Skip to content

Commit

Permalink
[Refactor]: repository 파일 이동 및 querydsl 메서드 구현
Browse files Browse the repository at this point in the history
Related to: #559
  • Loading branch information
dev-Crayon committed Nov 27, 2024
1 parent e56b2aa commit 97b719a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.makers.internal.repository.community;
package org.sopt.makers.internal.community.repository.anonymous;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@
import org.sopt.makers.internal.community.domain.CommunityPost;
import org.springframework.data.jpa.repository.JpaRepository;

public interface AnonymousPostProfileRepository extends JpaRepository<AnonymousPostProfile, Long> {
public interface AnonymousPostProfileRepository extends JpaRepository<AnonymousPostProfile, Long>, AnonymousPostProfileRepositoryCustom {

// CREATE

// READ
Optional<AnonymousPostProfile> findAnonymousPostProfileByMemberIdAndCommunityPostId(Long memberId, Long communityPostId);

Optional<AnonymousPostProfile> findByMemberAndCommunityPost(Member member, CommunityPost post);

List<AnonymousPostProfile> findTop4ByOrderByCreatedAtDesc();

List<AnonymousPostProfile> findTop50ByOrderByCreatedAtDesc();

// UPDATE

//DELETE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sopt.makers.internal.community.repository.anonymous;

import org.sopt.makers.internal.domain.community.AnonymousPostProfile;

import java.util.List;

public interface AnonymousPostProfileRepositoryCustom {

List<AnonymousPostProfile> findTopByOrderByIdDescWithLimit(int limit);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.sopt.makers.internal.community.repository.anonymous;

import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import org.sopt.makers.internal.domain.community.AnonymousPostProfile;
import org.sopt.makers.internal.domain.community.QAnonymousPostProfile;

import java.util.List;

@RequiredArgsConstructor
public class AnonymousPostProfileRepositoryCustomImpl implements AnonymousPostProfileRepositoryCustom {

private final JPAQueryFactory queryFactory;

@Override
public List<AnonymousPostProfile> findTopByOrderByIdDescWithLimit(int limit) {

QAnonymousPostProfile anonymousPostProfile = QAnonymousPostProfile.anonymousPostProfile;

return queryFactory
.selectFrom(anonymousPostProfile)
.orderBy(anonymousPostProfile.createdAt.desc())
.limit(limit)
.fetch();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.sopt.makers.internal.community.domain.CommunityPost;
import org.sopt.makers.internal.community.domain.QCommunityPost;
import org.sopt.makers.internal.community.domain.category.QCategory;
import org.sopt.makers.internal.domain.*;
import org.sopt.makers.internal.domain.community.*;
Expand Down

0 comments on commit 97b719a

Please sign in to comment.