Skip to content

Commit

Permalink
Merge pull request #353 from Team-Sopetit/feature/#352/sohyeon
Browse files Browse the repository at this point in the history
[FEAT] 루틴/미션 달성 기록 삭제 API
  • Loading branch information
thguss authored Nov 17, 2024
2 parents af7145a + 9e4ebf1 commit c83d285
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,11 @@ public SuccessResponse<AchieveMemberRoutineResponse> 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.deleteHistory(historyId);
return SuccessResponse.success(SuccessMessage.DELETE_ROUTINE.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,27 @@ SuccessResponse<AchieveMemberRoutineResponse> 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
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,9 @@ private Map<Theme, Map<Routine, MemberRoutine>> toRoutinesByTheme(
)
));
}

@Transactional
public void deleteHistory(long historyId) {
routineHistoryAdapter.deleteById(historyId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit c83d285

Please sign in to comment.