Skip to content

Commit 5fd66f1

Browse files
committed
feat(auth): JWT 로그인 기능 및 기본 프로필 설정 추가
1 parent de99205 commit 5fd66f1

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/main/java/com/example/FixLog/domain/post/Post.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.example.FixLog.domain.post;
22

33
import com.example.FixLog.domain.bookmark.Bookmark;
4+
import com.example.FixLog.domain.like.PostLike;
45
import com.example.FixLog.domain.member.Member;
56
import jakarta.persistence.*;
67
import lombok.AccessLevel;
@@ -70,9 +71,14 @@ public class Post {
7071
@OneToMany(mappedBy = "postId", cascade = CascadeType.ALL, orphanRemoval = true)
7172
private List<Bookmark> bookmarks = new ArrayList<>();
7273

74+
// 태그와의 관계
7375
@OneToMany(mappedBy = "postId", cascade = CascadeType.ALL, orphanRemoval = true)
7476
private List<PostTag> postTags = new ArrayList<>();
7577

78+
// 좋아요와의 관계
79+
@OneToMany(mappedBy = "postId", cascade = CascadeType.ALL, orphanRemoval = true)
80+
private List<PostLike> postLikes = new ArrayList<>();
81+
7682
public Post(Member userId, String postTitle, String coverImage, String problem, String errorMessage,
7783
String environment, String reproduceCode, String solutionCode, String causeAnalysis,
7884
String referenceLink, String extraContent, LocalDateTime createdAt, LocalDateTime editedAt){
@@ -89,7 +95,6 @@ public Post(Member userId, String postTitle, String coverImage, String problem,
8995
this.extraContent = extraContent;
9096
this.createdAt = createdAt;
9197
this.editedAt = editedAt;
92-
// 게시글 이미지
9398
// 게시글 태그
9499
}
95100
}
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
package com.example.FixLog.repository.post;
22

33
import com.example.FixLog.domain.post.Post;
4+
import org.springframework.data.domain.Page;
5+
import org.springframework.data.domain.Pageable;
46
import org.springframework.data.jpa.repository.JpaRepository;
57

6-
public interface PostRepository extends JpaRepository<Post, Long> {
8+
import java.util.List;
79

10+
public interface PostRepository extends JpaRepository<Post, Long> {
11+
List<Post> findTop12ByOrderByCreatedAtDesc();
12+
List<Post> findTop12ByOrderByPostLikesDesc();
13+
Page<Post> findAllByOrderByCreatedAtDesc(Pageable pageable);
14+
Page<Post> findAllByOrderByPostLikesDesc(Pageable pageable);
815
}

0 commit comments

Comments
 (0)