Skip to content

Commit

Permalink
Merge pull request #71 from MEME-UMC/chore/#70
Browse files Browse the repository at this point in the history
[Chore] isBlock인 포트폴리오 숨김 처리
  • Loading branch information
yeopyeop-82 authored Jan 29, 2024
2 parents a0050b0 + 4f77f50 commit d027111
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public class UpdatePortfolioDto {
private String makeupName;
private int price;
private String info;
private boolean isBlock;
private Boolean isBlock;
private PortfolioImgDto portfolioImg;
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void updatePortfolio(UpdatePortfolioDto request) {
this.makeupName = request.getMakeupName();
}

this.isBlock = request.isBlock();
this.isBlock = request.getIsBlock();
}

public void updateReviewList(Review review){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.springframework.stereotype.Service;
import umc.meme.shop.domain.artist.entity.Artist;
import umc.meme.shop.domain.artist.repository.ArtistRepository;
import umc.meme.shop.domain.favorite.entity.FavoritePortfolio;
import umc.meme.shop.domain.portfolio.converter.PortfolioConverter;
import umc.meme.shop.domain.portfolio.dto.request.CreatePortfolioDto;
import umc.meme.shop.domain.portfolio.dto.request.UpdatePortfolioDto;
Expand All @@ -24,8 +23,8 @@
import umc.meme.shop.global.exception.GlobalException;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -78,8 +77,18 @@ public PortfolioPageDto getPortfolio(Long artistId, int page) {
Artist artist = artistRepository.findById(artistId)
.orElseThrow(() -> new GlobalException(ErrorStatus.NOT_EXIST_ARTIST));

//page
List<Portfolio> portfolioList = artist.getPortfolioList();

//isblock이면 리스트에서 제거
Iterator<Portfolio> iterator = portfolioList.iterator();
while (iterator.hasNext()) {
Portfolio portfolio = iterator.next();
if (portfolio.isBlock()) {
iterator.remove();
}
}

//page로 mapping
Pageable pageable = PageRequest.of(page, 30);
int start = (int) pageable.getOffset();
int end = Math.min((start + pageable.getPageSize()), portfolioList.size());
Expand All @@ -96,6 +105,9 @@ public PortfolioDto getPortfolioDetails(Long portfolioId) {
Portfolio portfolio = portfolioRepository.findById(portfolioId)
.orElseThrow(() -> new GlobalException(ErrorStatus.NOT_EXIST_PORTFOLIO));

if(portfolio.isBlock())
throw new GlobalException(ErrorStatus.BLOCKED_PORTFOLIO);

return PortfolioDto.from(portfolio);
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/umc/meme/shop/global/ErrorStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public enum ErrorStatus {
//portfolio
ALREADY_EXIST_PORTFOLIO(400, "해당 포트폴리오 제목이 이미 존재합니다"),
INVALID_SORT_CRITERIA(400, "잘못된 정렬 기준입니다"),
BLOCKED_PORTFOLIO(400, "숨김 처리된 포트폴리오입니다"),

//review
ALREADY_REVIEWED(400, "이미 리뷰 작성이 완료된 예약입니다."),
Expand Down

0 comments on commit d027111

Please sign in to comment.