Skip to content

Commit

Permalink
✨ Feature/#157 - 신문고(Suggestion) 도메인그룹 구현 (#158)
Browse files Browse the repository at this point in the history
* ✨ Feature/#157 - 게시글(Board) 도메인 구현

* ✨ Feature/#157 - 댓글(Comment) 도메인 구현

* ✨ Feature/#157 - 공감(Like) 도메인 구현

* ✨ Feature/#157 - 신문고(Suggestion) 도메인그룹 구현
  • Loading branch information
dongkyeomjang authored Nov 26, 2024
1 parent 11a23d2 commit b6e9a7d
Show file tree
Hide file tree
Showing 16 changed files with 211 additions and 0 deletions.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
65 changes: 65 additions & 0 deletions src/main/java/com/daon/onjung/suggestion/domain/Board.java
Original file line number Diff line number Diff line change
@@ -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();
}

}
57 changes: 57 additions & 0 deletions src/main/java/com/daon/onjung/suggestion/domain/Comment.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
41 changes: 41 additions & 0 deletions src/main/java/com/daon/onjung/suggestion/domain/Like.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.daon.onjung.suggestion.domain.service;

import org.springframework.stereotype.Service;

@Service
public class BoardService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.daon.onjung.suggestion.domain.service;

import org.springframework.stereotype.Service;

@Service
public class CommentService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.daon.onjung.suggestion.domain.service;

import org.springframework.stereotype.Service;

@Service
public class LikeService {
}
Empty file.
Original file line number Diff line number Diff line change
@@ -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<Board, Long> {
}
Original file line number Diff line number Diff line change
@@ -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<Comment, Long> {
}
Original file line number Diff line number Diff line change
@@ -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<Like, Long> {
}

0 comments on commit b6e9a7d

Please sign in to comment.