Skip to content

Commit

Permalink
refactor: User - Artist/Model 관계 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
daeun084 committed Oct 1, 2024
1 parent 79031f5 commit 414804a
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public static ArtistResponse.ArtistDto toArtistDto(Artist artist, boolean isFavo
return ArtistResponse.ArtistDto.builder()
.artistId(artist.getUserId())
.isFavorite(isFavorite)
.gender(artist.getGender())
.nickname(artist.getNickname())
.profileImg(artist.getProfileImg())
.email(artist.getEmail())
.gender(artist.getUser().getGender())
.nickname(artist.getUser().getNickname())
.profileImg(artist.getUser().getProfileImg())
.email(artist.getUser().getEmail())
.phoneNumber(artist.getPhoneNumber())
.instagramId(artist.getInstagramId())
.introduction(artist.getIntroduction())
Expand All @@ -35,9 +35,9 @@ public static ArtistResponse.ArtistDto toArtistDto(Artist artist, boolean isFavo
public static ArtistResponse.ArtistSimpleDto toArtistSimpleDto(Artist artist, Long modelCount) {
return ArtistResponse.ArtistSimpleDto.builder()
.artistId(artist.getUserId())
.profileImg(artist.getProfileImg())
.artistNickName(artist.getNickname())
.email(artist.getEmail())
.profileImg(artist.getUser().getProfileImg())
.artistNickName(artist.getUser().getNickname())
.email(artist.getUser().getEmail())
.region(artist.getRegion().get(0).getValue())
.modelCount(modelCount)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static FavoriteArtist toFavoriteArtist(Artist artist, Model model){
// favoritePortfolio
public static FavoritePortfolio toFavoritePortfolio(Model model, Portfolio portfolio){
return FavoritePortfolio.builder()
.model(model)
.model(model.getUser())
.portfolio(portfolio)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class MypageConverter {
public static MypageResponse.ModelProfileDto toModelProfileDto(Model model){
return MypageResponse.ModelProfileDto.builder()
.userId(model.getUserId())
.profileImg(model.getProfileImg())
.nickname(model.getNickname())
.gender(model.getGender())
.profileImg(model.getUser().getProfileImg())
.nickname(model.getUser().getNickname())
.gender(model.getUser().getGender())
.skinType(model.getSkinType())
.personalColor(model.getPersonalColor())
.build();
Expand All @@ -22,9 +22,9 @@ public static MypageResponse.ModelProfileDto toModelProfileDto(Model model){
public static MypageResponse.ArtistProfileDto toArtistProfileDto(Artist artist){
return MypageResponse.ArtistProfileDto.builder()
.userId(artist.getUserId())
.profileImg(artist.getProfileImg())
.nickname(artist.getNickname())
.gender(artist.getGender())
.profileImg(artist.getUser().getProfileImg())
.nickname(artist.getUser().getNickname())
.gender(artist.getUser().getGender())
.introduction(artist.getIntroduction())
.phoneNumber(artist.getPhoneNumber())
.instagramId(artist.getInstagramId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static PortfolioResponse.PortfolioDto toPortfolioDto(Portfolio portfolio)
.portfolioId(portfolio.getPortfolioId())
.userId(portfolio.getArtist().getUserId())
.category(portfolio.getCategory())
.artistNickName(artist.getNickname())
.artistNickName(artist.getUser().getNickname())
.makeupName(portfolio.getMakeupName())
.price(portfolio.getPrice())
.makeupLocation(artist.getMakeupLocation())
Expand All @@ -66,8 +66,8 @@ public static PortfolioResponse.PortfolioDetailDto toPortfolioDetailDto(Portfoli
.userId(portfolio.getArtist().getUserId())
.isFavorite(isFavorite)
.category(portfolio.getCategory())
.artistProfileImg(artist.getProfileImg())
.artistNickName(artist.getNickname())
.artistProfileImg(artist.getUser().getProfileImg())
.artistNickName(artist.getUser().getNickname())
.makeupName(portfolio.getMakeupName())
.price(portfolio.getPrice())
.info(portfolio.getInfo())
Expand Down Expand Up @@ -118,8 +118,8 @@ public static PortfolioResponse.PortfolioSimpleDto toPortfolioSimpleDto(Portfoli
.portfolioImg(portfolio.getPortfolioImgList().get(0).getSrc())
.category(portfolio.getCategory())
.makeupName(portfolio.getMakeupName())
.artistName(artist.getNickname())
.artistEmail(artist.getEmail())
.artistName(artist.getUser().getNickname())
.artistEmail(artist.getUser().getEmail())
.price(portfolio.getPrice())
.makeupLocation(artist.getMakeupLocation())
.averageStars(portfolio.getAverageStars())
Expand All @@ -135,8 +135,8 @@ public static PortfolioResponse.PortfolioSimpleDto toPortfolioSimpleDto(Favorite
.portfolioImg(portfolio.getPortfolioImgList().get(0).getSrc())
.category(portfolio.getCategory())
.makeupName(portfolio.getMakeupName())
.artistName(artist.getNickname())
.artistEmail(artist.getEmail())
.artistName(artist.getUser().getNickname())
.artistEmail(artist.getUser().getEmail())
.price(portfolio.getPrice())
.makeupLocation(artist.getMakeupLocation())
.averageStars(portfolio.getAverageStars())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.meme.service.domain.entity.Portfolio;
import org.meme.service.domain.enums.Category;
import org.meme.service.domain.enums.MakeupLocation;
import org.meme.service.domain.enums.Region;
import org.meme.service.domain.enums.WorkExperience;
import org.meme.service.domain.enums.*;

import java.util.List;

@SuperBuilder

@AllArgsConstructor
@NoArgsConstructor
@Getter @Setter
@Entity
public class Artist extends User{
public class Artist {

@Id
private Long userId;

@OneToOne
@MapsId
@JoinColumn(name = "user_id")
private User user;

@Column(length = 500, nullable = true)
private String introduction;
Expand Down Expand Up @@ -57,4 +62,16 @@ public class Artist extends User{
public void updatePortfolioList(Portfolio portfolio){
this.portfolioList.add(portfolio);
}

public void updateProfileImg(String profileimg){
this.user.updateProfileImg(profileimg);
}

public void updateNickname(String nickname){
this.user.updateNickname(nickname);
}

public void updateGender(Gender gender){
this.user.updateGender(gender);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.meme.service.domain.entity.Reservation;
import org.meme.service.domain.entity.*;
import org.meme.service.domain.enums.Gender;
import org.meme.service.domain.enums.PersonalColor;
import org.meme.service.domain.enums.SkinType;

import java.util.List;

@SuperBuilder
@Getter @Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class Model extends User {
public class Model {

@Id
private Long userId;

@OneToOne
@MapsId
@JoinColumn(name = "user_id")
private User user;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
Expand Down Expand Up @@ -47,12 +53,21 @@ public void updateFavoriteArtistList(FavoriteArtist artist){
public void updateFavoritePortfolioList(FavoritePortfolio portfolio){
this.favoritePortfolioList.add(portfolio);
}
public void updateReservationList(Reservation reservation){
this.reservationList.add(reservation);
}

public void updateReviewList(Review review){
this.reviewList.add(review);
}

public void updateProfileImg(String profileimg){
this.user.updateProfileImg(profileimg);
}

public void updateNickname(String nickname){
this.user.updateNickname(nickname);
}

public void updateGender(Gender gender){
this.user.updateGender(gender);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import lombok.*;
import org.meme.service.domain.entity.Inquiry;
import org.meme.service.domain.enums.Gender;
import org.meme.service.domain.enums.Provider;
Expand All @@ -18,10 +14,10 @@
import java.util.List;
import java.util.Set;

@SuperBuilder @Getter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Inheritance(strategy = InheritanceType.JOINED)
//@Inheritance(strategy = InheritanceType.JOINED)
@Entity
public class User {

Expand Down Expand Up @@ -68,7 +64,7 @@ public class User {
private Provider provider;

@ElementCollection
@Builder.Default
// @Builder.Default
private Set<String> deviceTokens = new HashSet<>();

@OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
Expand Down

0 comments on commit 414804a

Please sign in to comment.