From 0008ccbfd0c6e6d071de7409913231c77dbe0253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=B8=EC=A4=80?= Date: Sun, 16 Jun 2024 00:34:21 +0900 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20build.gradle=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index 931edeb..858b8b5 100644 --- a/build.gradle +++ b/build.gradle @@ -27,6 +27,8 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-web' + // S3 + implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' compileOnly 'org.projectlombok:lombok' runtimeOnly 'com.mysql:mysql-connector-j' annotationProcessor 'org.projectlombok:lombok' From 7f52a8c205daaa9291cd53d46539d2c04f15f63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=B8=EC=A4=80?= Date: Tue, 23 Jul 2024 09:30:57 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20entity=20=EA=B8=B0=EB=B3=B8=20?= =?UTF-8?q?=EA=B5=AC=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/board/entity/BoardEntity.java | 53 +++++++++++++++ .../domain/contest/entity/ContestEntity.java | 68 +++++++++++++++++++ .../domain/contest/enums/ContestState.java | 5 ++ .../domain/file/entity/FileEntity.java | 49 +++++++++++++ 4 files changed, 175 insertions(+) create mode 100644 src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/entity/BoardEntity.java create mode 100644 src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/entity/ContestEntity.java create mode 100644 src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/enums/ContestState.java create mode 100644 src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/entity/FileEntity.java diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/entity/BoardEntity.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/entity/BoardEntity.java new file mode 100644 index 0000000..ed20d4f --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/entity/BoardEntity.java @@ -0,0 +1,53 @@ +package kr.hs.dgsw.SOPO_server_v2.domain.board.entity; + +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import kr.hs.dgsw.SOPO_server_v2.domain.file.entity.FileEntity; +import kr.hs.dgsw.SOPO_server_v2.domain.member.entity.MemberEntity; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Getter +@Entity +@Table(name = "tbl_board") +@NoArgsConstructor +public class BoardEntity { + + // 게시물 아이디 + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "board_id") + private Long boardId; + + // 게시물 제목 + @Column(name = "board_title") + private String boardTitle; + + // 게시물 내용 + @Column(name = "board_content") + private String boardContent; + + // 게시물 좋아요 + @Column(name = "board_like_count") + private Integer boardLikeCount; + + // 유저 아이디 + @ManyToOne + @JoinColumn(name = "member_id") // member_id로 참조한다. + private MemberEntity member; + + // 게시물 파일 + @OneToMany(mappedBy = "board", cascade = CascadeType.ALL, orphanRemoval = true) // 읽기만, 게시물 삭제될 때 함께 삭제 + private List file; + +} diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/entity/ContestEntity.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/entity/ContestEntity.java new file mode 100644 index 0000000..07d78e9 --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/entity/ContestEntity.java @@ -0,0 +1,68 @@ +package kr.hs.dgsw.SOPO_server_v2.domain.contest.entity; + +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import kr.hs.dgsw.SOPO_server_v2.domain.contest.enums.ContestState; +import kr.hs.dgsw.SOPO_server_v2.domain.file.entity.FileEntity; +import kr.hs.dgsw.SOPO_server_v2.domain.member.entity.MemberEntity; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +@Getter +@Entity +@Table(name = "tbl_contest") +@NoArgsConstructor +public class ContestEntity { + + // 대회 아이디 + @Id + @Column(name = "contest_id") + private Long contestId; + + // 대회 제목 + @Column(name = "contest_title") + private String contestTitle; + + // 대회 내용 + @Column(name = "contest_content") + private String contestContent; + + // 대회 상태 + @Column(name = "contest_state") + private ContestState contestState; + + // 대회 정원 + @Column(name = "contest_max") + private Integer contestMax; + + // 대회 인원 + @Column(name = "contest_person") + private Integer contestPerson; + + // 대회 마감일 + @Column(name = "contest_date_time") + private Date contestDateTime; + + // 대회 좋아요 + @Column(name = "contest_like_count") + private Integer contestLikeCount; + + // 유저 아이디 + @ManyToOne + @JoinColumn(name = "member_id") + private MemberEntity member; + + // 대회 파일 + @OneToMany(mappedBy = "contest", cascade = CascadeType.ALL, orphanRemoval = true) // 읽기만, 게시물 삭제될 때 함께 삭제 + private List file; + +} diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/enums/ContestState.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/enums/ContestState.java new file mode 100644 index 0000000..cee28d5 --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/enums/ContestState.java @@ -0,0 +1,5 @@ +package kr.hs.dgsw.SOPO_server_v2.domain.contest.enums; + +public enum ContestState { + ACTIVE, DISABLED +} diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/entity/FileEntity.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/entity/FileEntity.java new file mode 100644 index 0000000..65597fd --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/entity/FileEntity.java @@ -0,0 +1,49 @@ +package kr.hs.dgsw.SOPO_server_v2.domain.file.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import kr.hs.dgsw.SOPO_server_v2.domain.board.entity.BoardEntity; +import kr.hs.dgsw.SOPO_server_v2.domain.contest.entity.ContestEntity; +import kr.hs.dgsw.SOPO_server_v2.domain.member.entity.MemberEntity; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table(name = "tbl_file") +@NoArgsConstructor +public class FileEntity { + + // 파일 아이디 + @Id + @Column(name = "file_id") + private Long fileId; + + // 파일 이름 + @Column(name = "file_name") + private String fileName; + + // 파일 url + @Column(name = "file_url") + private String fileUrl; + + // 게시물 아이디 + @ManyToOne + @JoinColumn(name = "board_id") + private BoardEntity board; + + // 대회 아이디 + @ManyToOne + @JoinColumn(name = "contest_id") + private ContestEntity contest; + + // 유저 아이디 + @ManyToOne + @JoinColumn(name = "member_id") + private MemberEntity member; + +} From d2e902cb537a6cf184a40a5f8dbd393e2562d441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=B8=EC=A4=80?= Date: Tue, 23 Jul 2024 20:44:56 +0900 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20board=20&=20contest=20entity=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/board/entity/BoardEntity.java | 10 ++++++++- .../domain/contest/entity/ContestEntity.java | 21 ++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/entity/BoardEntity.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/entity/BoardEntity.java index ed20d4f..b9bf40c 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/entity/BoardEntity.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/entity/BoardEntity.java @@ -10,10 +10,12 @@ import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import kr.hs.dgsw.SOPO_server_v2.domain.board.dto.BoardUpdateReq; import kr.hs.dgsw.SOPO_server_v2.domain.file.entity.FileEntity; import kr.hs.dgsw.SOPO_server_v2.domain.member.entity.MemberEntity; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; import java.util.List; @@ -21,6 +23,7 @@ @Entity @Table(name = "tbl_board") @NoArgsConstructor +@SuperBuilder public class BoardEntity { // 게시물 아이디 @@ -39,7 +42,7 @@ public class BoardEntity { // 게시물 좋아요 @Column(name = "board_like_count") - private Integer boardLikeCount; + private Integer boardLikeCount = 0; // 유저 아이디 @ManyToOne @@ -50,4 +53,9 @@ public class BoardEntity { @OneToMany(mappedBy = "board", cascade = CascadeType.ALL, orphanRemoval = true) // 읽기만, 게시물 삭제될 때 함께 삭제 private List file; + public void update(BoardUpdateReq updateReq) { + this.boardTitle = updateReq.boardTitle(); + this.boardContent = updateReq.boardContent(); + } + } diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/entity/ContestEntity.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/entity/ContestEntity.java index 07d78e9..5dff9c1 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/entity/ContestEntity.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/entity/ContestEntity.java @@ -3,17 +3,23 @@ import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import kr.hs.dgsw.SOPO_server_v2.domain.contest.dto.ContestUpdateReq; import kr.hs.dgsw.SOPO_server_v2.domain.contest.enums.ContestState; import kr.hs.dgsw.SOPO_server_v2.domain.file.entity.FileEntity; import kr.hs.dgsw.SOPO_server_v2.domain.member.entity.MemberEntity; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.Date; import java.util.List; @@ -21,6 +27,7 @@ @Entity @Table(name = "tbl_contest") @NoArgsConstructor +@SuperBuilder public class ContestEntity { // 대회 아이디 @@ -38,7 +45,8 @@ public class ContestEntity { // 대회 상태 @Column(name = "contest_state") - private ContestState contestState; + @Enumerated(EnumType.STRING) + private ContestState contestState = ContestState.ACTIVE; // 대회 정원 @Column(name = "contest_max") @@ -50,11 +58,11 @@ public class ContestEntity { // 대회 마감일 @Column(name = "contest_date_time") - private Date contestDateTime; + private LocalDateTime contestDateTime; // 대회 좋아요 @Column(name = "contest_like_count") - private Integer contestLikeCount; + private Integer contestLikeCount = 0; // 유저 아이디 @ManyToOne @@ -65,4 +73,11 @@ public class ContestEntity { @OneToMany(mappedBy = "contest", cascade = CascadeType.ALL, orphanRemoval = true) // 읽기만, 게시물 삭제될 때 함께 삭제 private List file; + public void update(ContestUpdateReq updateReq) { + this.contestTitle = updateReq.contestTitle(); + this.contestContent = updateReq.contestContent(); + this.contestMax = updateReq.contestMax(); + this.contestPerson = updateReq.contestPerson(); + this.contestDateTime = updateReq.contestDateTime(); + } } From 711cce603f7467ed48ad83e1aa88ae3580a7009f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=B8=EC=A4=80?= Date: Tue, 23 Jul 2024 20:45:12 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20board=20&=20contest=20dto=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/board/dto/BoardCommandRes.java | 13 +++++++++ .../domain/board/dto/BoardLoadRes.java | 22 +++++++++++++++ .../domain/board/dto/BoardUpdateReq.java | 7 +++++ .../domain/contest/dto/ContestCommandRes.java | 14 ++++++++++ .../domain/contest/dto/ContestLoadRes.java | 28 +++++++++++++++++++ .../domain/contest/dto/ContestUpdateReq.java | 14 ++++++++++ 6 files changed, 98 insertions(+) create mode 100644 src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardCommandRes.java create mode 100644 src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardLoadRes.java create mode 100644 src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardUpdateReq.java create mode 100644 src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestCommandRes.java create mode 100644 src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestLoadRes.java create mode 100644 src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestUpdateReq.java diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardCommandRes.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardCommandRes.java new file mode 100644 index 0000000..509fe1c --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardCommandRes.java @@ -0,0 +1,13 @@ +package kr.hs.dgsw.SOPO_server_v2.domain.board.dto; + +import kr.hs.dgsw.SOPO_server_v2.domain.board.entity.BoardEntity; + +public record BoardCommandRes ( + Long boardId +) { + public static BoardCommandRes of (BoardEntity board) { + return new BoardCommandRes( + board.getBoardId() + ); + } +} diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardLoadRes.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardLoadRes.java new file mode 100644 index 0000000..aa34495 --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardLoadRes.java @@ -0,0 +1,22 @@ +package kr.hs.dgsw.SOPO_server_v2.domain.board.dto; + +import kr.hs.dgsw.SOPO_server_v2.domain.board.entity.BoardEntity; + +public record BoardLoadRes ( + Long boardId, + String boardTitle, + String boardContent, + Integer boardLikeCount + // List fileUrls, + // Long memberId +){ + public static BoardLoadRes of(BoardEntity board) { + return new BoardLoadRes( + board.getBoardId(), + board.getBoardTitle(), + board.getBoardTitle(), + board.getBoardLikeCount() + //board.getFile() Url을 String 으로 묶어서 받아야 함. + ); + } +} diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardUpdateReq.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardUpdateReq.java new file mode 100644 index 0000000..4af3686 --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardUpdateReq.java @@ -0,0 +1,7 @@ +package kr.hs.dgsw.SOPO_server_v2.domain.board.dto; + +public record BoardUpdateReq( + String boardTitle, + String boardContent +) { +} diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestCommandRes.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestCommandRes.java new file mode 100644 index 0000000..1b535f2 --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestCommandRes.java @@ -0,0 +1,14 @@ +package kr.hs.dgsw.SOPO_server_v2.domain.contest.dto; + +import kr.hs.dgsw.SOPO_server_v2.domain.contest.entity.ContestEntity; + + +public record ContestCommandRes( + Long contestId +) { + public static ContestCommandRes of (ContestEntity contest) { + return new ContestCommandRes( + contest.getContestId() + ); + } +} diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestLoadRes.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestLoadRes.java new file mode 100644 index 0000000..d02e589 --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestLoadRes.java @@ -0,0 +1,28 @@ +package kr.hs.dgsw.SOPO_server_v2.domain.contest.dto; + +import kr.hs.dgsw.SOPO_server_v2.domain.contest.entity.ContestEntity; + +import java.time.LocalDateTime; + +public record ContestLoadRes ( + Long contestId, + String contestTitle, + String contestContent, + Integer contestMax, + Integer contestPerson, + LocalDateTime contestDateTime + // List fileUrls, + // Long memberId +) { + public static ContestLoadRes of(ContestEntity contest) { + return new ContestLoadRes ( + contest.getContestId(), + contest.getContestTitle(), + contest.getContestContent(), + contest.getContestMax(), + contest.getContestPerson(), + contest.getContestDateTime() + //contest.getFile() Url을 String 으로 묶어서 받아야 함. + ); + } +} diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestUpdateReq.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestUpdateReq.java new file mode 100644 index 0000000..d4dc108 --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestUpdateReq.java @@ -0,0 +1,14 @@ +package kr.hs.dgsw.SOPO_server_v2.domain.contest.dto; + +import kr.hs.dgsw.SOPO_server_v2.domain.contest.enums.ContestState; + +import java.time.LocalDateTime; + +public record ContestUpdateReq ( + String contestTitle, + String contestContent, + Integer contestMax, + Integer contestPerson, + LocalDateTime contestDateTime +) { +}