From c6f0a5fcbf01e9bfd1a10fb049c08ae20d0f261f Mon Sep 17 00:00:00 2001 From: Hong0329 Date: Wed, 27 Dec 2023 00:49:15 +0900 Subject: [PATCH 1/7] =?UTF-8?q?[FEAT]=EC=94=A8=EC=95=97=20=EC=95=8C?= =?UTF-8?q?=EB=A6=BC=20=EC=A1=B0=ED=9A=8C=20API=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/seed/controller/SeedController.java | 7 ++++ .../dto/response/SeedAlarmGetResponseDto.java | 14 ++++++++ .../api/seed/repository/SeedRepository.java | 6 +++- .../seed/service/Impl/SeedServiceImpl.java | 32 +++++++++++++++++++ .../api/seed/service/SeedService.java | 6 ++++ .../common/response/SuccessStatus.java | 1 + 6 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedAlarmGetResponseDto.java diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/controller/SeedController.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/controller/SeedController.java index f901357..11b339a 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/controller/SeedController.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/controller/SeedController.java @@ -3,6 +3,7 @@ import com.example.growthookserver.api.seed.dto.request.SeedMoveRequestDto; import com.example.growthookserver.api.seed.dto.request.SeedCreateRequestDto; import com.example.growthookserver.api.seed.dto.request.SeedUpdateRequestDto; +import com.example.growthookserver.api.seed.dto.response.SeedAlarmGetResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedCreateResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedDetailGetResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedMoveResponseDto; @@ -62,4 +63,10 @@ public ApiResponse moveSeed(@PathVariable Long seedId, @Val return ApiResponse.success(SuccessStatus.MOVE_SEED_SUCCESS, seedService.moveSeed(seedId, seedMoveRequestDto)); } + @GetMapping("member/{memberId}/alarm") + @ResponseStatus(HttpStatus.OK) + @Operation(summary = "SeedAlarm", description = "기한이 3일 이내로 남은 씨앗에 대한 알림을 조회하는 API입니다.") + public ApiResponse getSeedAlarm(@PathVariable Long memberId) { + return ApiResponse.success(SuccessStatus.GET_SEED_ALARM, seedService.getSeedAlarm(memberId)); + } } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedAlarmGetResponseDto.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedAlarmGetResponseDto.java new file mode 100644 index 0000000..b252c41 --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedAlarmGetResponseDto.java @@ -0,0 +1,14 @@ +package com.example.growthookserver.api.seed.dto.response; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(staticName = "of") +public class SeedAlarmGetResponseDto { + private int seedCount; + private int daysRemaining; +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/repository/SeedRepository.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/repository/SeedRepository.java index dbe7584..2662215 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/repository/SeedRepository.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/repository/SeedRepository.java @@ -1,9 +1,11 @@ package com.example.growthookserver.api.seed.repository; -import com.example.growthookserver.api.cave.domain.Cave; import com.example.growthookserver.api.seed.domain.Seed; import com.example.growthookserver.common.exception.NotFoundException; import com.example.growthookserver.common.response.ErrorStatus; + +import java.time.LocalDate; +import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; @@ -14,4 +16,6 @@ default Seed findSeedByIdOrThrow(Long seedId) { return findSeedById(seedId) .orElseThrow(()-> new NotFoundException(ErrorStatus.NOT_FOUND_SEED.getMessage())); } + + List findByCave_MemberIdAndLockDateBetween(Long memberId, LocalDate now, LocalDate threeDaysLater); } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java index 46be8b7..7902525 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java @@ -6,17 +6,21 @@ import com.example.growthookserver.api.seed.dto.request.SeedCreateRequestDto; import com.example.growthookserver.api.seed.dto.request.SeedMoveRequestDto; import com.example.growthookserver.api.seed.dto.request.SeedUpdateRequestDto; +import com.example.growthookserver.api.seed.dto.response.SeedAlarmGetResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedCreateResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedDetailGetResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedMoveResponseDto; import com.example.growthookserver.api.seed.repository.SeedRepository; import com.example.growthookserver.api.seed.service.SeedService; import lombok.RequiredArgsConstructor; +import org.springframework.cglib.core.Local; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; import java.time.temporal.ChronoUnit; +import java.util.Comparator; +import java.util.List; @Service @RequiredArgsConstructor @@ -76,4 +80,32 @@ public SeedMoveResponseDto moveSeed(Long seedId, SeedMoveRequestDto seedMoveRequ return SeedMoveResponseDto.of(seed.getCave().getId(), seed.getCave().getName()); } + @Override + public SeedAlarmGetResponseDto getSeedAlarm(Long memberId) { + LocalDate now = LocalDate.now(); + LocalDate threeDaysLater = now.plusDays(3); + + List seeds = seedRepository.findByCave_MemberIdAndLockDateBetween(memberId, now, threeDaysLater); + + if(seeds.isEmpty()) { + return SeedAlarmGetResponseDto.of(0,0); + } + + int seedCount = seeds.size(); + + Seed earliestSeed = findEarliestSeed(seeds); + int daysRemaining = calculateDaysRemaining(now, earliestSeed.getLockDate()); + + return SeedAlarmGetResponseDto.of(seedCount, daysRemaining); + } + + private Seed findEarliestSeed(List seeds) { + return seeds.stream() + .min(Comparator.comparing(Seed::getLockDate)) + .orElse(null); + } + + private int calculateDaysRemaining(LocalDate now, LocalDate localDate) { + return (int) ChronoUnit.DAYS.between(now, localDate); + } } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/SeedService.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/SeedService.java index 636bef2..ecb1984 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/SeedService.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/SeedService.java @@ -5,10 +5,13 @@ import com.example.growthookserver.api.seed.dto.request.SeedCreateRequestDto; import com.example.growthookserver.api.seed.dto.request.SeedMoveRequestDto; import com.example.growthookserver.api.seed.dto.request.SeedUpdateRequestDto; +import com.example.growthookserver.api.seed.dto.response.SeedAlarmGetResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedCreateResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedDetailGetResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedMoveResponseDto; +import java.time.LocalDate; + public interface SeedService { //* 씨앗 생성 SeedCreateResponseDto createSeed(Long caveId, SeedCreateRequestDto seedCreateRequestDto); @@ -24,4 +27,7 @@ public interface SeedService { //* 씨앗 이동 SeedMoveResponseDto moveSeed(Long seedId, SeedMoveRequestDto seedMoveRequestDto); + + //* 씨앗 알림 조회 + SeedAlarmGetResponseDto getSeedAlarm(Long memberId); } diff --git a/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java b/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java index fca7a07..1e7afdf 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java +++ b/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java @@ -33,6 +33,7 @@ public enum SuccessStatus { PATCH_SEED_SUCCESS(HttpStatus.OK, "씨앗 수정 성공"), GET_SEED_DETAIL(HttpStatus.OK, "씨앗 상세 정보 조회 성공"), MOVE_SEED_SUCCESS(HttpStatus.OK, "씨앗 이동 성공"), + GET_SEED_ALARM(HttpStatus.OK,"씨앗 알람 조회 성공"), /** * actionplan From 6c7682c5b0e235dcc2f09e35851c0d743619ad85 Mon Sep 17 00:00:00 2001 From: Hong0329 Date: Wed, 27 Dec 2023 01:29:20 +0900 Subject: [PATCH 2/7] =?UTF-8?q?[FIX]=EC=95=A1=EC=85=98=20=ED=94=8C?= =?UTF-8?q?=EB=9E=9C=20=EC=83=9D=EC=84=B1=20API=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ActionPlanController.java | 5 +++-- .../request/ActionPlanCreateRequestDto.java | 8 +++++--- .../actionplan/service/ActionPlanService.java | 2 +- .../service/Impl/ActionPlanServiceImpl.java | 18 +++++++++++------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java index d8e0805..f02e0a7 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java @@ -27,8 +27,9 @@ public class ActionPlanController { @PostMapping("seed/{seedId}/actionPlan") @ResponseStatus(HttpStatus.CREATED) @Operation(summary = "ActionPlanPost",description = "액션 플랜 생성 API입니다.") - public ApiResponse createActionPlan(@PathVariable("seedId")Long seedId, @Valid @RequestBody ActionPlanCreateRequestDto actionPlanCreateRequestDto) { - return ApiResponse.success(SuccessStatus.POST_ACTIONPLAN_SUCCESS, actionPlanService.createActionPlan(seedId, actionPlanCreateRequestDto)); + public ApiResponse createActionPlan(@PathVariable("seedId")Long seedId, @Valid @RequestBody ActionPlanCreateRequestDto actionPlanCreateRequestDto) { + actionPlanService.createActionPlan(seedId, actionPlanCreateRequestDto); + return ApiResponse.success(SuccessStatus.POST_ACTIONPLAN_SUCCESS.getStatusCode(), SuccessStatus.POST_ACTIONPLAN_SUCCESS.getMessage()); } @GetMapping("seed/{seedId}/actionPlan") diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/request/ActionPlanCreateRequestDto.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/request/ActionPlanCreateRequestDto.java index b6e321a..3e3429c 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/request/ActionPlanCreateRequestDto.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/request/ActionPlanCreateRequestDto.java @@ -1,17 +1,19 @@ package com.example.growthookserver.api.actionplan.dto.request; -import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.List; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor public class ActionPlanCreateRequestDto { - @NotBlank + @NotNull @Size(max = 40) - private String content; + private List contents; } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/ActionPlanService.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/ActionPlanService.java index f6b8898..ddec739 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/ActionPlanService.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/ActionPlanService.java @@ -11,7 +11,7 @@ public interface ActionPlanService { //* 액션플랜 생성 - ActionPlanCreateResponseDto createActionPlan(Long seedId, ActionPlanCreateRequestDto actionPlanCreateRequestDto); + void createActionPlan(Long seedId, ActionPlanCreateRequestDto actionPlanCreateRequestDto); //* 씨앗 별 액션 플랜 조회 List getActionPlan(Long seedId); diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java index 5aa24e9..0469c6b 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java @@ -30,14 +30,18 @@ public class ActionPlanServiceImpl implements ActionPlanService { @Override @Transactional - public ActionPlanCreateResponseDto createActionPlan(Long seedId, ActionPlanCreateRequestDto actionPlanCreateRequestDto){ + public void createActionPlan(Long seedId, ActionPlanCreateRequestDto actionPlanCreateRequestDto){ Seed seed = seedRepository.findSeedByIdOrThrow(seedId); - ActionPlan actionPlan = ActionPlan.builder() - .content(actionPlanCreateRequestDto.getContent()) - .seed(seed) - .build(); - ActionPlan savedActionPlan = actionPlanRepository.save(actionPlan); - return ActionPlanCreateResponseDto.of(savedActionPlan.getId()); + + List contents = actionPlanCreateRequestDto.getContents(); + + for(String content : contents) { + ActionPlan actionPlan = ActionPlan.builder() + .content(content) + .seed(seed) + .build(); + actionPlanRepository.save(actionPlan); + } } @Override From 47f4cf8f6d51ce987ca2b4e5fba08ee477f4bc89 Mon Sep 17 00:00:00 2001 From: Hong0329 Date: Wed, 27 Dec 2023 01:31:29 +0900 Subject: [PATCH 3/7] =?UTF-8?q?[FIX]=EC=82=AC=EC=9A=A9=ED=95=98=EC=A7=80?= =?UTF-8?q?=20=EC=95=8A=EB=8A=94=20=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ActionPlanController.java | 1 - .../dto/response/ActionPlanCreateResponseDto.java | 14 -------------- .../api/actionplan/service/ActionPlanService.java | 1 - .../service/Impl/ActionPlanServiceImpl.java | 1 - 4 files changed, 17 deletions(-) delete mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/ActionPlanCreateResponseDto.java diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java index f02e0a7..ddc1694 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java @@ -2,7 +2,6 @@ import com.example.growthookserver.api.actionplan.dto.request.ActionPlanCreateRequestDto; import com.example.growthookserver.api.actionplan.dto.request.ActionPlanUpdateRequestDto; -import com.example.growthookserver.api.actionplan.dto.response.ActionPlanCreateResponseDto; import com.example.growthookserver.api.actionplan.dto.response.ActionPlanGetResponseDto; import com.example.growthookserver.api.actionplan.dto.response.DoingActionPlanGetResponseDto; import com.example.growthookserver.api.actionplan.dto.response.FinishedActionPlanGetResponseDto; diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/ActionPlanCreateResponseDto.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/ActionPlanCreateResponseDto.java deleted file mode 100644 index ad9ccf9..0000000 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/ActionPlanCreateResponseDto.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.example.growthookserver.api.actionplan.dto.response; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor(staticName = "of") -public class ActionPlanCreateResponseDto { - - private Long actionPlanId; -} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/ActionPlanService.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/ActionPlanService.java index ddec739..d4f71a5 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/ActionPlanService.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/ActionPlanService.java @@ -2,7 +2,6 @@ import com.example.growthookserver.api.actionplan.dto.request.ActionPlanCreateRequestDto; import com.example.growthookserver.api.actionplan.dto.request.ActionPlanUpdateRequestDto; -import com.example.growthookserver.api.actionplan.dto.response.ActionPlanCreateResponseDto; import com.example.growthookserver.api.actionplan.dto.response.ActionPlanGetResponseDto; import com.example.growthookserver.api.actionplan.dto.response.DoingActionPlanGetResponseDto; import com.example.growthookserver.api.actionplan.dto.response.FinishedActionPlanGetResponseDto; diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java index 0469c6b..040c879 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java @@ -3,7 +3,6 @@ import com.example.growthookserver.api.actionplan.domain.ActionPlan; import com.example.growthookserver.api.actionplan.dto.request.ActionPlanCreateRequestDto; import com.example.growthookserver.api.actionplan.dto.request.ActionPlanUpdateRequestDto; -import com.example.growthookserver.api.actionplan.dto.response.ActionPlanCreateResponseDto; import com.example.growthookserver.api.actionplan.dto.response.ActionPlanGetResponseDto; import com.example.growthookserver.api.actionplan.dto.response.DoingActionPlanGetResponseDto; import com.example.growthookserver.api.actionplan.dto.response.FinishedActionPlanGetResponseDto; From da9c52eda1bf09382d9acc48a190075a33c241c7 Mon Sep 17 00:00:00 2001 From: Hong0329 Date: Thu, 28 Dec 2023 02:52:15 +0900 Subject: [PATCH 4/7] =?UTF-8?q?[FIX]=EC=95=A1=EC=85=98=20=ED=94=8C?= =?UTF-8?q?=EB=9E=9C=20=EC=99=84=EB=A3=8C=ED=95=98=EA=B8=B0API=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actionplan/service/Impl/ActionPlanServiceImpl.java | 9 +++++++++ .../growthookserver/api/member/domain/Member.java | 5 +++++ .../growthookserver/common/response/ErrorStatus.java | 1 + 3 files changed, 15 insertions(+) diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java index 040c879..e7a771e 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java @@ -8,8 +8,11 @@ import com.example.growthookserver.api.actionplan.dto.response.FinishedActionPlanGetResponseDto; import com.example.growthookserver.api.actionplan.repository.ActionPlanRepository; import com.example.growthookserver.api.actionplan.service.ActionPlanService; +import com.example.growthookserver.api.member.domain.Member; import com.example.growthookserver.api.seed.domain.Seed; import com.example.growthookserver.api.seed.repository.SeedRepository; +import com.example.growthookserver.common.exception.BadRequestException; +import com.example.growthookserver.common.response.ErrorStatus; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -70,7 +73,13 @@ public void deleteActionPlan(Long actionPlanId) { @Transactional public void completeActionPlan(Long actionPlanId) { ActionPlan existinActionPlan = actionPlanRepository.findActionPlanByIdOrThrow(actionPlanId); + if(existinActionPlan.getIsFinished()) { + throw new BadRequestException(ErrorStatus.ALREADY_COMPLETE_ACTIONPLAN.getMessage()); + } existinActionPlan.completeActionPlan(true); + + Member member = existinActionPlan.getSeed().getCave().getMember(); + member.incrementGatheredSsuk(); } @Override diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/member/domain/Member.java b/growthookServer/src/main/java/com/example/growthookserver/api/member/domain/Member.java index b49c3e6..7d567eb 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/member/domain/Member.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/member/domain/Member.java @@ -51,4 +51,9 @@ public Member(String nickname, String email, SocialPlatform socialPlatform, Bool this.usedSsuk = usedSsuk; this.gatheredSsuk = gatheredSsuk; } + + @Builder + public void incrementGatheredSsuk() { + this.gatheredSsuk = (this.gatheredSsuk == null ? 0 : this.gatheredSsuk) + 1; + } } diff --git a/growthookServer/src/main/java/com/example/growthookserver/common/response/ErrorStatus.java b/growthookServer/src/main/java/com/example/growthookserver/common/response/ErrorStatus.java index d4f13eb..835502e 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/common/response/ErrorStatus.java +++ b/growthookServer/src/main/java/com/example/growthookserver/common/response/ErrorStatus.java @@ -16,6 +16,7 @@ public enum ErrorStatus { NO_TOKEN("토큰을 넣어주세요."), INVALID_MEMBER("유효하지 않은 유저입니다."), ANOTHER_ACCESS_TOKEN("지원하지 않는 소셜 플랫폼입니다."), + ALREADY_COMPLETE_ACTIONPLAN("이미 완료된 액션 플랜입니다."), /** * 401 UNAUTHORIZED From 23cf1847a79636406f1fd2b1b2a2b009be56f8e1 Mon Sep 17 00:00:00 2001 From: Hong0329 Date: Fri, 29 Dec 2023 03:33:46 +0900 Subject: [PATCH 5/7] =?UTF-8?q?[FIX]=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actionplan/service/Impl/ActionPlanServiceImpl.java | 10 +++------- .../api/seed/dto/response/SeedAlarmGetResponseDto.java | 1 - .../api/seed/service/Impl/SeedServiceImpl.java | 7 ++----- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java index e7a771e..f1c540e 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java @@ -37,13 +37,9 @@ public void createActionPlan(Long seedId, ActionPlanCreateRequestDto actionPlanC List contents = actionPlanCreateRequestDto.getContents(); - for(String content : contents) { - ActionPlan actionPlan = ActionPlan.builder() - .content(content) - .seed(seed) - .build(); - actionPlanRepository.save(actionPlan); - } + contents.stream() + .map(content -> ActionPlan.builder().content(content).seed(seed).build()) + .forEach(actionPlanRepository::save); } @Override diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedAlarmGetResponseDto.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedAlarmGetResponseDto.java index b252c41..aa5322d 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedAlarmGetResponseDto.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedAlarmGetResponseDto.java @@ -10,5 +10,4 @@ @AllArgsConstructor(staticName = "of") public class SeedAlarmGetResponseDto { private int seedCount; - private int daysRemaining; } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java index 7902525..2d990e7 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java @@ -88,15 +88,12 @@ public SeedAlarmGetResponseDto getSeedAlarm(Long memberId) { List seeds = seedRepository.findByCave_MemberIdAndLockDateBetween(memberId, now, threeDaysLater); if(seeds.isEmpty()) { - return SeedAlarmGetResponseDto.of(0,0); + return SeedAlarmGetResponseDto.of(0); } int seedCount = seeds.size(); - Seed earliestSeed = findEarliestSeed(seeds); - int daysRemaining = calculateDaysRemaining(now, earliestSeed.getLockDate()); - - return SeedAlarmGetResponseDto.of(seedCount, daysRemaining); + return SeedAlarmGetResponseDto.of(seedCount); } private Seed findEarliestSeed(List seeds) { From 5911636818765c3153a4a84652c163072d49ec21 Mon Sep 17 00:00:00 2001 From: Hong0329 Date: Thu, 4 Jan 2024 16:14:35 +0900 Subject: [PATCH 6/7] =?UTF-8?q?[TEST]CI=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- growthookServer/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/growthookServer/.gitignore b/growthookServer/.gitignore index b89ff5c..a0ce3cb 100644 --- a/growthookServer/.gitignore +++ b/growthookServer/.gitignore @@ -38,4 +38,4 @@ out/ resources ../.DS_Store -.DS_Store \ No newline at end of file +.DS_Store From 5969d62f2c9783752a9c46026cadaa97cf636be4 Mon Sep 17 00:00:00 2001 From: Hong0329 <97835512+Hong0329@users.noreply.github.com> Date: Fri, 5 Jan 2024 03:35:11 +0900 Subject: [PATCH 7/7] =?UTF-8?q?[FIX]=EC=95=88=EC=93=B0=EB=8A=94=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/seed/service/Impl/SeedServiceImpl.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java index 2d990e7..e63755d 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java @@ -95,14 +95,4 @@ public SeedAlarmGetResponseDto getSeedAlarm(Long memberId) { return SeedAlarmGetResponseDto.of(seedCount); } - - private Seed findEarliestSeed(List seeds) { - return seeds.stream() - .min(Comparator.comparing(Seed::getLockDate)) - .orElse(null); - } - - private int calculateDaysRemaining(LocalDate now, LocalDate localDate) { - return (int) ChronoUnit.DAYS.between(now, localDate); - } }