From cd5ddee252bc09d74fbf30a43bb0b196020fa46a Mon Sep 17 00:00:00 2001 From: su080915 Date: Tue, 27 Aug 2024 04:00:47 +0900 Subject: [PATCH] feat :: edit --- .../domain/post/comment/Comment.java | 56 --------------- .../domain/post/domain/Post.java | 68 ------------------- .../domain/post/dto/AddCommentRequest.java | 32 --------- .../post/repository/CommentRepository.java | 8 --- .../src/main/resources/application.yml | 10 ++- 5 files changed, 4 insertions(+), 170 deletions(-) delete mode 100644 crescendo-server/src/main/java/com/example/crescendoserver/domain/post/comment/Comment.java delete mode 100644 crescendo-server/src/main/java/com/example/crescendoserver/domain/post/domain/Post.java delete mode 100644 crescendo-server/src/main/java/com/example/crescendoserver/domain/post/dto/AddCommentRequest.java delete mode 100644 crescendo-server/src/main/java/com/example/crescendoserver/domain/post/repository/CommentRepository.java diff --git a/crescendo-server/src/main/java/com/example/crescendoserver/domain/post/comment/Comment.java b/crescendo-server/src/main/java/com/example/crescendoserver/domain/post/comment/Comment.java deleted file mode 100644 index f5ef8e6..0000000 --- a/crescendo-server/src/main/java/com/example/crescendoserver/domain/post/comment/Comment.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.example.crescendoserver.domain.post.comment; - -import com.example.crescendoserver.domain.post.domain.Post; -import com.example.crescendoserver.domain.user.domain.User; -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.Table; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.springframework.data.annotation.CreatedDate; -import org.springframework.data.annotation.LastModifiedDate; - -import java.time.LocalDateTime; - -@Builder -@AllArgsConstructor -@NoArgsConstructor -@Getter -@Table(name = "comments") -@Entity -public class Comment { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(columnDefinition = "TEXT", nullable = false) - private String comment; - - @Column(name = "created_date") - @CreatedDate - private LocalDateTime createdDate; - - @Column(name = "modified_date") - @LastModifiedDate - private LocalDateTime modifiedDate; - - @ManyToOne - @JoinColumn(name = "post_id") - private Post post; - - @ManyToOne - @JoinColumn(name = "user_id") - private User user; // 작성자 - - //댓글 수정 - public void update(String comment) { - this.comment = comment; - } -} diff --git a/crescendo-server/src/main/java/com/example/crescendoserver/domain/post/domain/Post.java b/crescendo-server/src/main/java/com/example/crescendoserver/domain/post/domain/Post.java deleted file mode 100644 index 4630156..0000000 --- a/crescendo-server/src/main/java/com/example/crescendoserver/domain/post/domain/Post.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.example.crescendoserver.domain.post.domain; - - -import com.example.crescendoserver.domain.post.comment.Comment; -import jakarta.persistence.CascadeType; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.OneToMany; -import jakarta.persistence.OrderBy; -import jakarta.persistence.Table; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.springframework.data.annotation.CreatedDate; -import org.springframework.data.annotation.LastModifiedDate; - -import java.time.LocalDateTime; -import java.util.List; - -@Entity -@Getter//모든필드에 대한 접근자 메서드 생성 -@Table(name = "posts") -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Post { - @Id - @GeneratedValue(strategy= GenerationType.IDENTITY) - @Column(name="id",updatable = false) - private Long id; - - @Column(name="title",nullable = false) - private String title; - - @Column(name="content",nullable = false) - private String content; - - @Column(name="author",nullable = false) - private String author; - - - @Builder - public Post(String author,String title,String content,String comment){ - this.author = author; - this.title = title; - this.content = content; - } - - public void update(String title,String content){ - this.title = title; - this.content = content; - } - - @CreatedDate //엔티티가 생성될 때 생성 시간 저장 - @Column(name="created_at") - private LocalDateTime createdAt; - - @LastModifiedDate //엔티티가 수정될 때 수정 시간 저장 - @Column(name="updated_at") - private LocalDateTime updatedAt; - - @OneToMany(mappedBy = "posts", fetch = FetchType.EAGER, cascade = CascadeType.REMOVE) - @OrderBy("id asc") // 댓글 정렬 - private List comments; -} diff --git a/crescendo-server/src/main/java/com/example/crescendoserver/domain/post/dto/AddCommentRequest.java b/crescendo-server/src/main/java/com/example/crescendoserver/domain/post/dto/AddCommentRequest.java deleted file mode 100644 index 1843342..0000000 --- a/crescendo-server/src/main/java/com/example/crescendoserver/domain/post/dto/AddCommentRequest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.example.crescendoserver.domain.post.dto; - -import com.example.crescendoserver.domain.post.comment.Comment; -import com.example.crescendoserver.domain.user.domain.User; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -public class AddCommentRequest { - private Long id; - private String comment; - private String createdDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy.MM.dd HH:mm")); - private String modifiedDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy.MM.dd HH:mm")); - private String user; - private int article; - -// public Comment toEntity() { //생성자를 사용해 객체 생성 -// return Comment.builder() -// .comment(comment) -// .createdDate(LocalDateTime.parse(createdDate)) -// .modifiedDate(LocalDateTime.parse(modifiedDate)) -// .user(user) -// .article(article) -// .build(); -// } -} \ No newline at end of file diff --git a/crescendo-server/src/main/java/com/example/crescendoserver/domain/post/repository/CommentRepository.java b/crescendo-server/src/main/java/com/example/crescendoserver/domain/post/repository/CommentRepository.java deleted file mode 100644 index f939a1e..0000000 --- a/crescendo-server/src/main/java/com/example/crescendoserver/domain/post/repository/CommentRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.crescendoserver.domain.post.repository; - -import com.example.crescendoserver.domain.post.comment.Comment; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface CommentRepository extends JpaRepository { -} - diff --git a/crescendo-server/src/main/resources/application.yml b/crescendo-server/src/main/resources/application.yml index f0ca524..2c55e13 100644 --- a/crescendo-server/src/main/resources/application.yml +++ b/crescendo-server/src/main/resources/application.yml @@ -14,12 +14,10 @@ spring: hibernate: ddl-auto: create -ai: - openai: - api-key: ${CHATGPT_API_KEY} - chat: - options: - model: gpt-3.5-turbo + ai: + openai: + api-key: ${CHATGPT_API_KEY} + redis: