-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 포트폴리오 조회 기능 수정 * feat: 포트폴리오 조회 기능 수정 [core-domain] * feat: toDto -> from으로 수정
- Loading branch information
Showing
8 changed files
with
131 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
api/src/main/java/com/sponus/sponusbe/domain/portfolio/dto/PortfolioGetResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
package com.sponus.sponusbe.domain.portfolio.dto; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
import com.sponus.coredomain.domain.portfolio.Portfolio; | ||
|
||
public record PortfolioGetResponse( | ||
Long portfolioId, | ||
Long clubId, | ||
LocalDate startDate, | ||
LocalDate endDate, | ||
String description, | ||
List<PortfolioImageGetResponse> portfolioImageGetResponses | ||
) { | ||
public static PortfolioGetResponse from(Portfolio portfolio, | ||
List<PortfolioImageGetResponse> portfolioImageGetResponses) { | ||
return new PortfolioGetResponse( | ||
portfolio.getId(), | ||
portfolio.getClub().getId(), | ||
portfolio.getStartDate(), | ||
portfolio.getEndDate(), | ||
portfolio.getDescription(), | ||
portfolioImageGetResponses | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
core/core-domain/src/main/java/com/sponus/coredomain/config/QuerydslConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.sponus.coredomain.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.PersistenceContext; | ||
|
||
@Configuration | ||
public class QuerydslConfig { | ||
@PersistenceContext | ||
private EntityManager entityManager; | ||
|
||
@Bean | ||
public JPAQueryFactory jpaQueryFactory() { | ||
return new JPAQueryFactory(entityManager); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...ain/java/com/sponus/coredomain/domain/portfolio/repository/PortfolioCustomRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.sponus.coredomain.domain.portfolio.repository; | ||
|
||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
import com.sponus.coredomain.domain.portfolio.Portfolio; | ||
import com.sponus.coredomain.domain.portfolio.repository.conditions.PortfolioSearchParam; | ||
|
||
public interface PortfolioCustomRepository { | ||
Page<Portfolio> findAllByConditions(PortfolioSearchParam portfolioSearchParam, Pageable pageable); | ||
} |
52 changes: 52 additions & 0 deletions
52
.../main/java/com/sponus/coredomain/domain/portfolio/repository/PortfolioRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.sponus.coredomain.domain.portfolio.repository; | ||
|
||
import static com.sponus.coredomain.domain.portfolio.QPortfolio.*; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.support.PageableExecutionUtils; | ||
|
||
import com.querydsl.core.types.dsl.BooleanExpression; | ||
import com.querydsl.jpa.impl.JPAQuery; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import com.sponus.coredomain.domain.portfolio.Portfolio; | ||
import com.sponus.coredomain.domain.portfolio.repository.conditions.PortfolioSearchParam; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public class PortfolioRepositoryImpl implements PortfolioCustomRepository { | ||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public Page<Portfolio> findAllByConditions(PortfolioSearchParam portfolioSearchParam, | ||
Pageable pageable) { | ||
JPAQuery<Long> countQuery = queryFactory | ||
.select(portfolio.count()) | ||
.from(portfolio); | ||
|
||
List<Portfolio> portfolios = queryFactory | ||
.select(portfolio) | ||
.from(portfolio) | ||
.where( | ||
isClubId(portfolioSearchParam.clubId()), | ||
isPortfolioId(portfolioSearchParam.portfolioId()) | ||
) | ||
.orderBy(portfolio.id.asc()) | ||
.offset(pageable.getOffset()) | ||
.limit(pageable.getPageSize()) | ||
.fetch(); | ||
|
||
return PageableExecutionUtils.getPage(portfolios, pageable, countQuery::fetchOne); | ||
} | ||
|
||
private BooleanExpression isClubId(Long clubId) { | ||
return clubId != null ? portfolio.club.id.eq(clubId) : null; | ||
} | ||
|
||
private BooleanExpression isPortfolioId(Long portfolioId) { | ||
return portfolioId != null ? portfolio.club.id.eq(portfolioId) : null; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...va/com/sponus/coredomain/domain/portfolio/repository/conditions/PortfolioSearchParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.sponus.coredomain.domain.portfolio.repository.conditions; | ||
|
||
public record PortfolioSearchParam( | ||
Long portfolioId, | ||
Long clubId | ||
) { | ||
} |