Skip to content

Commit

Permalink
Merge pull request #90 from Snap-Spot/!HOTFIX
Browse files Browse the repository at this point in the history
✨ feat: 10차 배포
  • Loading branch information
xyzwv authored Sep 25, 2023
2 parents f41ac98 + 6504241 commit 911a869
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package snap.api.photographer.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -61,8 +59,8 @@ public ResponseEntity<List<PhotographerSimpleDto>> photographerFindByTag(@Reques
}

@GetMapping
public ResponseEntity<List<PhotographerSimpleDto>> photographerList(PhotographerFilterReq filterReq, @PageableDefault(size = 15) Pageable pageable){
return new ResponseEntity<>(photographerService.findByFilter(filterReq, pageable), HttpStatus.OK);
public ResponseEntity<List<PhotographerSimpleDto>> photographerList(PhotographerFilterReq filterReq){
return new ResponseEntity<>(photographerService.findByFilter(filterReq), HttpStatus.OK);
}

@GetMapping("/name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import snap.api.photographer.dto.request.PhotographerCustomDto;
import snap.api.photographer.dto.response.PhotographerNameResponseDto;
Expand Down Expand Up @@ -76,16 +75,10 @@ public List<PhotographerNameResponseDto> findAllNames(){
.map(PhotographerNameResponseDto::new).collect(Collectors.toList());
}

public List<PhotographerResponseDto> findAllPhotographers(Pageable pageable){
return photographerDomainService.findAllToPage(pageable)
.map(photographer -> new PhotographerResponseDto(photographer, findReview(photographer)))
.getContent();
}

public List<PhotographerSimpleDto> findByFilter(PhotographerFilterReq filterReq, Pageable pageable){
return photographerDomainService.findAllByFilter(filterReq, pageable)
public List<PhotographerSimpleDto> findByFilter(PhotographerFilterReq filterReq){
return photographerDomainService.findAllByFilter(filterReq).stream()
.map(photographer -> new PhotographerSimpleDto(photographer, findReview(photographer)))
.getContent();
.toList();
}

public PhotographerResponseDto updatePhotographerInfo(Photographer photographer, PhotographerCustomDto dto){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package snap.domains.photographer.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import snap.domains.photographer.entity.Photographer;
import snap.dto.request.PhotographerFilterReq;

import java.util.List;

public interface PhotographerRepositoryCustom {

Page<Photographer> searchAll(PhotographerFilterReq photographerFilterReq, Pageable pageable);
List<Photographer> searchAll(PhotographerFilterReq photographerFilterReq);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import snap.domains.member.entity.Member;
Expand Down Expand Up @@ -63,13 +62,8 @@ public List<Photographer> findAllToList(){
}

@Transactional(readOnly = true)
public Page<Photographer> findAllToPage(Pageable pageable){
return photographerRepository.findAll(pageable);
}

@Transactional(readOnly = true)
public Page<Photographer> findAllByFilter(PhotographerFilterReq filterReq, Pageable pageable){
return photographerRepository.searchAll(filterReq, pageable);
public List<Photographer> findAllByFilter(PhotographerFilterReq filterReq){
return photographerRepository.searchAll(filterReq);
}

public void updatePhotographer(Photographer photographer, String nickname, String profileImage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;
import snap.domains.photographer.entity.Photographer;
import snap.domains.photographer.repository.PhotographerRepositoryCustom;
Expand All @@ -30,7 +27,7 @@ public class PhotographerRepositoryImpl implements PhotographerRepositoryCustom
private final JPAQueryFactory queryFactory;

@Override
public Page<Photographer> searchAll(PhotographerFilterReq photographerFilterReq, Pageable pageable) {
public List<Photographer> searchAll(PhotographerFilterReq photographerFilterReq) {
List<Photographer> result = new ArrayList<>();
Sort sort = photographerFilterReq.getSort();

Expand All @@ -41,22 +38,21 @@ public Page<Photographer> searchAll(PhotographerFilterReq photographerFilterReq,

if(sort != null) {
if(sort.equals(Sort.PAY)){
result = searchQuery(photographerFilterReq, pageable).orderBy(paySpecifier).fetch();
result = searchQuery(photographerFilterReq).orderBy(paySpecifier, photographerSpecifier).fetch();
} else if(sort.equals(Sort.REVIEW)){
result = searchQuery(photographerFilterReq, pageable).orderBy(review.count().desc()).fetch();
result = searchQuery(photographerFilterReq).orderBy(reviewCountSpecifier, photographerSpecifier).fetch();
} else if (sort.equals(Sort.SCORE)) {
result = searchQuery(photographerFilterReq, pageable).orderBy(reviewScoreSpecifier, photographerSpecifier).fetch();
result = searchQuery(photographerFilterReq).orderBy(reviewScoreSpecifier, photographerSpecifier).fetch();
}
}
else {
result = searchQuery(photographerFilterReq, pageable).orderBy(photographerSpecifier).fetch();
result = searchQuery(photographerFilterReq).orderBy(photographerSpecifier).fetch();
}
return new PageImpl<>(result);
return result;
}

private JPAQuery<Photographer> searchQuery (
PhotographerFilterReq photographerFilterReq,
Pageable pageable
PhotographerFilterReq photographerFilterReq
) {
return queryFactory
.selectFrom(photographer)
Expand All @@ -67,8 +63,6 @@ private JPAQuery<Photographer> searchQuery (
specialKeywordCondition(photographerFilterReq.getSpecial()),
ableDateCondition(photographerFilterReq.getAbleDate())
)
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.groupBy(photographer);
}

Expand Down

0 comments on commit 911a869

Please sign in to comment.