Skip to content

Commit

Permalink
Merge pull request #90 from MEME-UMC/add/#89
Browse files Browse the repository at this point in the history
[Add] 관심 포트폴리오/아티스트 dto
  • Loading branch information
yeopyeop-82 authored Feb 3, 2024
2 parents a87904e + ad40ed3 commit 2a05d54
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
import org.springframework.data.domain.Page;
import umc.meme.shop.domain.artist.dto.response.ArtistDto;
import umc.meme.shop.domain.artist.dto.response.ArtistPageDto;
import umc.meme.shop.domain.favorite.dto.response.FavoriteArtistPageResponseDto;
import umc.meme.shop.domain.favorite.dto.response.FavoriteArtistResponseDto;
import umc.meme.shop.domain.favorite.entity.FavoriteArtist;

import java.util.List;

public class ArtistConverter {
public static ArtistPageDto favoriteArtistPageConverter(Page<FavoriteArtist> page) {
public static FavoriteArtistPageResponseDto favoriteArtistPageConverter(Page<FavoriteArtist> page) {

List<ArtistDto> content = page.stream()
.map(ArtistDto::from)
List<FavoriteArtistResponseDto> content = page.stream()
.map(FavoriteArtistResponseDto::from)
.toList();

return ArtistPageDto.builder()
return FavoriteArtistPageResponseDto.builder()
.content(content)
.pageSize(page.getSize())
.currentPage(page.getNumber())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package umc.meme.shop.domain.favorite.dto.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import umc.meme.shop.domain.favorite.entity.FavoriteArtist;

import java.util.List;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FavoriteArtistPageResponseDto {
private List<FavoriteArtistResponseDto> content;
private int currentPage; //현재 페이지 번호
private int pageSize; //페이지 크기
private int totalNumber; //전체 메이크업 개수
private int totalPage; //전체 페이지 개수
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package umc.meme.shop.domain.favorite.dto.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import umc.meme.shop.domain.artist.entity.Artist;
import umc.meme.shop.domain.favorite.entity.FavoriteArtist;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FavoriteArtistResponseDto {
private Long artistId;
private String profileImg;
private String artistNickName;

public static FavoriteArtistResponseDto from(FavoriteArtist favoriteArtist) {

Artist artist = favoriteArtist.getArtist();

return FavoriteArtistResponseDto.builder()
.artistId(artist.getArtistId())
.profileImg(artist.getProfileImg())
.artistNickName(artist.getNickname())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package umc.meme.shop.domain.favorite.dto.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import umc.meme.shop.domain.artist.entity.Artist;
import umc.meme.shop.domain.favorite.entity.FavoritePortfolio;
import umc.meme.shop.domain.portfolio.dto.response.PortfolioDto;
import umc.meme.shop.domain.portfolio.entity.Portfolio;
import umc.meme.shop.domain.portfolio.entity.PortfolioImg;
import umc.meme.shop.domain.portfolio.entity.enums.Category;

import java.util.List;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FavoritePortfolioResponseDto {
private Long portfolioId;
private String portfolioImg;
private Category category;
private String makeupName;
private int price;

public static FavoritePortfolioResponseDto from(FavoritePortfolio favoritePortfolio) {

Portfolio portfolio = favoritePortfolio.getPortfolio();

return FavoritePortfolioResponseDto.builder()
.portfolioId(portfolio.getPortfolioId())
.portfolioImg(portfolio.getPortfolioImgList().get(0).getSrc())
.category(portfolio.getCategory())
.makeupName(portfolio.getMakeupName())
.price(portfolio.getPrice())
.build();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package umc.meme.shop.domain.favorite.dto.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class FavoritePortfolioResponsePageDto {
private List<FavoritePortfolioResponseDto> content;
private int currentPage; //현재 페이지 번호
private int pageSize; //페이지 크기
private int totalNumber; //전체 메이크업 개수
private int totalPage; //전체 페이지 개수
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import umc.meme.shop.domain.artist.repository.ArtistRepository;
import umc.meme.shop.domain.favorite.dto.request.FavoriteArtistDto;
import umc.meme.shop.domain.favorite.dto.request.FavoritePortfolioDto;
import umc.meme.shop.domain.favorite.dto.response.FavoriteArtistPageResponseDto;
import umc.meme.shop.domain.favorite.dto.response.FavoritePortfolioResponsePageDto;
import umc.meme.shop.domain.favorite.entity.FavoriteArtist;
import umc.meme.shop.domain.favorite.entity.FavoritePortfolio;
import umc.meme.shop.domain.favorite.repository.FavoriteArtistRepository;
Expand Down Expand Up @@ -49,7 +51,7 @@ public void updateModelProfile(ModelProfileDto request){

//관심 아티스트 조회
@Transactional
public ArtistPageDto getFavoriteArtist(Long modelId, int page){
public FavoriteArtistPageResponseDto getFavoriteArtist(Long modelId, int page){
Model model = modelRepository.findById(modelId)
.orElseThrow(() -> new GlobalException(ErrorStatus.NOT_EXIST_MODEL));

Expand All @@ -67,7 +69,7 @@ public ArtistPageDto getFavoriteArtist(Long modelId, int page){

//관심 메이크업 조회
@Transactional
public PortfolioPageDto getFavoritePortfolio(Long modelId, int page){
public FavoritePortfolioResponsePageDto getFavoritePortfolio(Long modelId, int page){
Model model = modelRepository.findById(modelId)
.orElseThrow(() -> new GlobalException(ErrorStatus.NOT_EXIST_MODEL));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package umc.meme.shop.domain.portfolio.converter;

import org.springframework.data.domain.Page;
import umc.meme.shop.domain.favorite.dto.response.FavoriteArtistResponseDto;
import umc.meme.shop.domain.favorite.dto.response.FavoritePortfolioResponseDto;
import umc.meme.shop.domain.favorite.dto.response.FavoritePortfolioResponsePageDto;
import umc.meme.shop.domain.favorite.entity.FavoritePortfolio;
import umc.meme.shop.domain.portfolio.dto.response.PortfolioDto;
import umc.meme.shop.domain.portfolio.dto.response.PortfolioPageDto;
Expand All @@ -10,13 +13,13 @@

public class PortfolioConverter {

public static PortfolioPageDto favoritePortfolioPageConverter(Page<FavoritePortfolio> page){
public static FavoritePortfolioResponsePageDto favoritePortfolioPageConverter(Page<FavoritePortfolio> page){

List<PortfolioDto> content = page.stream()
.map(PortfolioDto::from)
List<FavoritePortfolioResponseDto> content = page.stream()
.map(FavoritePortfolioResponseDto::from)
.toList();

return PortfolioPageDto.builder()
return FavoritePortfolioResponsePageDto.builder()
.content(content)
.pageSize(page.getSize())
.currentPage(page.getNumber())
Expand Down

0 comments on commit 2a05d54

Please sign in to comment.