Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Feature/#157 - 신문고(Suggestion) 도메인그룹 구현 #158

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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> {
}