From b6e9a7dc5b71061e886891b7cb27eb3a523e22fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EB=8F=99=EA=B2=B8?= Date: Wed, 27 Nov 2024 02:48:22 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Feature/#157=20-=20=EC=8B=A0?= =?UTF-8?q?=EB=AC=B8=EA=B3=A0(Suggestion)=20=EB=8F=84=EB=A9=94=EC=9D=B8?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=20=EA=B5=AC=ED=98=84=20(#158)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ Feature/#157 - 게시글(Board) 도메인 구현 * ✨ Feature/#157 - 댓글(Comment) 도메인 구현 * ✨ Feature/#157 - 공감(Like) 도메인 구현 * ✨ Feature/#157 - 신문고(Suggestion) 도메인그룹 구현 --- .../application/controller/command/.keep | 0 .../application/controller/query/.keep | 0 .../suggestion/application/dto/request/.keep | 0 .../suggestion/application/dto/response/.keep | 0 .../suggestion/application/service/.keep | 0 .../suggestion/application/usecase/.keep | 0 .../daon/onjung/suggestion/domain/Board.java | 65 +++++++++++++++++++ .../onjung/suggestion/domain/Comment.java | 57 ++++++++++++++++ .../daon/onjung/suggestion/domain/Like.java | 41 ++++++++++++ .../domain/service/BoardService.java | 7 ++ .../domain/service/CommentService.java | 7 ++ .../domain/service/LikeService.java | 7 ++ .../daon/onjung/suggestion/domain/type/.keep | 0 .../repository/mysql/BoardRepository.java | 9 +++ .../repository/mysql/CommentRepository.java | 9 +++ .../repository/mysql/LikeRepository.java | 9 +++ 16 files changed, 211 insertions(+) create mode 100644 src/main/java/com/daon/onjung/suggestion/application/controller/command/.keep create mode 100644 src/main/java/com/daon/onjung/suggestion/application/controller/query/.keep create mode 100644 src/main/java/com/daon/onjung/suggestion/application/dto/request/.keep create mode 100644 src/main/java/com/daon/onjung/suggestion/application/dto/response/.keep create mode 100644 src/main/java/com/daon/onjung/suggestion/application/service/.keep create mode 100644 src/main/java/com/daon/onjung/suggestion/application/usecase/.keep create mode 100644 src/main/java/com/daon/onjung/suggestion/domain/Board.java create mode 100644 src/main/java/com/daon/onjung/suggestion/domain/Comment.java create mode 100644 src/main/java/com/daon/onjung/suggestion/domain/Like.java create mode 100644 src/main/java/com/daon/onjung/suggestion/domain/service/BoardService.java create mode 100644 src/main/java/com/daon/onjung/suggestion/domain/service/CommentService.java create mode 100644 src/main/java/com/daon/onjung/suggestion/domain/service/LikeService.java create mode 100644 src/main/java/com/daon/onjung/suggestion/domain/type/.keep create mode 100644 src/main/java/com/daon/onjung/suggestion/repository/mysql/BoardRepository.java create mode 100644 src/main/java/com/daon/onjung/suggestion/repository/mysql/CommentRepository.java create mode 100644 src/main/java/com/daon/onjung/suggestion/repository/mysql/LikeRepository.java diff --git a/src/main/java/com/daon/onjung/suggestion/application/controller/command/.keep b/src/main/java/com/daon/onjung/suggestion/application/controller/command/.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/com/daon/onjung/suggestion/application/controller/query/.keep b/src/main/java/com/daon/onjung/suggestion/application/controller/query/.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/com/daon/onjung/suggestion/application/dto/request/.keep b/src/main/java/com/daon/onjung/suggestion/application/dto/request/.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/com/daon/onjung/suggestion/application/dto/response/.keep b/src/main/java/com/daon/onjung/suggestion/application/dto/response/.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/com/daon/onjung/suggestion/application/service/.keep b/src/main/java/com/daon/onjung/suggestion/application/service/.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/com/daon/onjung/suggestion/application/usecase/.keep b/src/main/java/com/daon/onjung/suggestion/application/usecase/.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/com/daon/onjung/suggestion/domain/Board.java b/src/main/java/com/daon/onjung/suggestion/domain/Board.java new file mode 100644 index 0000000..65758b0 --- /dev/null +++ b/src/main/java/com/daon/onjung/suggestion/domain/Board.java @@ -0,0 +1,65 @@ +package com.daon.onjung.suggestion.domain; + +import com.daon.onjung.account.domain.User; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "boards") +public class Board { + /* -------------------------------------------- */ + /* Default Column ----------------------------- */ + /* -------------------------------------------- */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + /* -------------------------------------------- */ + /* Information Column ------------------------- */ + /* -------------------------------------------- */ + @Column(name = "title", length = 20, nullable = false) + private String title; + + @Column(name = "content", length = 500, nullable = false) + private String content; + + @Column(name = "img_url", length = 2080, nullable = true) + private String imgUrl; + + @Column(name = "like_count", nullable = false) + private Integer likeCount; + + /* -------------------------------------------- */ + /* Timestamp Column --------------------------- */ + /* -------------------------------------------- */ + @Column(name = "created_at", nullable = false, updatable = false) + private LocalDateTime createdAt; + + /* -------------------------------------------- */ + /* Many To One Mapping ------------------------ */ + /* -------------------------------------------- */ + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "users_id", nullable = false) + private User user; + + /* -------------------------------------------- */ + /* Methods ------------------------------------ */ + /* -------------------------------------------- */ + @Builder + public Board(String title, String content, String imgUrl, User user) { + this.title = title; + this.content = content; + this.imgUrl = imgUrl; + this.user = user; + this.likeCount = 0; + this.createdAt = LocalDateTime.now(); + } + +} diff --git a/src/main/java/com/daon/onjung/suggestion/domain/Comment.java b/src/main/java/com/daon/onjung/suggestion/domain/Comment.java new file mode 100644 index 0000000..0eb6a7a --- /dev/null +++ b/src/main/java/com/daon/onjung/suggestion/domain/Comment.java @@ -0,0 +1,57 @@ +package com.daon.onjung.suggestion.domain; + +import com.daon.onjung.account.domain.User; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "comments") +public class Comment { + /* -------------------------------------------- */ + /* Default Column ----------------------------- */ + /* -------------------------------------------- */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + /* -------------------------------------------- */ + /* Information Column ------------------------- */ + /* -------------------------------------------- */ + @Column(name = "content", length = 100, nullable = false) + private String content; + + /* -------------------------------------------- */ + /* Timestamp Column --------------------------- */ + /* -------------------------------------------- */ + @Column(name = "created_at", nullable = false, updatable = false) + private LocalDateTime createdAt; + + /* -------------------------------------------- */ + /* Many To One Mapping ------------------------ */ + /* -------------------------------------------- */ + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "users_id", nullable = false) + private User user; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "boards_id", nullable = false) + private Board board; + + /* -------------------------------------------- */ + /* Methods ------------------------------------ */ + /* -------------------------------------------- */ + @Builder + public Comment(String content, User user, Board board) { + this.content = content; + this.user = user; + this.board = board; + this.createdAt = LocalDateTime.now(); + } +} diff --git a/src/main/java/com/daon/onjung/suggestion/domain/Like.java b/src/main/java/com/daon/onjung/suggestion/domain/Like.java new file mode 100644 index 0000000..aff8df9 --- /dev/null +++ b/src/main/java/com/daon/onjung/suggestion/domain/Like.java @@ -0,0 +1,41 @@ +package com.daon.onjung.suggestion.domain; + +import com.daon.onjung.account.domain.User; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "likes") +public class Like { + /* -------------------------------------------- */ + /* Default Column ----------------------------- */ + /* -------------------------------------------- */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + /* -------------------------------------------- */ + /* Many To One Mapping ------------------------ */ + /* -------------------------------------------- */ + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "users_id", nullable = false) + private User user; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "boards_id", nullable = false) + private Board board; + + /* -------------------------------------------- */ + /* Methods ------------------------------------ */ + /* -------------------------------------------- */ + @Builder + public Like(User user, Board board) { + this.user = user; + this.board = board; + } +} diff --git a/src/main/java/com/daon/onjung/suggestion/domain/service/BoardService.java b/src/main/java/com/daon/onjung/suggestion/domain/service/BoardService.java new file mode 100644 index 0000000..6453f28 --- /dev/null +++ b/src/main/java/com/daon/onjung/suggestion/domain/service/BoardService.java @@ -0,0 +1,7 @@ +package com.daon.onjung.suggestion.domain.service; + +import org.springframework.stereotype.Service; + +@Service +public class BoardService { +} diff --git a/src/main/java/com/daon/onjung/suggestion/domain/service/CommentService.java b/src/main/java/com/daon/onjung/suggestion/domain/service/CommentService.java new file mode 100644 index 0000000..10b2ebe --- /dev/null +++ b/src/main/java/com/daon/onjung/suggestion/domain/service/CommentService.java @@ -0,0 +1,7 @@ +package com.daon.onjung.suggestion.domain.service; + +import org.springframework.stereotype.Service; + +@Service +public class CommentService { +} diff --git a/src/main/java/com/daon/onjung/suggestion/domain/service/LikeService.java b/src/main/java/com/daon/onjung/suggestion/domain/service/LikeService.java new file mode 100644 index 0000000..9afe744 --- /dev/null +++ b/src/main/java/com/daon/onjung/suggestion/domain/service/LikeService.java @@ -0,0 +1,7 @@ +package com.daon.onjung.suggestion.domain.service; + +import org.springframework.stereotype.Service; + +@Service +public class LikeService { +} diff --git a/src/main/java/com/daon/onjung/suggestion/domain/type/.keep b/src/main/java/com/daon/onjung/suggestion/domain/type/.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/com/daon/onjung/suggestion/repository/mysql/BoardRepository.java b/src/main/java/com/daon/onjung/suggestion/repository/mysql/BoardRepository.java new file mode 100644 index 0000000..fb3ea25 --- /dev/null +++ b/src/main/java/com/daon/onjung/suggestion/repository/mysql/BoardRepository.java @@ -0,0 +1,9 @@ +package com.daon.onjung.suggestion.repository.mysql; + +import com.daon.onjung.suggestion.domain.Board; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface BoardRepository extends JpaRepository { +} diff --git a/src/main/java/com/daon/onjung/suggestion/repository/mysql/CommentRepository.java b/src/main/java/com/daon/onjung/suggestion/repository/mysql/CommentRepository.java new file mode 100644 index 0000000..d5221ca --- /dev/null +++ b/src/main/java/com/daon/onjung/suggestion/repository/mysql/CommentRepository.java @@ -0,0 +1,9 @@ +package com.daon.onjung.suggestion.repository.mysql; + +import com.daon.onjung.suggestion.domain.Comment; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface CommentRepository extends JpaRepository { +} diff --git a/src/main/java/com/daon/onjung/suggestion/repository/mysql/LikeRepository.java b/src/main/java/com/daon/onjung/suggestion/repository/mysql/LikeRepository.java new file mode 100644 index 0000000..ae2992b --- /dev/null +++ b/src/main/java/com/daon/onjung/suggestion/repository/mysql/LikeRepository.java @@ -0,0 +1,9 @@ +package com.daon.onjung.suggestion.repository.mysql; + +import com.daon.onjung.suggestion.domain.Like; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface LikeRepository extends JpaRepository { +}