diff --git a/src/main/java/org/sopt/makers/internal/domain/community/AnonymousNickname.java b/src/main/java/org/sopt/makers/internal/community/domain/anonymous/AnonymousNickname.java similarity index 66% rename from src/main/java/org/sopt/makers/internal/domain/community/AnonymousNickname.java rename to src/main/java/org/sopt/makers/internal/community/domain/anonymous/AnonymousNickname.java index b47e9742..54191b9f 100644 --- a/src/main/java/org/sopt/makers/internal/domain/community/AnonymousNickname.java +++ b/src/main/java/org/sopt/makers/internal/community/domain/anonymous/AnonymousNickname.java @@ -1,4 +1,4 @@ -package org.sopt.makers.internal.domain.community; +package org.sopt.makers.internal.community.domain.anonymous; import javax.persistence.Column; import javax.persistence.Entity; @@ -6,18 +6,17 @@ import javax.persistence.GenerationType; import javax.persistence.Id; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; +import lombok.*; @Entity @Getter +@Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PROTECTED) public class AnonymousNickname { - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "anonymous_nickname_id") private Long id; diff --git a/src/main/java/org/sopt/makers/internal/domain/community/AnonymousPostProfile.java b/src/main/java/org/sopt/makers/internal/community/domain/anonymous/AnonymousPostProfile.java similarity index 93% rename from src/main/java/org/sopt/makers/internal/domain/community/AnonymousPostProfile.java rename to src/main/java/org/sopt/makers/internal/community/domain/anonymous/AnonymousPostProfile.java index 91e46185..d6f56542 100644 --- a/src/main/java/org/sopt/makers/internal/domain/community/AnonymousPostProfile.java +++ b/src/main/java/org/sopt/makers/internal/community/domain/anonymous/AnonymousPostProfile.java @@ -1,4 +1,4 @@ -package org.sopt.makers.internal.domain.community; +package org.sopt.makers.internal.community.domain.anonymous; import javax.persistence.Column; import javax.persistence.ConstraintMode; @@ -11,7 +11,6 @@ import javax.persistence.ManyToOne; import javax.persistence.OneToOne; -import org.sopt.makers.internal.community.domain.AnonymousProfileImage; import org.sopt.makers.internal.community.domain.CommunityPost; import org.sopt.makers.internal.domain.Member; import org.sopt.makers.internal.domain.common.AuditingTimeEntity; diff --git a/src/main/java/org/sopt/makers/internal/community/domain/AnonymousProfileImage.java b/src/main/java/org/sopt/makers/internal/community/domain/anonymous/AnonymousProfileImage.java similarity index 54% rename from src/main/java/org/sopt/makers/internal/community/domain/AnonymousProfileImage.java rename to src/main/java/org/sopt/makers/internal/community/domain/anonymous/AnonymousProfileImage.java index 802f0da0..958880d0 100644 --- a/src/main/java/org/sopt/makers/internal/community/domain/AnonymousProfileImage.java +++ b/src/main/java/org/sopt/makers/internal/community/domain/anonymous/AnonymousProfileImage.java @@ -1,11 +1,14 @@ -package org.sopt.makers.internal.community.domain; +package org.sopt.makers.internal.community.domain.anonymous; -import lombok.Getter; +import lombok.*; import javax.persistence.*; @Entity @Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) public class AnonymousProfileImage { @Id diff --git a/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousNicknameRepository.java b/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousNicknameRepository.java index e8a7470d..81813731 100644 --- a/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousNicknameRepository.java +++ b/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousNicknameRepository.java @@ -2,7 +2,7 @@ import java.util.List; -import org.sopt.makers.internal.domain.community.AnonymousNickname; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousNickname; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; diff --git a/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousPostProfileRepository.java b/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousPostProfileRepository.java index a634b205..f9d589df 100644 --- a/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousPostProfileRepository.java +++ b/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousPostProfileRepository.java @@ -1,10 +1,9 @@ package org.sopt.makers.internal.community.repository.anonymous; -import java.util.List; import java.util.Optional; import org.sopt.makers.internal.domain.Member; -import org.sopt.makers.internal.domain.community.AnonymousPostProfile; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousPostProfile; import org.sopt.makers.internal.community.domain.CommunityPost; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousPostProfileRepositoryCustom.java b/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousPostProfileRepositoryCustom.java index a5e23b84..60c909a2 100644 --- a/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousPostProfileRepositoryCustom.java +++ b/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousPostProfileRepositoryCustom.java @@ -1,6 +1,6 @@ package org.sopt.makers.internal.community.repository.anonymous; -import org.sopt.makers.internal.domain.community.AnonymousPostProfile; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousPostProfile; import java.util.List; diff --git a/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousPostProfileRepositoryCustomImpl.java b/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousPostProfileRepositoryCustomImpl.java index 3fbfcc65..11702375 100644 --- a/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousPostProfileRepositoryCustomImpl.java +++ b/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousPostProfileRepositoryCustomImpl.java @@ -2,7 +2,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; -import org.sopt.makers.internal.domain.community.AnonymousPostProfile; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousPostProfile; import org.sopt.makers.internal.domain.community.QAnonymousPostProfile; import java.util.List; diff --git a/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousProfileImageRepository.java b/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousProfileImageRepository.java index 887bb3ea..c2ff6a52 100644 --- a/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousProfileImageRepository.java +++ b/src/main/java/org/sopt/makers/internal/community/repository/anonymous/AnonymousProfileImageRepository.java @@ -1,6 +1,6 @@ package org.sopt.makers.internal.community.repository.anonymous; -import org.sopt.makers.internal.community.domain.AnonymousProfileImage; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousProfileImage; import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; diff --git a/src/main/java/org/sopt/makers/internal/community/service/AnonymousProfileImageService.java b/src/main/java/org/sopt/makers/internal/community/service/AnonymousProfileImageService.java index 0aa64085..5c725b0a 100644 --- a/src/main/java/org/sopt/makers/internal/community/service/AnonymousProfileImageService.java +++ b/src/main/java/org/sopt/makers/internal/community/service/AnonymousProfileImageService.java @@ -1,6 +1,6 @@ package org.sopt.makers.internal.community.service; -import org.sopt.makers.internal.community.domain.AnonymousProfileImage; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousProfileImage; import org.sopt.makers.internal.community.repository.anonymous.AnonymousProfileImageRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/org/sopt/makers/internal/community/service/CommunityPostService.java b/src/main/java/org/sopt/makers/internal/community/service/CommunityPostService.java index 13a39109..1e900989 100644 --- a/src/main/java/org/sopt/makers/internal/community/service/CommunityPostService.java +++ b/src/main/java/org/sopt/makers/internal/community/service/CommunityPostService.java @@ -9,6 +9,7 @@ import org.sopt.makers.internal.community.controller.dto.request.PostSaveRequest; import org.sopt.makers.internal.community.domain.CommunityPost; import org.sopt.makers.internal.community.domain.CommunityPostLike; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousPostProfile; import org.sopt.makers.internal.community.repository.CommunityPostLikeRepository; import org.sopt.makers.internal.community.repository.CommunityPostRepository; import org.sopt.makers.internal.community.repository.anonymous.AnonymousNicknameRepository; diff --git a/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousNicknameRetriever.java b/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousNicknameRetriever.java index aca7b7ff..3b32171c 100644 --- a/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousNicknameRetriever.java +++ b/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousNicknameRetriever.java @@ -2,7 +2,7 @@ import lombok.RequiredArgsConstructor; import org.sopt.makers.internal.community.repository.anonymous.AnonymousNicknameRepository; -import org.sopt.makers.internal.domain.community.AnonymousNickname; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousNickname; import org.springframework.stereotype.Component; import java.util.List; diff --git a/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousPostProfileModifier.java b/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousPostProfileModifier.java index e4a2c230..f2498cea 100644 --- a/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousPostProfileModifier.java +++ b/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousPostProfileModifier.java @@ -1,12 +1,12 @@ package org.sopt.makers.internal.community.service.anonymous; import lombok.RequiredArgsConstructor; -import org.sopt.makers.internal.community.domain.AnonymousProfileImage; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousProfileImage; import org.sopt.makers.internal.community.domain.CommunityPost; import org.sopt.makers.internal.community.repository.anonymous.AnonymousPostProfileRepository; import org.sopt.makers.internal.domain.Member; -import org.sopt.makers.internal.domain.community.AnonymousNickname; -import org.sopt.makers.internal.domain.community.AnonymousPostProfile; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousNickname; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousPostProfile; import org.springframework.stereotype.Component; @Component diff --git a/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousPostProfileRetriever.java b/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousPostProfileRetriever.java index 5a11466b..dd143296 100644 --- a/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousPostProfileRetriever.java +++ b/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousPostProfileRetriever.java @@ -2,7 +2,7 @@ import lombok.RequiredArgsConstructor; import org.sopt.makers.internal.community.repository.anonymous.AnonymousPostProfileRepository; -import org.sopt.makers.internal.domain.community.AnonymousPostProfile; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousPostProfile; import org.springframework.stereotype.Component; import java.util.List; diff --git a/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousPostProfileService.java b/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousPostProfileService.java index a97b29f8..f874d1b8 100644 --- a/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousPostProfileService.java +++ b/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousPostProfileService.java @@ -1,11 +1,11 @@ package org.sopt.makers.internal.community.service.anonymous; import lombok.RequiredArgsConstructor; -import org.sopt.makers.internal.community.domain.AnonymousProfileImage; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousProfileImage; import org.sopt.makers.internal.community.domain.CommunityPost; import org.sopt.makers.internal.domain.Member; -import org.sopt.makers.internal.domain.community.AnonymousNickname; -import org.sopt.makers.internal.domain.community.AnonymousPostProfile; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousNickname; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousPostProfile; import org.springframework.stereotype.Component; import java.util.List; diff --git a/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousProfileImageRetriever.java b/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousProfileImageRetriever.java index 76b83fc9..05c69326 100644 --- a/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousProfileImageRetriever.java +++ b/src/main/java/org/sopt/makers/internal/community/service/anonymous/AnonymousProfileImageRetriever.java @@ -1,7 +1,7 @@ package org.sopt.makers.internal.community.service.anonymous; import lombok.RequiredArgsConstructor; -import org.sopt.makers.internal.community.domain.AnonymousProfileImage; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousProfileImage; import org.sopt.makers.internal.community.repository.anonymous.AnonymousProfileImageRepository; import org.sopt.makers.internal.exception.BusinessLogicException; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/sopt/makers/internal/domain/community/AnonymousCommentProfile.java b/src/main/java/org/sopt/makers/internal/domain/community/AnonymousCommentProfile.java index 6e1e0a1a..41cc14f7 100644 --- a/src/main/java/org/sopt/makers/internal/domain/community/AnonymousCommentProfile.java +++ b/src/main/java/org/sopt/makers/internal/domain/community/AnonymousCommentProfile.java @@ -3,8 +3,6 @@ import javax.persistence.Column; import javax.persistence.ConstraintMode; import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; import javax.persistence.ForeignKey; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; @@ -13,7 +11,8 @@ import javax.persistence.ManyToOne; import javax.persistence.OneToOne; -import org.sopt.makers.internal.community.domain.AnonymousProfileImage; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousNickname; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousProfileImage; import org.sopt.makers.internal.domain.Member; import org.sopt.makers.internal.domain.common.AuditingTimeEntity; diff --git a/src/main/java/org/sopt/makers/internal/domain/community/AnonymousProfileImg.java b/src/main/java/org/sopt/makers/internal/domain/community/AnonymousProfileImg.java deleted file mode 100644 index 5bd2af41..00000000 --- a/src/main/java/org/sopt/makers/internal/domain/community/AnonymousProfileImg.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.sopt.makers.internal.domain.community; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import lombok.Getter; - -@Getter -public enum AnonymousProfileImg { - // TODO 실제 S3 URL로 변경 - BLUE(1, "profile_blue.svg"), - ORANGE(2, "profile_orange.svg"), - PINK(3, "profile_pink.svg"), - SKYBLUE(4, "profile_skyblue.svg"), - YELLOW(5, "profile_yellow.svg"); - - private final int index; - private final String content; - - private static final Map profileImgMap = new HashMap<>(); - - AnonymousProfileImg(int index, String content) { - this.index = index; - this.content = content; - } - - static { - for (AnonymousProfileImg img : AnonymousProfileImg.values()) { - profileImgMap.put(img.index, img); - } - } - - - public static AnonymousProfileImg filtered(List excludes) { - return profileImgMap.keySet().stream() - .filter(i -> !excludes.contains(i)) - .findFirst() - .map(profileImgMap::get).orElse(null); - } - - public static AnonymousProfileImg shuffle(int index) { - return profileImgMap.get(index); - } - - public static AnonymousProfileImg getRandomProfileImg(List excludes) { - if (excludes.isEmpty() || excludes.size() >= AnonymousProfileImg.values().length) { - return shuffle((int)(Math.random() * 5)); - } - return filtered(excludes); - } -} diff --git a/src/main/java/org/sopt/makers/internal/mapper/CommunityResponseMapper.java b/src/main/java/org/sopt/makers/internal/mapper/CommunityResponseMapper.java index d8d678bb..d602af79 100644 --- a/src/main/java/org/sopt/makers/internal/mapper/CommunityResponseMapper.java +++ b/src/main/java/org/sopt/makers/internal/mapper/CommunityResponseMapper.java @@ -4,7 +4,7 @@ import org.sopt.makers.internal.domain.Member; import org.sopt.makers.internal.domain.MemberCareer; import org.sopt.makers.internal.domain.community.AnonymousCommentProfile; -import org.sopt.makers.internal.domain.community.AnonymousPostProfile; +import org.sopt.makers.internal.community.domain.anonymous.AnonymousPostProfile; import org.sopt.makers.internal.community.domain.category.Category; import org.sopt.makers.internal.community.domain.CommunityPost; import org.sopt.makers.internal.dto.community.*;