From e1b44d3f7295ee02a64d594afcd1a644d756d226 Mon Sep 17 00:00:00 2001 From: dong99u Date: Fri, 8 Aug 2025 11:04:51 +0900 Subject: [PATCH 1/3] [REFACTOR] Add `title` field to `MemoDetailResponseDTO` in static factory method --- .../domain/memo/dto/response/MemoDetailResponseDTO.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/indayvidual/server/domain/memo/dto/response/MemoDetailResponseDTO.java b/src/main/java/com/indayvidual/server/domain/memo/dto/response/MemoDetailResponseDTO.java index 988d94b..cd0b5b2 100644 --- a/src/main/java/com/indayvidual/server/domain/memo/dto/response/MemoDetailResponseDTO.java +++ b/src/main/java/com/indayvidual/server/domain/memo/dto/response/MemoDetailResponseDTO.java @@ -22,6 +22,9 @@ public class MemoDetailResponseDTO { @Schema(description = "메모 ID", example = "3") private Long memoId; + @Schema(description = "메모 제목", example = "메모 제목") + private String title; + @Schema(description = "메모 내용", example = "메모 내용") private String content; @@ -34,6 +37,7 @@ public class MemoDetailResponseDTO { public static MemoDetailResponseDTO from(Memo memo) { return MemoDetailResponseDTO.builder() .memoId(memo.getId()) + .title(memo.getTitle()) .content(memo.getContent()) .createdDate(memo.getCreatedAt().toLocalDate()) .createdTime(memo.getCreatedAt().toLocalTime()) From 2e218f98437711d2b7ecdaa2e5978c1b49c065ab Mon Sep 17 00:00:00 2001 From: dong99u Date: Sat, 9 Aug 2025 14:13:48 +0900 Subject: [PATCH 2/3] [REFACTOR] Remove redundant `@ApiResponses` annotations from controllers in Memo and Habit domains --- .../habit/controller/HabitController.java | 194 +----------------- .../memo/controller/MemoController.java | 87 -------- 2 files changed, 1 insertion(+), 280 deletions(-) diff --git a/src/main/java/com/indayvidual/server/domain/habit/controller/HabitController.java b/src/main/java/com/indayvidual/server/domain/habit/controller/HabitController.java index 61dd1a7..6cba1d6 100644 --- a/src/main/java/com/indayvidual/server/domain/habit/controller/HabitController.java +++ b/src/main/java/com/indayvidual/server/domain/habit/controller/HabitController.java @@ -30,9 +30,6 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import jakarta.validation.constraints.PastOrPresent; @@ -53,25 +50,6 @@ public class HabitController { summary = "습관 목록 조회 (무한 스크롤)", description = "생성일자 기준으로 내림차순 정렬된 습관 목록을 페이지네이션으로 조회합니다. 각 습관의 오늘 체크 여부도 함께 반환됩니다." ) - @ApiResponses(value = { - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "200", - description = "습관 목록 조회 성공", - content = @Content(schema = @Schema(implementation = HabitSliceResponseDTO.class)) - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "400", - description = "잘못된 요청 파라미터" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "401", - description = "인증 실패" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "500", - description = "서버 내부 오류" - ) - }) public ApiResponse getHabits( @Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(required = false, defaultValue = "0") Integer page, @@ -88,29 +66,6 @@ public ApiResponse getHabits( summary = "습관 생성", description = "새로운 습관을 생성합니다. 습관 이름과 색상 코드를 입력받아 저장합니다." ) - @ApiResponses(value = { - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "200", - description = "습관 생성 성공", - content = @Content(schema = @Schema(implementation = HabitResponseDTO.class)) - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "400", - description = "잘못된 요청 데이터 (필수 필드 누락, 유효성 검증 실패 등)" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "401", - description = "인증 실패" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "409", - description = "동일한 이름의 습관이 이미 존재함" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "500", - description = "서버 내부 오류" - ) - }) public ApiResponse createHabit( @Valid @RequestBody CreateHabitRequestDTO request ) { @@ -123,47 +78,11 @@ public ApiResponse createHabit( summary = "습관 수정", description = "기존 습관의 정보를 수정합니다. 본인이 생성한 습관만 수정 가능합니다." ) - @ApiResponses(value = { - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "200", - description = "습관 수정 성공", - content = @Content(schema = @Schema(implementation = HabitResponseDTO.class)) - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "400", - description = "잘못된 요청 데이터 (유효성 검증 실패 등)" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "401", - description = "인증 실패" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "403", - description = "권한 없음 (다른 사용자의 습관 수정 시도)" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "404", - description = "습관을 찾을 수 없음" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "409", - description = "변경하려는 이름의 습관이 이미 존재함" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "500", - description = "서버 내부 오류" - ) - }) public ApiResponse updateHabit( @Parameter(description = "습관 ID", required = true, example = "1") @PathVariable Long habitId, - @io.swagger.v3.oas.annotations.parameters.RequestBody( - description = "습관 수정 요청 데이터", - required = true, - content = @Content(schema = @Schema(implementation = UpdateHabitRequestDTO.class)) - ) @RequestBody UpdateHabitRequestDTO request ) { Long userId = Utils.getUserId(); @@ -175,29 +94,6 @@ public ApiResponse updateHabit( summary = "습관 삭제", description = "특정 습관을 삭제합니다. 본인이 생성한 습관만 삭제 가능하며, 관련된 모든 체크 기록도 함께 삭제됩니다." ) - @ApiResponses(value = { - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "200", - description = "습관 삭제 성공", - content = @Content(schema = @Schema(implementation = Void.class)) - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "401", - description = "인증 실패" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "403", - description = "권한 없음 (다른 사용자의 습관 삭제 시도)" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "404", - description = "습관을 찾을 수 없음" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "500", - description = "서버 내부 오류" - ) - }) public ApiResponse deleteHabit( @Parameter(description = "습관 ID", required = true, example = "1") @PathVariable Long habitId @@ -211,42 +107,11 @@ public ApiResponse deleteHabit( summary = "습관 체크 상태 토글", description = "특정 날짜의 습관 체크 상태를 토글합니다. 체크되지 않은 상태면 체크하고, 체크된 상태면 체크를 해제합니다." ) - @ApiResponses(value = { - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "200", - description = "습관 체크 상태 토글 성공", - content = @Content(schema = @Schema(implementation = HabitResponseDTO.class)) - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "400", - description = "잘못된 요청 데이터 (유효성 검증 실패, 미래 날짜 등)" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "401", - description = "인증 실패" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "403", - description = "권한 없음 (다른 사용자의 습관 체크 시도)" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "404", - description = "습관을 찾을 수 없음" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "500", - description = "서버 내부 오류" - ) - }) public ApiResponse updateHabitCheck( + @Parameter(description = "습관 ID", required = true, example = "1") @PathVariable Long habitId, - @io.swagger.v3.oas.annotations.parameters.RequestBody( - description = "습관 체크 토글 요청 데이터", - required = true, - content = @Content(schema = @Schema(implementation = ToggleCheckRequestDTO.class)) - ) @Valid @RequestBody ToggleCheckRequestDTO request ) { Long userId = Utils.getUserId(); @@ -258,25 +123,6 @@ public ApiResponse updateHabitCheck( summary = "특정 날짜 습관 체크 상태 조회", description = "특정 날짜에 대한 모든 습관의 체크 상태를 조회합니다. 각 습관별로 해당 날짜에 체크되었는지 여부를 반환합니다." ) - @ApiResponses(value = { - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "200", - description = "일일 습관 체크 상태 조회 성공", - content = @Content(schema = @Schema(implementation = HabitResponseDTO.class)) - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "400", - description = "잘못된 요청 파라미터 (미래 날짜, 잘못된 날짜 형식 등)" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "401", - description = "인증 실패" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "500", - description = "서버 내부 오류" - ) - }) public ApiResponse> getDailyHabitCheckedState( @Parameter(description = "조회할 날짜 (과거 또는 오늘만 가능)", required = true, example = "2025-01-01") @RequestParam @PastOrPresent LocalDate date @@ -290,25 +136,6 @@ public ApiResponse> getDailyHabitCheckedState( summary = "주간 습관 체크 현황 조회", description = "지정된 시작 날짜부터 7일간의 습관 체크 현황을 조회합니다. 각 습관별로 주간 체크 패턴을 확인할 수 있습니다." ) - @ApiResponses(value = { - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "200", - description = "주간 습관 체크 현황 조회 성공", - content = @Content(schema = @Schema(implementation = HabitWeeklyChecksResponseDTO.class)) - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "400", - description = "잘못된 요청 파라미터 (잘못된 날짜 형식 등)" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "401", - description = "인증 실패" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "500", - description = "서버 내부 오류" - ) - }) public ApiResponse> getWeeklyChecks( @Parameter(description = "주간 조회 시작 날짜", required = true, example = "2025-01-01") @RequestParam LocalDate startDate @@ -322,25 +149,6 @@ public ApiResponse> getWeeklyChecks( summary = "월간 습관 체크 현황 조회", description = "지정된 월의 습관 체크 현황을 조회합니다. 각 습관별로 월간 체크 패턴과 통계를 확인할 수 있습니다." ) - @ApiResponses(value = { - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "200", - description = "월간 습관 체크 현황 조회 성공", - content = @Content(schema = @Schema(implementation = HabitMonthlyChecksResponseDTO.class)) - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "400", - description = "잘못된 요청 파라미터 (잘못된 년월 형식 등)" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "401", - description = "인증 실패" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "500", - description = "서버 내부 오류" - ) - }) public ApiResponse> getMonthlyChecks( @Parameter(description = "조회할 년월 (yyyy-MM 형식)", required = true, example = "2025-01") @RequestParam diff --git a/src/main/java/com/indayvidual/server/domain/memo/controller/MemoController.java b/src/main/java/com/indayvidual/server/domain/memo/controller/MemoController.java index a5138ba..ef315b7 100644 --- a/src/main/java/com/indayvidual/server/domain/memo/controller/MemoController.java +++ b/src/main/java/com/indayvidual/server/domain/memo/controller/MemoController.java @@ -21,9 +21,6 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -42,25 +39,6 @@ public class MemoController { summary = "메모 목록 조회 (무한 스크롤)", description = "생성일자 또는 수정일자 기준으로 내림차순 정렬된 메모 목록을 페이지네이션으로 조회합니다." ) - @ApiResponses(value = { - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "200", - description = "메모 목록 조회 성공", - content = @Content(schema = @Schema(implementation = MemoSliceResponseDTO.class)) - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "400", - description = "잘못된 요청 파라미터" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "401", - description = "인증 실패" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "500", - description = "서버 내부 오류" - ) - }) public ApiResponse getMemos( @Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(required = false, defaultValue = "0") Integer page, @@ -77,29 +55,6 @@ public ApiResponse getMemos( summary = "메모 상세 조회", description = "특정 메모의 상세 정보를 조회합니다. 본인이 작성한 메모만 조회 가능합니다." ) - @ApiResponses(value = { - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "200", - description = "메모 상세 조회 성공", - content = @Content(schema = @Schema(implementation = MemoDetailResponseDTO.class)) - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "401", - description = "인증 실패" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "403", - description = "권한 없음 (다른 사용자의 메모에 접근 시도)" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "404", - description = "메모를 찾을 수 없음" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "500", - description = "서버 내부 오류" - ) - }) public ApiResponse getMemoDetail( @Parameter(description = "메모 ID", required = true, example = "1") @PathVariable Long memoId @@ -128,29 +83,6 @@ public ApiResponse updateMemo( summary = "메모 삭제", description = "특정 메모를 삭제합니다. 본인이 작성한 메모만 삭제 가능합니다." ) - @ApiResponses(value = { - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "200", - description = "메모 삭제 성공", - content = @Content(schema = @Schema(implementation = Void.class)) - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "401", - description = "인증 실패" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "403", - description = "권한 없음 (다른 사용자의 메모 삭제 시도)" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "404", - description = "메모를 찾을 수 없음" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "500", - description = "서버 내부 오류" - ) - }) public ApiResponse deleteMemo( @Parameter(description = "메모 ID", required = true, example = "1") @PathVariable Long memoId @@ -164,25 +96,6 @@ public ApiResponse deleteMemo( summary = "메모 생성", description = "새로운 메모를 생성합니다. 제목과 내용을 입력받아 메모를 저장합니다." ) - @ApiResponses(value = { - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "200", - description = "메모 생성 성공", - content = @Content(schema = @Schema(implementation = Void.class)) - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "400", - description = "잘못된 요청 데이터 (필수 필드 누락, 유효성 검증 실패 등)" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "401", - description = "인증 실패" - ), - @io.swagger.v3.oas.annotations.responses.ApiResponse( - responseCode = "500", - description = "서버 내부 오류" - ) - }) public ApiResponse createMemo( @RequestBody @Valid CreateMemoRequestDTO request ) { From e34d1e9622823b5ff2d25d7cb2f4afea76a50cd7 Mon Sep 17 00:00:00 2001 From: dong99u Date: Sat, 9 Aug 2025 14:20:55 +0900 Subject: [PATCH 3/3] [REFACTOR] Update `updateCheck` method in `HabitLog` to accept `checkedAt` parameter - Modified `Habit.updateHabitLog` to pass `checkDate` to `updateCheck`. --- .../com/indayvidual/server/domain/habit/entity/Habit.java | 2 +- .../indayvidual/server/domain/habitlog/entity/HabitLog.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/indayvidual/server/domain/habit/entity/Habit.java b/src/main/java/com/indayvidual/server/domain/habit/entity/Habit.java index df54808..b497503 100644 --- a/src/main/java/com/indayvidual/server/domain/habit/entity/Habit.java +++ b/src/main/java/com/indayvidual/server/domain/habit/entity/Habit.java @@ -134,7 +134,7 @@ public void updateHabitCheck(User user, LocalDate checkDate, Boolean checked) { } // 상태 업데이트 - targetLog.updateCheck(checked); + targetLog.updateCheck(checked, checkDate); } } diff --git a/src/main/java/com/indayvidual/server/domain/habitlog/entity/HabitLog.java b/src/main/java/com/indayvidual/server/domain/habitlog/entity/HabitLog.java index 9078797..f9080bf 100644 --- a/src/main/java/com/indayvidual/server/domain/habitlog/entity/HabitLog.java +++ b/src/main/java/com/indayvidual/server/domain/habitlog/entity/HabitLog.java @@ -59,8 +59,8 @@ public static void createHabitLog(Habit habit) { } //== 더티체킹 메서드 ==// - public void updateCheck(Boolean isChecked) { + public void updateCheck(Boolean isChecked, LocalDate checkedAt) { this.isChecked = isChecked; - this.checkedAt = isChecked ? LocalDate.now() : null; + this.checkedAt = checkedAt; } }