-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardCommandRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardLoadRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> fileUrls, | ||
// Long memberId | ||
){ | ||
public static BoardLoadRes of(BoardEntity board) { | ||
return new BoardLoadRes( | ||
board.getBoardId(), | ||
board.getBoardTitle(), | ||
board.getBoardTitle(), | ||
board.getBoardLikeCount() | ||
//board.getFile() Url을 String 으로 묶어서 받아야 함. | ||
); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/dto/BoardUpdateReq.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package kr.hs.dgsw.SOPO_server_v2.domain.board.dto; | ||
|
||
public record BoardUpdateReq( | ||
String boardTitle, | ||
String boardContent | ||
) { | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/board/entity/BoardEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
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.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; | ||
|
||
@Getter | ||
@Entity | ||
@Table(name = "tbl_board") | ||
@NoArgsConstructor | ||
@SuperBuilder | ||
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 = 0; | ||
|
||
// 유저 아이디 | ||
@ManyToOne | ||
@JoinColumn(name = "member_id") // member_id로 참조한다. | ||
private MemberEntity member; | ||
|
||
// 게시물 파일 | ||
@OneToMany(mappedBy = "board", cascade = CascadeType.ALL, orphanRemoval = true) // 읽기만, 게시물 삭제될 때 함께 삭제 | ||
private List<FileEntity> file; | ||
|
||
public void update(BoardUpdateReq updateReq) { | ||
this.boardTitle = updateReq.boardTitle(); | ||
this.boardContent = updateReq.boardContent(); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestCommandRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestLoadRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> 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 으로 묶어서 받아야 함. | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/dto/ContestUpdateReq.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) { | ||
} |
83 changes: 83 additions & 0 deletions
83
src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/entity/ContestEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
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.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; | ||
|
||
@Getter | ||
@Entity | ||
@Table(name = "tbl_contest") | ||
@NoArgsConstructor | ||
@SuperBuilder | ||
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") | ||
@Enumerated(EnumType.STRING) | ||
private ContestState contestState = ContestState.ACTIVE; | ||
|
||
// 대회 정원 | ||
@Column(name = "contest_max") | ||
private Integer contestMax; | ||
|
||
// 대회 인원 | ||
@Column(name = "contest_person") | ||
private Integer contestPerson; | ||
|
||
// 대회 마감일 | ||
@Column(name = "contest_date_time") | ||
private LocalDateTime contestDateTime; | ||
|
||
// 대회 좋아요 | ||
@Column(name = "contest_like_count") | ||
private Integer contestLikeCount = 0; | ||
|
||
// 유저 아이디 | ||
@ManyToOne | ||
@JoinColumn(name = "member_id") | ||
private MemberEntity member; | ||
|
||
// 대회 파일 | ||
@OneToMany(mappedBy = "contest", cascade = CascadeType.ALL, orphanRemoval = true) // 읽기만, 게시물 삭제될 때 함께 삭제 | ||
private List<FileEntity> 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(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/contest/enums/ContestState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package kr.hs.dgsw.SOPO_server_v2.domain.contest.enums; | ||
|
||
public enum ContestState { | ||
ACTIVE, DISABLED | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/entity/FileEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
} |