diff --git a/src/main/java/com/pickple/server/api/moim/domain/Moim.java b/src/main/java/com/pickple/server/api/moim/domain/Moim.java index 9c48f55e..bdad58d3 100644 --- a/src/main/java/com/pickple/server/api/moim/domain/Moim.java +++ b/src/main/java/com/pickple/server/api/moim/domain/Moim.java @@ -1,15 +1,12 @@ package com.pickple.server.api.moim.domain; import com.pickple.server.api.host.domain.Host; -import com.pickple.server.api.moim.domain.enums.MoimState; import com.pickple.server.api.moimsubmission.domain.AccountInfo; import com.pickple.server.api.moimsubmission.domain.MoimSubmission; import com.pickple.server.api.notice.domain.Notice; import com.pickple.server.global.common.domain.BaseTimeEntity; import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -31,6 +28,7 @@ @Entity @Getter @Table(name = "moims") +@Builder @NoArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) public class Moim extends BaseTimeEntity { @@ -70,44 +68,11 @@ public class Moim extends BaseTimeEntity { @JdbcTypeCode(SqlTypes.JSON) private ImageInfo imageList; - @Enumerated(EnumType.STRING) - private MoimState moimState; + private String moimState; @OneToMany(mappedBy = "moim", cascade = CascadeType.REMOVE) private List notices = new ArrayList<>(); @OneToMany(mappedBy = "moim", cascade = CascadeType.REMOVE) private List moimSubmissions = new ArrayList<>(); - - @Builder - public Moim( - final Host host, - final CategoryInfo categoryList, - final boolean isOffline, - final String spot, - final DateInfo dateList, - final int maxGuest, - final int fee, - final AccountInfo accountList, - final QuestionInfo questionList, - final String title, - final String description, - final ImageInfo imageList, - final MoimState moimState - ) { - this.host = host; - this.categoryList = categoryList; - this.isOffline = isOffline; - this.spot = spot; - this.dateList = dateList; - this.maxGuest = maxGuest; - this.fee = fee; - this.accountList = accountList; - this.questionList = questionList; - this.title = title; - this.description = description; - this.imageList = imageList; - this.moimState = moimState; - } - } diff --git a/src/main/java/com/pickple/server/api/moim/domain/enums/Category.java b/src/main/java/com/pickple/server/api/moim/domain/enums/Category.java index 3ef4a1e8..de1d2589 100644 --- a/src/main/java/com/pickple/server/api/moim/domain/enums/Category.java +++ b/src/main/java/com/pickple/server/api/moim/domain/enums/Category.java @@ -3,29 +3,38 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +@Getter +@RequiredArgsConstructor public enum Category { NJOB("njob"), + INVESTMENT("investment"), + STARTUP("startup"), + EMPLOYMENT("employment"), + PRODUCTIVITY("productivity"), + LIFESTYLE("lifestyle"), + HEALTH("health"), + MIND("mind"), + HOBBY("hobby"), + LANGUAGE("language"); - public final String category; - Category(String category) { - this.category = category; - } + public final String category; public static List getCategories() { return Arrays.stream(Category.values()) .map(category -> category.category) .collect(Collectors.toList()); } - } diff --git a/src/main/java/com/pickple/server/api/moim/domain/enums/MoimState.java b/src/main/java/com/pickple/server/api/moim/domain/enums/MoimState.java index 75de370f..10a1e3da 100644 --- a/src/main/java/com/pickple/server/api/moim/domain/enums/MoimState.java +++ b/src/main/java/com/pickple/server/api/moim/domain/enums/MoimState.java @@ -1,13 +1,15 @@ package com.pickple.server.api.moim.domain.enums; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor public enum MoimState { - ONGOING("ONGOING"), - COMPLETED("COMPLETED"); - public final String moimState; + ONGOING("ongoing"), - MoimState(String moimState) { - this.moimState = moimState; - } + COMPLETED("completed"); + public final String moimState; } diff --git a/src/main/java/com/pickple/server/api/moim/dto/response/MoimByCategoryResponse.java b/src/main/java/com/pickple/server/api/moim/dto/response/MoimByCategoryResponse.java index 52310ffe..b816117d 100644 --- a/src/main/java/com/pickple/server/api/moim/dto/response/MoimByCategoryResponse.java +++ b/src/main/java/com/pickple/server/api/moim/dto/response/MoimByCategoryResponse.java @@ -5,12 +5,19 @@ @Builder public record MoimByCategoryResponse( + Long moimId, + int dayOfDay, + String title, + String hostNickName, + DateInfo dateList, + String moimImageUrl, + String hostImageUrl ) { } diff --git a/src/main/java/com/pickple/server/api/moim/dto/response/SubmittedMoimByGuestResponse.java b/src/main/java/com/pickple/server/api/moim/dto/response/SubmittedMoimByGuestResponse.java index 43e1b9a2..21193193 100644 --- a/src/main/java/com/pickple/server/api/moim/dto/response/SubmittedMoimByGuestResponse.java +++ b/src/main/java/com/pickple/server/api/moim/dto/response/SubmittedMoimByGuestResponse.java @@ -1,13 +1,12 @@ package com.pickple.server.api.moim.dto.response; import com.pickple.server.api.moim.domain.DateInfo; -import com.pickple.server.api.moimsubmission.domain.MoimSubmissionState; import lombok.Builder; @Builder public record SubmittedMoimByGuestResponse( Long moimId, - MoimSubmissionState moimSubmissionState, + String moimSubmissionState, String title, String hostNickname, DateInfo dateList, diff --git a/src/main/java/com/pickple/server/api/moim/service/MoimCommandService.java b/src/main/java/com/pickple/server/api/moim/service/MoimCommandService.java index 1f1e7484..dbdf0de5 100644 --- a/src/main/java/com/pickple/server/api/moim/service/MoimCommandService.java +++ b/src/main/java/com/pickple/server/api/moim/service/MoimCommandService.java @@ -33,7 +33,7 @@ public void createMoim(Long hostId, MoimCreateRequest request) { .title(request.title()) .description(request.description()) .imageList(request.imageList()) - .moimState(MoimState.ONGOING) + .moimState(MoimState.ONGOING.getMoimState()) .build(); moimRepository.save(moim); } diff --git a/src/main/java/com/pickple/server/api/moimsubmission/controller/MoimSubmissionController.java b/src/main/java/com/pickple/server/api/moimsubmission/controller/MoimSubmissionController.java index e5bc4e0a..5661294f 100644 --- a/src/main/java/com/pickple/server/api/moimsubmission/controller/MoimSubmissionController.java +++ b/src/main/java/com/pickple/server/api/moimsubmission/controller/MoimSubmissionController.java @@ -1,6 +1,5 @@ package com.pickple.server.api.moimsubmission.controller; -import com.pickple.server.api.moimsubmission.domain.MoimSubmissionState; import com.pickple.server.api.moimsubmission.dto.request.MoimSubmitRequest; import com.pickple.server.api.moimsubmission.service.MoimSubmissionCommandService; import com.pickple.server.api.moimsubmission.service.MoimSubmissionQueryService; @@ -37,7 +36,7 @@ public ApiResponseDto createMoimSubmission( @GetMapping("/v1/guest/{guestId}/submitted-moim-list") public ApiResponseDto getSubmittedMoimListByGuest( @PathVariable Long guestId, - @RequestParam MoimSubmissionState moimSubmissionState + @RequestParam String moimSubmissionState ) { return ApiResponseDto.success(SuccessCode.SUBMITTED_MOIM_LIST_BY_GUEST_GET_SUCCESS, moimSubmissionQueryService.getSubmittedMoimListByGuest(guestId, moimSubmissionState)); @@ -49,6 +48,7 @@ public ApiResponseDto getSubmissionDetail( ) { return ApiResponseDto.success(SuccessCode.SUBMISSION_DETAIL_GET_SUCCESS, moimSubmissionQueryService.getSubmittionDetail(moimId, submitterId)); + } @GetMapping("/v1/guest/{guestId}/completed-moim-list") public ApiResponseDto getCompletedMoimListByGuest( diff --git a/src/main/java/com/pickple/server/api/moimsubmission/domain/MoimSubmission.java b/src/main/java/com/pickple/server/api/moimsubmission/domain/MoimSubmission.java index 27a9ba84..0425da6c 100644 --- a/src/main/java/com/pickple/server/api/moimsubmission/domain/MoimSubmission.java +++ b/src/main/java/com/pickple/server/api/moimsubmission/domain/MoimSubmission.java @@ -3,8 +3,6 @@ import com.pickple.server.api.moim.domain.Moim; import com.pickple.server.global.common.domain.BaseTimeEntity; import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -44,6 +42,5 @@ public class MoimSubmission extends BaseTimeEntity { @JdbcTypeCode(SqlTypes.JSON) private AccountInfo accountList; - @Enumerated(EnumType.STRING) - private MoimSubmissionState moimSubmissionState; + private String moimSubmissionState; } diff --git a/src/main/java/com/pickple/server/api/moimsubmission/domain/MoimSubmissionState.java b/src/main/java/com/pickple/server/api/moimsubmission/domain/MoimSubmissionState.java index d0da8c39..42003e50 100644 --- a/src/main/java/com/pickple/server/api/moimsubmission/domain/MoimSubmissionState.java +++ b/src/main/java/com/pickple/server/api/moimsubmission/domain/MoimSubmissionState.java @@ -1,17 +1,25 @@ package com.pickple.server.api.moimsubmission.domain; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor public enum MoimSubmissionState { + ALL("all"), + PENDING_PAYMENT("pendingPayment"), + PENDING_APPROVAL("pendingApproval"), + APPROVED("approved"), + REJECTED("rejected"), + REFUNDED("refunded"), + COMPLETED("completed"); public final String moimSubmissionState; - - MoimSubmissionState(String moimSubmissionState) { - this.moimSubmissionState = moimSubmissionState; - } } diff --git a/src/main/java/com/pickple/server/api/moimsubmission/repository/MoimSubmissionRepository.java b/src/main/java/com/pickple/server/api/moimsubmission/repository/MoimSubmissionRepository.java index 743254f3..f9c72887 100644 --- a/src/main/java/com/pickple/server/api/moimsubmission/repository/MoimSubmissionRepository.java +++ b/src/main/java/com/pickple/server/api/moimsubmission/repository/MoimSubmissionRepository.java @@ -2,21 +2,20 @@ import com.pickple.server.api.moim.domain.Moim; import com.pickple.server.api.moimsubmission.domain.MoimSubmission; -import com.pickple.server.api.moimsubmission.domain.MoimSubmissionState; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; public interface MoimSubmissionRepository extends JpaRepository { - boolean existsByMoimAndMoimSubmissionState(Moim moim, MoimSubmissionState moimSubmissionState); + boolean existsByMoimAndMoimSubmissionState(Moim moim, String moimSubmissionState); List findAllByGuestId(Long guestId); - List findAllByMoimSubmissionState(MoimSubmissionState moimSubmissionState); + List findAllByMoimSubmissionState(String moimSubmissionState); MoimSubmission findBymoimIdAndGuestId(Long moimId, Long guestId); - @Query("SELECT ms FROM MoimSubmission ms WHERE ms.guestId = :guestId AND ms.moimSubmissionState = 'COMPLETED'") + @Query("SELECT ms FROM MoimSubmission ms WHERE ms.guestId = :guestId AND ms.moimSubmissionState = 'completed'") List findCompletedMoimSubmissionsByGuest(@Param("guestId") Long guestId); } diff --git a/src/main/java/com/pickple/server/api/moimsubmission/service/MoimSubmissionCommandService.java b/src/main/java/com/pickple/server/api/moimsubmission/service/MoimSubmissionCommandService.java index f01d8dcf..18f5a7cb 100644 --- a/src/main/java/com/pickple/server/api/moimsubmission/service/MoimSubmissionCommandService.java +++ b/src/main/java/com/pickple/server/api/moimsubmission/service/MoimSubmissionCommandService.java @@ -27,7 +27,7 @@ public void createMoimSubmission(Long moimId, Long guestId, MoimSubmitRequest re .moim(moim) .answerList(request.answerList()) .accountList(request.accountList()) - .moimSubmissionState(MoimSubmissionState.PENDING_PAYMENT) + .moimSubmissionState(MoimSubmissionState.PENDING_PAYMENT.getMoimSubmissionState()) .build(); isDuplicatedMoimSubmission(moimSubmission); moimSubmissionRepository.save(moimSubmission); diff --git a/src/main/java/com/pickple/server/api/moimsubmission/service/MoimSubmissionQueryService.java b/src/main/java/com/pickple/server/api/moimsubmission/service/MoimSubmissionQueryService.java index 73c6ffbf..f0d35a8d 100644 --- a/src/main/java/com/pickple/server/api/moimsubmission/service/MoimSubmissionQueryService.java +++ b/src/main/java/com/pickple/server/api/moimsubmission/service/MoimSubmissionQueryService.java @@ -24,11 +24,11 @@ public class MoimSubmissionQueryService { private final MoimSubmissionRepository moimSubmissionRepository; public List getSubmittedMoimListByGuest(final Long guestId, - final MoimSubmissionState moimSubmissionState) { + final String moimSubmissionState) { Guest guest = guestRepository.findGuestByIdOrThrow(guestId); List moimSubmissionList; - if (moimSubmissionState.equals(MoimSubmissionState.ALL)) { + if (moimSubmissionState.equals(MoimSubmissionState.ALL.getMoimSubmissionState())) { moimSubmissionList = moimSubmissionRepository.findAllByGuestId(guest.getId()); } else { moimSubmissionList = moimSubmissionRepository.findAllByMoimSubmissionState(moimSubmissionState); @@ -62,6 +62,7 @@ public SubmittionDetailResponse getSubmittionDetail(Long moimId, Long guestId) { .answerList(submission.getAnswerList()) .questionList(submission.getMoim().getQuestionList()) .build(); + } public List getCompletedMoimListByGuest(final Long guestId) { Guest guest = guestRepository.findGuestByIdOrThrow(guestId); diff --git a/src/main/java/com/pickple/server/api/submitter/domain/Submitter.java b/src/main/java/com/pickple/server/api/submitter/domain/Submitter.java index 4075ee91..4e8e3c47 100644 --- a/src/main/java/com/pickple/server/api/submitter/domain/Submitter.java +++ b/src/main/java/com/pickple/server/api/submitter/domain/Submitter.java @@ -3,8 +3,6 @@ import com.pickple.server.api.guest.domain.Guest; import com.pickple.server.global.common.domain.BaseTimeEntity; import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -22,6 +20,7 @@ @Entity @Getter +@Builder @Table(name = "submitters") @NoArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) @@ -50,28 +49,5 @@ public class Submitter extends BaseTimeEntity { private String email; - @Enumerated(EnumType.STRING) - private SubmitterState submitterState; - - @Builder - public Submitter(final Guest guest, - final String intro, - final String goal, - final String link, - final String nickname, - final SubmitterCategoryInfo categoryList, - final String plan, - final String email, - final SubmitterState submitterState - ) { - this.guest = guest; - this.intro = intro; - this.goal = goal; - this.link = link; - this.nickname = nickname; - this.categoryList = categoryList; - this.plan = plan; - this.email = email; - this.submitterState = submitterState; - } + private String submitterState; } diff --git a/src/main/java/com/pickple/server/api/submitter/domain/SubmitterCategoryInfo.java b/src/main/java/com/pickple/server/api/submitter/domain/SubmitterCategoryInfo.java index 9b0ea393..41b19133 100644 --- a/src/main/java/com/pickple/server/api/submitter/domain/SubmitterCategoryInfo.java +++ b/src/main/java/com/pickple/server/api/submitter/domain/SubmitterCategoryInfo.java @@ -12,14 +12,8 @@ public class SubmitterCategoryInfo { @NotBlank(message = "카테고리가 비었습니다.") private final String category1; + private final String category2; - private final String category3; - public static SubmitterCategoryInfo of(String category1, String category2, String category3) { - return SubmitterCategoryInfo.builder() - .category1(category1) - .category2(category2) - .category3(category3) - .build(); - } + private final String category3; } diff --git a/src/main/java/com/pickple/server/api/submitter/domain/SubmitterState.java b/src/main/java/com/pickple/server/api/submitter/domain/SubmitterState.java index 0a2a9a9b..34caced7 100644 --- a/src/main/java/com/pickple/server/api/submitter/domain/SubmitterState.java +++ b/src/main/java/com/pickple/server/api/submitter/domain/SubmitterState.java @@ -1,14 +1,17 @@ package com.pickple.server.api.submitter.domain; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor public enum SubmitterState { PENDING("pending"), + APPROVE("approve"), + REJECT("reject"); public final String submitterState; - - SubmitterState(String submitterState) { - this.submitterState = submitterState; - } } diff --git a/src/main/java/com/pickple/server/api/submitter/repository/SubmitterRepository.java b/src/main/java/com/pickple/server/api/submitter/repository/SubmitterRepository.java index 209695f1..e37bc444 100644 --- a/src/main/java/com/pickple/server/api/submitter/repository/SubmitterRepository.java +++ b/src/main/java/com/pickple/server/api/submitter/repository/SubmitterRepository.java @@ -2,9 +2,8 @@ import com.pickple.server.api.guest.domain.Guest; import com.pickple.server.api.submitter.domain.Submitter; -import com.pickple.server.api.submitter.domain.SubmitterState; import org.springframework.data.jpa.repository.JpaRepository; public interface SubmitterRepository extends JpaRepository { - boolean existsByGuestAndSubmitterState(Guest guest, SubmitterState submitterState); + boolean existsByGuestAndSubmitterState(Guest guest, String submitterState); } \ No newline at end of file diff --git a/src/main/java/com/pickple/server/api/submitter/service/SubmitterCommandService.java b/src/main/java/com/pickple/server/api/submitter/service/SubmitterCommandService.java index 47200669..2c8d466d 100644 --- a/src/main/java/com/pickple/server/api/submitter/service/SubmitterCommandService.java +++ b/src/main/java/com/pickple/server/api/submitter/service/SubmitterCommandService.java @@ -32,7 +32,7 @@ public void createSubmitter(Long guestId, SubmitterCreateRequest request) { .categoryList(request.categoryList()) .email(request.email()) .plan(request.plan()) - .submitterState(SubmitterState.PENDING) + .submitterState(SubmitterState.PENDING.getSubmitterState()) .build(); isDulicatedSubmition(submitter); submitterRepository.save(submitter);