Skip to content

Commit

Permalink
fix : post글 목록 최신순 반환
Browse files Browse the repository at this point in the history
  • Loading branch information
moonyaeyoon committed Sep 20, 2024
1 parent 5032db0 commit d77b534
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package meltingpot.server.domain.entity.comment;

import jakarta.persistence.*;
import jakarta.validation.constraints.Size;
import lombok.*;
import meltingpot.server.domain.entity.Account;
import meltingpot.server.domain.entity.post.Post;
Expand All @@ -20,6 +21,7 @@ public class Comment extends BaseEntity {
@Column(name = "comment_id")
private Long id;

@Size(min = 10, max = 500)
private String content;

@Column(name = "is_anonymous")
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/meltingpot/server/domain/entity/post/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import jakarta.persistence.*;
import jakarta.validation.constraints.Size;
import lombok.*;
import meltingpot.server.domain.entity.Account;
import meltingpot.server.domain.entity.Report;
Expand All @@ -28,8 +29,10 @@ public class Post extends BaseEntity {
@Column(name = "post_id")
private Long id;

@Size(min = 10, max = 500)
private String title;

@Size(min = 10, max = 500)
private String content;

@Enumerated(EnumType.STRING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public interface PostRepository extends JpaRepository<Post, Long> {

@Query("SELECT p FROM Post p WHERE p.postType = :postType AND p.isDraft = false AND (:cursor IS NULL OR p.id > :cursor) ORDER BY p.id ASC")
@Query("SELECT p FROM Post p WHERE p.postType = :postType AND p.isDraft = false AND (:cursor IS NULL OR p.id < :cursor) ORDER BY p.id DESC")
List<Post> findByPostTypeAndCursor(@Param("postType") PostType postType, @Param("cursor") Long cursor, Pageable pageable);

Slice<Post> findAllByAccountAndDeletedAtIsNullOrderByIdDesc(Account account, Pageable page);
Expand Down

0 comments on commit d77b534

Please sign in to comment.