From 414804a1c023c6b8341761014907f085da70e783 Mon Sep 17 00:00:00 2001 From: daeun084 <030804jk@naver.com> Date: Tue, 1 Oct 2024 17:02:44 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20User=20-=20Artist/Model=20=EA=B4=80?= =?UTF-8?q?=EA=B3=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/converter/ArtistConverter.java | 14 ++++----- .../domain/converter/FavoriteConverter.java | 2 +- .../domain/converter/MypageConverter.java | 12 ++++---- .../domain/converter/PortfolioConverter.java | 14 ++++----- .../meme/service/domain/entity/Artist.java | 29 +++++++++++++++---- .../org/meme/service/domain/entity/Model.java | 29 ++++++++++++++----- .../org/meme/service/domain/entity/User.java | 12 +++----- 7 files changed, 70 insertions(+), 42 deletions(-) diff --git a/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/ArtistConverter.java b/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/ArtistConverter.java index 57f599d..9539d1c 100644 --- a/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/ArtistConverter.java +++ b/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/ArtistConverter.java @@ -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()) @@ -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(); diff --git a/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/FavoriteConverter.java b/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/FavoriteConverter.java index 79be7a9..527e149 100644 --- a/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/FavoriteConverter.java +++ b/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/FavoriteConverter.java @@ -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(); } diff --git a/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/MypageConverter.java b/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/MypageConverter.java index d53d197..434b8d9 100644 --- a/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/MypageConverter.java +++ b/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/MypageConverter.java @@ -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(); @@ -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()) diff --git a/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/PortfolioConverter.java b/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/PortfolioConverter.java index 1b40f97..f6afa2d 100644 --- a/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/PortfolioConverter.java +++ b/MEME-SERVICE/src/main/java/org/meme/service/domain/converter/PortfolioConverter.java @@ -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()) @@ -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()) @@ -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()) @@ -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()) diff --git a/MEME-SERVICE/src/main/java/org/meme/service/domain/entity/Artist.java b/MEME-SERVICE/src/main/java/org/meme/service/domain/entity/Artist.java index 29f9c35..f5bc05f 100644 --- a/MEME-SERVICE/src/main/java/org/meme/service/domain/entity/Artist.java +++ b/MEME-SERVICE/src/main/java/org/meme/service/domain/entity/Artist.java @@ -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; @@ -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); + } } \ No newline at end of file diff --git a/MEME-SERVICE/src/main/java/org/meme/service/domain/entity/Model.java b/MEME-SERVICE/src/main/java/org/meme/service/domain/entity/Model.java index 09366c8..a115bfa 100644 --- a/MEME-SERVICE/src/main/java/org/meme/service/domain/entity/Model.java +++ b/MEME-SERVICE/src/main/java/org/meme/service/domain/entity/Model.java @@ -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) @@ -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); + } + } diff --git a/MEME-SERVICE/src/main/java/org/meme/service/domain/entity/User.java b/MEME-SERVICE/src/main/java/org/meme/service/domain/entity/User.java index 3fed211..c039e82 100644 --- a/MEME-SERVICE/src/main/java/org/meme/service/domain/entity/User.java +++ b/MEME-SERVICE/src/main/java/org/meme/service/domain/entity/User.java @@ -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; @@ -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 { @@ -68,7 +64,7 @@ public class User { private Provider provider; @ElementCollection - @Builder.Default +// @Builder.Default private Set deviceTokens = new HashSet<>(); @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")