Skip to content

Commit

Permalink
Feat: Comment 기능구현
Browse files Browse the repository at this point in the history
* Feat : Comment 기본코드 가져오기
- 이전에 작성한 깃이 꼬여서 다시 가져왔습니다..

* Fix : Comment - Member Id 연관관계 매핑

* Fix: Comment - @NotNull 적용
  • Loading branch information
Shsin9797 authored Sep 23, 2024
1 parent ba4c28b commit 3935625
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package notai.comment.application;

public class CommentQueryService {
}
4 changes: 4 additions & 0 deletions src/main/java/notai/comment/application/CommentService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package notai.comment.application;

public class CommentService {
}
52 changes: 52 additions & 0 deletions src/main/java/notai/comment/domain/Comment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package notai.comment.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import notai.common.domain.RootEntity;
import notai.member.domain.Member;

import static jakarta.persistence.GenerationType.IDENTITY;
import static lombok.AccessLevel.PROTECTED;

@Entity
@Table(name = "comment")
@Getter
@NoArgsConstructor(access = PROTECTED)
@AllArgsConstructor
public class Comment extends RootEntity<Long> {
@Id
@GeneratedValue(strategy = IDENTITY)
private Long id;
@ManyToOne
@NotNull
@JoinColumn(name = "member_id")
private Member member;
@NotNull
@Column
private Long postId;
@NotNull
@Column
private Long parentCommentId;
@NotNull
@Column(length = 255)
private String content;
public Comment(
Member member,
Long postId,
String content
) {
this.member = member;
this.postId = postId;
this.content = content;
}

}
9 changes: 9 additions & 0 deletions src/main/java/notai/comment/domain/CommentRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package notai.comment.domain;

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,4 @@
package notai.comment.presentation;

public class CommentController {
}

0 comments on commit 3935625

Please sign in to comment.