From 7ab98f9c4f9a78e988c68ddc9c334d4d5b9a5e85 Mon Sep 17 00:00:00 2001 From: thguss Date: Sun, 17 Nov 2024 16:13:01 +0900 Subject: [PATCH 1/3] feature: delete RoutineHistory by id --- .../api/controller/MemberRoutineApi.java | 7 ++++++ .../controller/docs/MemberRoutineApiDocs.java | 23 +++++++++++++++++++ .../memberroutine/MemberRoutineService.java | 5 ++++ .../routine/RoutineHistoryAdapter.java | 4 ++++ 4 files changed, 39 insertions(+) diff --git a/src/main/java/com/soptie/server/api/controller/MemberRoutineApi.java b/src/main/java/com/soptie/server/api/controller/MemberRoutineApi.java index a2f81a03..d591b721 100644 --- a/src/main/java/com/soptie/server/api/controller/MemberRoutineApi.java +++ b/src/main/java/com/soptie/server/api/controller/MemberRoutineApi.java @@ -48,4 +48,11 @@ public SuccessResponse achieveMemberRoutine( val response = memberRoutineService.achieveMemberRoutine(memberId, routineId); return SuccessResponse.success(SuccessMessage.ACHIEVE_ROUTINE.getMessage(), response); } + + @ResponseStatus(HttpStatus.OK) + @DeleteMapping("/history/{historyId}") + public SuccessResponse deleteRoutineHistory(@PathVariable long historyId) { + memberRoutineService.deleteByHistoryId(historyId); + return SuccessResponse.success(SuccessMessage.DELETE_ROUTINE.getMessage()); + } } diff --git a/src/main/java/com/soptie/server/api/controller/docs/MemberRoutineApiDocs.java b/src/main/java/com/soptie/server/api/controller/docs/MemberRoutineApiDocs.java index 3e859500..5645b85e 100644 --- a/src/main/java/com/soptie/server/api/controller/docs/MemberRoutineApiDocs.java +++ b/src/main/java/com/soptie/server/api/controller/docs/MemberRoutineApiDocs.java @@ -71,4 +71,27 @@ SuccessResponse achieveMemberRoutine( example = "1" ) @PathVariable long routineId ); + + @Operation( + summary = "루틴 기록 삭제", + description = "달성한 루틴 기록을 삭제합니다.", + responses = { + @ApiResponse(responseCode = "200", description = "성공"), + @ApiResponse( + responseCode = "4xx", + description = "클라이언트(요청) 오류", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = ErrorResponse.class)))} + ) + SuccessResponse deleteRoutineHistory( + @Parameter( + name = "historyId", + description = "달성 이력 id", + in = ParameterIn.PATH, + example = "1" + ) @PathVariable long historyId + ); } diff --git a/src/main/java/com/soptie/server/domain/memberroutine/MemberRoutineService.java b/src/main/java/com/soptie/server/domain/memberroutine/MemberRoutineService.java index a78ca01a..28d0cb34 100644 --- a/src/main/java/com/soptie/server/domain/memberroutine/MemberRoutineService.java +++ b/src/main/java/com/soptie/server/domain/memberroutine/MemberRoutineService.java @@ -126,4 +126,9 @@ private Map> toRoutinesByTheme( ) )); } + + @Transactional + public void deleteByHistoryId(long historyId) { + routineHistoryAdapter.deleteById(historyId); + } } diff --git a/src/main/java/com/soptie/server/persistence/adapter/routine/RoutineHistoryAdapter.java b/src/main/java/com/soptie/server/persistence/adapter/routine/RoutineHistoryAdapter.java index 3b0e4725..48c7b050 100644 --- a/src/main/java/com/soptie/server/persistence/adapter/routine/RoutineHistoryAdapter.java +++ b/src/main/java/com/soptie/server/persistence/adapter/routine/RoutineHistoryAdapter.java @@ -21,4 +21,8 @@ public void save(long memberRoutineId) { public void deleteByRoutineIdAndCreatedAt(long memberRoutineId, LocalDate date) { historyRepository.deleteByMemberRoutineIdAndCreatedAt(memberRoutineId, date); } + + public void deleteById(long id) { + historyRepository.deleteById(id); + } } From a8d4d456009191a55dfeb091e20a8ba1641c0700 Mon Sep 17 00:00:00 2001 From: thguss Date: Sun, 17 Nov 2024 16:16:17 +0900 Subject: [PATCH 2/3] feature: delete RoutineHistory by id --- .../java/com/soptie/server/api/controller/MemberRoutineApi.java | 2 +- .../server/domain/memberroutine/MemberRoutineService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/soptie/server/api/controller/MemberRoutineApi.java b/src/main/java/com/soptie/server/api/controller/MemberRoutineApi.java index d591b721..1d17ecd5 100644 --- a/src/main/java/com/soptie/server/api/controller/MemberRoutineApi.java +++ b/src/main/java/com/soptie/server/api/controller/MemberRoutineApi.java @@ -52,7 +52,7 @@ public SuccessResponse achieveMemberRoutine( @ResponseStatus(HttpStatus.OK) @DeleteMapping("/history/{historyId}") public SuccessResponse deleteRoutineHistory(@PathVariable long historyId) { - memberRoutineService.deleteByHistoryId(historyId); + memberRoutineService.deleteHistory(historyId); return SuccessResponse.success(SuccessMessage.DELETE_ROUTINE.getMessage()); } } diff --git a/src/main/java/com/soptie/server/domain/memberroutine/MemberRoutineService.java b/src/main/java/com/soptie/server/domain/memberroutine/MemberRoutineService.java index 28d0cb34..f81ae1c5 100644 --- a/src/main/java/com/soptie/server/domain/memberroutine/MemberRoutineService.java +++ b/src/main/java/com/soptie/server/domain/memberroutine/MemberRoutineService.java @@ -128,7 +128,7 @@ private Map> toRoutinesByTheme( } @Transactional - public void deleteByHistoryId(long historyId) { + public void deleteHistory(long historyId) { routineHistoryAdapter.deleteById(historyId); } } From 03dd5ce4208e6a9133d12fe5c19efd27c29bbcef Mon Sep 17 00:00:00 2001 From: thguss Date: Sun, 17 Nov 2024 16:16:37 +0900 Subject: [PATCH 3/3] feature: delete MissionHistory by id --- .../api/controller/MemberMissionApi.java | 7 ++++++ .../controller/docs/MemberMissionApiDocs.java | 23 +++++++++++++++++++ .../membermission/MemberMissionService.java | 5 ++++ .../mission/MissionHistoryAdapter.java | 4 ++++ 4 files changed, 39 insertions(+) diff --git a/src/main/java/com/soptie/server/api/controller/MemberMissionApi.java b/src/main/java/com/soptie/server/api/controller/MemberMissionApi.java index b43d5aa7..955f104c 100644 --- a/src/main/java/com/soptie/server/api/controller/MemberMissionApi.java +++ b/src/main/java/com/soptie/server/api/controller/MemberMissionApi.java @@ -54,4 +54,11 @@ public SuccessResponse achieveMemberMission(Principal principal, @PathVariabl memberMissionService.achieveMemberMission(memberId, routineId); return SuccessResponse.success(SuccessMessage.ACHIEVE_ROUTINE.getMessage()); } + + @ResponseStatus(HttpStatus.OK) + @DeleteMapping("/history/{historyId}") + public SuccessResponse deleteMissionHistory(@PathVariable long historyId) { + memberMissionService.deleteHistory(historyId); + return SuccessResponse.success(SuccessMessage.DELETE_ROUTINE.getMessage()); + } } diff --git a/src/main/java/com/soptie/server/api/controller/docs/MemberMissionApiDocs.java b/src/main/java/com/soptie/server/api/controller/docs/MemberMissionApiDocs.java index a0f58a1c..50699adf 100644 --- a/src/main/java/com/soptie/server/api/controller/docs/MemberMissionApiDocs.java +++ b/src/main/java/com/soptie/server/api/controller/docs/MemberMissionApiDocs.java @@ -94,4 +94,27 @@ SuccessResponse achieveMemberMission( ) @PathVariable long routineId ); + + @Operation( + summary = "미션 기록 삭제", + description = "달성한 미션 기록을 삭제합니다.", + responses = { + @ApiResponse(responseCode = "200", description = "성공"), + @ApiResponse( + responseCode = "4xx", + description = "클라이언트(요청) 오류", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = ErrorResponse.class)))} + ) + SuccessResponse deleteMissionHistory( + @Parameter( + name = "historyId", + description = "달성 이력 id", + in = ParameterIn.PATH, + example = "1" + ) @PathVariable long historyId + ); } diff --git a/src/main/java/com/soptie/server/domain/membermission/MemberMissionService.java b/src/main/java/com/soptie/server/domain/membermission/MemberMissionService.java index 4cc83781..14376461 100644 --- a/src/main/java/com/soptie/server/domain/membermission/MemberMissionService.java +++ b/src/main/java/com/soptie/server/domain/membermission/MemberMissionService.java @@ -83,4 +83,9 @@ private GetMemberMissionResponse toGetMemberMissionResponse(MemberMission member val theme = themeAdapter.findById(challenge.getThemeId()); return GetMemberMissionResponse.of(memberMission, theme, challenge, mission); } + + @Transactional + public void deleteHistory(long historyId) { + missionHistoryAdapter.deleteById(historyId); + } } diff --git a/src/main/java/com/soptie/server/persistence/adapter/mission/MissionHistoryAdapter.java b/src/main/java/com/soptie/server/persistence/adapter/mission/MissionHistoryAdapter.java index f33dc5c5..9893b4cb 100644 --- a/src/main/java/com/soptie/server/persistence/adapter/mission/MissionHistoryAdapter.java +++ b/src/main/java/com/soptie/server/persistence/adapter/mission/MissionHistoryAdapter.java @@ -15,4 +15,8 @@ public class MissionHistoryAdapter { public void save(long memberMissionId) { historyRepository.save(new MissionHistoryEntity(memberMissionId)); } + + public void deleteById(long historyId) { + historyRepository.deleteById(historyId); + } }