Skip to content

Commit

Permalink
Merge pull request #6 from Sopo2023/feat/#2
Browse files Browse the repository at this point in the history
Feat/#2
  • Loading branch information
GayeongKimm authored Jul 24, 2024
2 parents 06e4d0c + 711cce6 commit 0751405
Show file tree
Hide file tree
Showing 11 changed files with 298 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
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()
);
}
}
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 으로 묶어서 받아야 함.
);
}
}
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
) {
}
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();
}

}
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()
);
}
}
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 으로 묶어서 받아야 함.
);
}
}
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
) {
}
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();
}
}
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
}
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;

}

0 comments on commit 0751405

Please sign in to comment.