## 코드 중복을 줄이기 위해서 isMain같은 boolean값을 파라미터로 보내는 게 나은가?
- 두 개의 메서드 차이점은 조건절에 ` jpaStyleKeyword.isMainDisplay.isTrue()
` 하나이다.
```java
package fnf.wp.online_store_backend.module.web.stylepick.adapter.out;
import static com.querydsl.core.types.Projections.constructor;
import static fnf.wp.online_store_backend.sub.category.infrastructure.entity.QJpaSimpleGoods.jpaSimpleGoods;
import static fnf.wp.online_store_backend.sub.display.infrastructure.entity.QJpaContentGoods.jpaContentGoods;
import static fnf.wp.online_store_backend.sub.stylepick.entity.QJpaStyleContent.jpaStyleContent;
import static fnf.wp.online_store_backend.sub.stylepick.entity.QJpaStyleKeyword.jpaStyleKeyword;
import static fnf.wp.online_store_backend.sub.stylepick.entity.QJpaStyleKeywordContentAssociation.jpaStyleKeywordContentAssociation;
import static fnf.wp.online_store_backend.sub.stylepick.entity.QJpaStylePick.jpaStylePick;
import com.querydsl.jpa.impl.JPAQueryFactory;
import fnf.wp.online_store_backend.module.core.common.core.time.DateTimeProvider;
import fnf.wp.online_store_backend.module.web.brand.stylepick.enums.SocialContentType;
import fnf.wp.online_store_backend.module.web.stylepick.port.out.StylePickTitleAndKeywordDsGateway;
import java.util.List;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class StylePickTitleAndKeywordDataMapper implements StylePickTitleAndKeywordDsGateway {
private final JPAQueryFactory subJpaQueryFactory;
private final DateTimeProvider dateTimeProvider;
@Override
public List<StylePickTitleAndKeyword> findAllByCategory(@NonNull String category) {
val now = dateTimeProvider.now();
return subJpaQueryFactory.select(
constructor(StylePickTitleAndKeyword.class,
jpaStyleKeyword.id,
jpaStyleKeyword.name,
jpaStyleKeyword.sequence,
jpaStylePick.name
)
)
.from(jpaStyleKeywordContentAssociation)
.join(jpaStyleKeywordContentAssociation.styleKeyword, jpaStyleKeyword)
.join(jpaStyleKeyword.stylePick, jpaStylePick)
.join(jpaStyleKeywordContentAssociation.styleContent, jpaStyleContent)
.join(jpaContentGoods).on(jpaContentGoods.styleContent.eq(jpaStyleContent))
.join(jpaContentGoods.simpleGoods, jpaSimpleGoods)
.where(
jpaStyleKeyword.isDisplay.isTrue(),
jpaStylePick.socialContentType.eq(SocialContentType.INSTAGRAM),
jpaStyleContent.isDisplay.isTrue(),
jpaStyleContent.displayStartDate.loe(now),
jpaStyleContent.displayEndDate.goe(now),
jpaSimpleGoods.representativeCategoryId.startsWith(category)
)
.distinct()
.orderBy(jpaStyleKeyword.sequence.asc())
.limit(10)
.fetch();
}
@Override
public List<StylePickTitleAndKeyword> findAllByCategoryForMain(@NonNull String category) {
val now = dateTimeProvider.now();
return subJpaQueryFactory.select(
constructor(StylePickTitleAndKeyword.class,
jpaStyleKeyword.id,
jpaStyleKeyword.name,
jpaStyleKeyword.sequence,
jpaStylePick.name
)
)
.from(jpaStyleKeywordContentAssociation)
.join(jpaStyleKeywordContentAssociation.styleKeyword, jpaStyleKeyword)
.join(jpaStyleKeyword.stylePick, jpaStylePick)
.join(jpaStyleKeywordContentAssociation.styleContent, jpaStyleContent)
.join(jpaContentGoods).on(jpaContentGoods.styleContent.eq(jpaStyleContent))
.join(jpaContentGoods.simpleGoods, jpaSimpleGoods)
.where(
jpaStyleKeyword.isDisplay.isTrue(),
jpaStyleKeyword.isMainDisplay.isTrue(),
jpaStylePick.socialContentType.eq(SocialContentType.INSTAGRAM),
jpaStyleContent.isDisplay.isTrue(),
jpaStyleContent.displayStartDate.loe(now),
jpaStyleContent.displayEndDate.goe(now),
jpaSimpleGoods.representativeCategoryId.startsWith(category)
)
.distinct()
.orderBy(jpaStyleKeyword.sequence.asc())
.limit(10)
.fetch();
}
}
```