Skip to content

Commit

Permalink
Merge pull request #5 from UniD-Hackathon-Team4/feature/#3/subscribe
Browse files Browse the repository at this point in the history
Feature/#3/subscribe
  • Loading branch information
kyungminlee-12 authored Nov 5, 2022
2 parents f4de27d + 296a685 commit 543117d
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/example/DayClassBack/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@EnableJpaAuditing
@SpringBootApplication
public class Application {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.DayClassBack.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;

@Slf4j
@RequiredArgsConstructor
@RequestMapping("/api/homebody/subscribe")
public class SubscribeController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.example.DayClassBack.dto.request;

import com.example.DayClassBack.enums.Ott;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotEmpty;
// import javax.validation.constraints.Pattern;
import java.time.LocalDateTime;

public class PartyRequestDto {

@Getter
@Setter
public static class Write {

@NotEmpty(message = "title은 필수 입력값입니다.")
// @Pattern(regexp = "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,6}$", message = "이메일 형식에 맞지 않습니다.")
private String title;

@NotEmpty(message = "content는 필수 입력값입니다.")
// @Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[~!@#$%^&*()+|=])[A-Za-z\\d~!@#$%^&*()+|=]{8,16}$", message = "비밀번호는 8~16자 영문 대 소문자, 숫자, 특수문자를 사용하세요.")
private String content;

@NotEmpty(message = "필수 입력값입니다.")
private int number_of_people;

@NotEmpty(message = "필수 입력값입니다.")
private LocalDateTime start_date;

@NotEmpty(message = "필수 입력값입니다.")
private LocalDateTime end_date;

@NotEmpty(message = "필수 입력값입니다.")
private int cost;

@NotEmpty(message = "ott는 필수 입력값입니다.")
private Ott ott;

@NotEmpty(message = "o필수 입력값입니다.")
private boolean is_completed;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.DayClassBack.dto.response;

import com.example.DayClassBack.enums.Type;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

public class PartyResponseDto {

@Builder
@Getter
@AllArgsConstructor
public static class PartyWriteInfo {
private int id;
private int user_id;

private String title;
private String content;

private Type type;

private String refreshToken;
private Long refreshTokenExpirationTime;
}

}
6 changes: 4 additions & 2 deletions src/main/java/com/example/DayClassBack/entity/BaseTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.time.LocalDateTime;
Expand All @@ -15,8 +16,9 @@
public class BaseTime {

@CreatedDate
private LocalDateTime createDate;
@Column(updatable = false)
private LocalDateTime created_at;

@LastModifiedDate
private LocalDateTime modifiedDate;
private LocalDateTime updated_at;
}
65 changes: 65 additions & 0 deletions src/main/java/com/example/DayClassBack/entity/Party.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.example.DayClassBack.entity;

import com.example.DayClassBack.enums.Ott;
import com.example.DayClassBack.enums.Type;
import lombok.*;
import org.springframework.data.annotation.CreatedDate;

import javax.persistence.*;
import java.time.LocalDateTime;

@Builder
@NoArgsConstructor
@AllArgsConstructor
@Setter
@Getter
@Entity
public class Party extends BaseTime {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne // Many = Party, Users = One 한명의 유저는 여러개의 게시글을 쓸 수 있다.
@JoinColumn(name="user_id") // foreign key (userId) references User (id)
private Users users;

/*
@Column
@CreatedDate
private LocalDateTime created_at;
@Column
private LocalDateTime updated_at;
*/

@Column(nullable = false)
@Enumerated(EnumType.STRING) // enum의 이름으로 지정
private Type type;

@Column(nullable = false)
private int number_of_people;

@Column(nullable = false)
private LocalDateTime start_date;

@Column
private LocalDateTime end_date;

@Column(nullable = false)
private int cost;

@Column(nullable = false)
@Enumerated(EnumType.STRING) // enum의 이름으로 지정
private Ott ott;

@Column(nullable = false)
private boolean is_completed;

@Column(nullable = false)
private String title;

@Column(nullable = false)
private String contents;

}
17 changes: 13 additions & 4 deletions src/main/java/com/example/DayClassBack/entity/Users.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.example.DayClassBack.entity;

import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import javax.persistence.*;
import java.security.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand All @@ -23,16 +26,22 @@ public class Users extends BaseTime implements UserDetails {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idx;

@Column
@Column(nullable = false)
private String email;

@Column
@Column(nullable = false)
private String password;

@Column
@Column(nullable = false)
private String username;

@Column
// @CreationTimestamp
// private Timestamp create_date;

// @UpdateTimestamp
// private Timestamp modified_date;

@Column(nullable = false)
@ElementCollection(fetch = FetchType.EAGER)
@Builder.Default
private List<String> roles = new ArrayList<>();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/example/DayClassBack/enums/Ott.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.example.DayClassBack.enums;

public enum Ott {
Netflix,
Watcha,
Disney_Plus,
Wavve,
Apple_TV,
TVING
}
6 changes: 6 additions & 0 deletions src/main/java/com/example/DayClassBack/enums/Type.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.DayClassBack.enums;

public enum Type {
Gather, // 모집
Rental // 대여
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.DayClassBack.repository;

import com.example.DayClassBack.entity.Party;
import org.springframework.data.jpa.repository.JpaRepository;

public interface PartyRepository extends JpaRepository<Party, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.example.DayClassBack.service;

public class PartyService {
}

0 comments on commit 543117d

Please sign in to comment.