Skip to content

Commit 58a6659

Browse files
authored
Merge pull request #27 from YAPP-Github/feat/T3-111
[T3-111] 선택한 요일(당일)만 루틴 삭제
2 parents 2332ca4 + 9b53410 commit 58a6659

18 files changed

Lines changed: 246 additions & 44 deletions

src/main/java/bitnagil/bitnagil_backend/auth/jwt/JwtAccessDeniedHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.fasterxml.jackson.databind.ObjectMapper;
1313

1414
import bitnagil.bitnagil_backend.global.response.CustomResponseDto;
15+
import bitnagil.bitnagil_backend.global.response.ErrorResponseDto;
1516
import jakarta.servlet.http.HttpServletRequest;
1617
import jakarta.servlet.http.HttpServletResponse;
1718
import lombok.RequiredArgsConstructor;
@@ -37,8 +38,7 @@ public void handle(HttpServletRequest request, HttpServletResponse response,
3738
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
3839
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
3940

40-
CustomResponseDto<String> errorResponse = CustomResponseDto.from(ErrorCode.FORBIDDEN_USER,
41-
accessDeniedException.getMessage());
41+
ErrorResponseDto errorResponse = ErrorResponseDto.from(ErrorCode.FORBIDDEN_USER);
4242
objectMapper.writeValue(response.getWriter(), errorResponse);
4343
}
4444
}

src/main/java/bitnagil/bitnagil_backend/auth/jwt/JwtAuthenticationEntryPoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.fasterxml.jackson.databind.ObjectMapper;
1313

1414
import bitnagil.bitnagil_backend.global.response.CustomResponseDto;
15+
import bitnagil.bitnagil_backend.global.response.ErrorResponseDto;
1516
import jakarta.servlet.http.HttpServletRequest;
1617
import jakarta.servlet.http.HttpServletResponse;
1718
import lombok.RequiredArgsConstructor;
@@ -37,8 +38,7 @@ public void commence(HttpServletRequest request, HttpServletResponse response,
3738
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
3839
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
3940

40-
CustomResponseDto<String> errorResponse = CustomResponseDto.from(ErrorCode.UNAUTHENTICATED_USER,
41-
authException.getMessage());
41+
ErrorResponseDto errorResponse = ErrorResponseDto.from(ErrorCode.UNAUTHENTICATED_USER);
4242
objectMapper.writeValue(response.getWriter(), errorResponse);
4343
}
4444
}

src/main/java/bitnagil/bitnagil_backend/enums/Role.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
public enum Role implements EnumType {
77

88
GUEST("ROLE_GUEST"),
9-
USER("ROLE_USER");
9+
USER("ROLE_USER"),
10+
WITHDRAWN("ROLE_WITHDRAWN");
1011

1112
private final String description;
1213

src/main/java/bitnagil/bitnagil_backend/global/errorcode/ErrorCode.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ public enum ErrorCode {
6868
NOT_FOUND_CHANGED_SUB_ROUTINE("CSR001", HttpStatus.NOT_FOUND, "존재하지 않는 변경 서브루틴입니다."),
6969
CHANGED_SUB_ROUTINE_USER_NOT_MATCHED("CSR002", HttpStatus.FORBIDDEN, "변경 서브루틴의 유저 정보와 로그인 유저 정보가 일치하지 않습니다."),
7070

71-
// 루틴 타입 관련 에러 코드
71+
// 루틴 완료 여부 관련 에러 코드
72+
ROUTINE_ID_MISMATCH("RC001", HttpStatus.BAD_REQUEST, "루틴 완료 여부 테이블에서 조회된 routineId와 요청받은 routineId가 다릅니다."),
73+
NOT_FOUND_ROUTINE_COMPLETION("RC002", HttpStatus.NOT_FOUND, "루틴 완료 여부 데이터를 찾을 수 없습니다."),
7274

7375
// 온보딩 관련 에러 코드
7476
NOT_FOUND_RECOMMENDED_ROUTINE("ON000", HttpStatus.NOT_FOUND, "조건에 맞는 추천 루틴을 찾을 수 없습니다."),

src/main/java/bitnagil/bitnagil_backend/routine/controller/RoutineController.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.UUID;
55

66
import bitnagil.bitnagil_backend.routine.domain.enums.RoutineType;
7+
import bitnagil.bitnagil_backend.routine.request.DeleteRoutineByDayRequest;
78
import bitnagil.bitnagil_backend.routine.request.UpdateRoutineCompletionRequest;
89
import jakarta.validation.constraints.NotNull;
910

@@ -59,6 +60,17 @@ public CustomResponseDto<Object> deleteRoutine(@CurrentUser User user, @PathVari
5960
return CustomResponseDto.from(null);
6061
}
6162

63+
/*
64+
* 유저가 선택한 요일(당일)만 삭제하는 API입니다.
65+
*/
66+
@DeleteMapping("/day")
67+
public CustomResponseDto<Object> deleteRoutineByDay(@CurrentUser User user,
68+
@RequestBody DeleteRoutineByDayRequest deleteRoutineByDayRequest) {
69+
routineService.deleteRoutineByDay(user, deleteRoutineByDayRequest);
70+
71+
return CustomResponseDto.from(null);
72+
}
73+
6274
/**
6375
* 회원이 보유한 특정 기간(start_date, end_date)의 루틴을 조회하는 API입니다.
6476
*/

src/main/java/bitnagil/bitnagil_backend/routine/controller/spec/RoutineSpec.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
import java.time.LocalDate;
44
import java.util.UUID;
55

6+
import org.springframework.web.bind.annotation.RequestBody;
7+
8+
import bitnagil.bitnagil_backend.global.annotation.CurrentUser;
69
import bitnagil.bitnagil_backend.global.errorcode.ErrorCode;
710
import bitnagil.bitnagil_backend.global.response.CustomResponseDto;
811
import bitnagil.bitnagil_backend.global.swagger.ApiErrorCodeExamples;
912
import bitnagil.bitnagil_backend.global.swagger.ApiTags;
13+
import bitnagil.bitnagil_backend.routine.request.DeleteRoutineByDayRequest;
1014
import bitnagil.bitnagil_backend.routine.request.RegisterRoutineRequest;
1115
import bitnagil.bitnagil_backend.routine.request.UpdateRoutineCompletionRequest;
1216
import bitnagil.bitnagil_backend.routine.request.UpdateRoutineRequest;
@@ -42,6 +46,16 @@ public interface RoutineSpec {
4246
CustomResponseDto<Object> deleteRoutine(User user, UUID routineId);
4347

4448
@Operation(summary = "여러 루틴의 완료 여부를 갱신합니다.")
49+
@ApiErrorCodeExamples({
50+
ErrorCode.NOT_FOUND_ROUTINE, ErrorCode.ROUTINE_USER_NOT_MATCHED,
51+
ErrorCode.NOT_FOUND_SUB_ROUTINE, ErrorCode.SUB_ROUTINE_USER_NOT_MATCHED,
52+
ErrorCode.NOT_FOUND_CHANGED_ROUTINE, ErrorCode.CHANGED_ROUTINE_USER_NOT_MATCHED,
53+
ErrorCode.NOT_FOUND_CHANGED_SUB_ROUTINE, ErrorCode.CHANGED_SUB_ROUTINE_USER_NOT_MATCHED
54+
})
4555
CustomResponseDto<Object> updateRoutineCompletionStatus(User user,
4656
UpdateRoutineCompletionRequest updateRoutineCompletionRequest);
57+
58+
@Operation(summary = "선택한 요일(당일)만 루틴을 삭제합니다.")
59+
@ApiErrorCodeExamples({ErrorCode.NOT_FOUND_ROUTINE, ErrorCode.ROUTINE_USER_NOT_MATCHED})
60+
CustomResponseDto<Object> deleteRoutineByDay(User user, DeleteRoutineByDayRequest deleteRoutineByDayRequest);
4761
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
package bitnagil.bitnagil_backend.routine.repository;
22

3+
import java.time.LocalDate;
4+
import java.util.Optional;
35
import java.util.UUID;
46

57
import org.springframework.data.jpa.repository.JpaRepository;
68

7-
import bitnagil.bitnagil_backend.global.entity.HistoryPk;
89
import bitnagil.bitnagil_backend.routine.domain.RoutineCompletion;
910
import bitnagil.bitnagil_backend.routine.domain.enums.RoutineType;
1011

11-
public interface RoutineCompletionRepository extends JpaRepository<RoutineCompletion, HistoryPk> {
12+
public interface RoutineCompletionRepository extends JpaRepository<RoutineCompletion, Long> {
1213

1314
RoutineCompletion findByRoutineIdAndRoutineHistorySeqAndRoutineType(
1415
UUID routineId, Long routineHistorySeq, RoutineType routineType);
16+
17+
Optional<RoutineCompletion> findByPerformedDateAndRoutineIdAndRoutineHistorySeqAndRoutineType(
18+
LocalDate performedDate, UUID routineId, Long routineHistorySeq, RoutineType routineType);
1519
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package bitnagil.bitnagil_backend.routine.request;
2+
3+
import java.time.LocalDate;
4+
import java.util.List;
5+
import java.util.UUID;
6+
7+
import io.swagger.v3.oas.annotations.media.Schema;
8+
import jakarta.validation.constraints.NotNull;
9+
import lombok.Getter;
10+
import lombok.NoArgsConstructor;
11+
12+
@Getter
13+
@NoArgsConstructor
14+
@Schema(description = "선택한 요일(당일)만 루틴 삭제 DTO")
15+
public class DeleteRoutineByDayRequest {
16+
17+
@Schema(description = "루틴완료 여부 ID입니다. 해당 값이 없는 경우에는 null로 보내주세요.",
18+
example = "1")
19+
private Long routineCompletionId;
20+
21+
@Schema(description = "루틴의 ID 값입니다.",
22+
example = "4fa85f64-5717-4562-b3fc-2c963f66afa6",
23+
required = true)
24+
@NotNull
25+
private UUID routineId;
26+
27+
@Schema(description = "세부루틴 완료 여부 정보를 담은 리스트입니다.",
28+
example = "["
29+
+ "{\"routineCompletionId\": 3, \"subRoutineId\": \"4fa85f64-5717-4562-b3fc-2c963f66afa6\"},"
30+
+ "{\"routineCompletionId\": null, \"subRoutineId\": \"4fa85f64-5717-4562-b3fc-2c963f66afa6\"},"
31+
+ "{\"routineCompletionId\": 8, \"subRoutineId\": \"3e1e63bb-1e24-4e88-93e2-8ccd82215e08\"}"
32+
+ "]")
33+
private List<SubRoutineInfoForDelete> subRoutineInfosForDelete;
34+
35+
@Schema(description = "삭제할 루틴 수행 날짜입니다.",
36+
example = "2025-07-13",
37+
required = true)
38+
@NotNull
39+
private LocalDate performedDate;
40+
41+
@Schema(description = "루틴의 이력순번 값입니다.",
42+
example = "2",
43+
required = true)
44+
@NotNull
45+
private Long historySeq;
46+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package bitnagil.bitnagil_backend.routine.request;
2+
3+
import java.util.UUID;
4+
5+
import io.swagger.v3.oas.annotations.media.Schema;
6+
import jakarta.validation.constraints.NotNull;
7+
import lombok.Getter;
8+
import lombok.NoArgsConstructor;
9+
10+
/**
11+
* 선택한 요일(당일)만 삭제 API 요청 시 필요한 서브 루틴 완료에 대한 정보를 관리하는 클래스입니다.
12+
*/
13+
@Getter
14+
@NoArgsConstructor
15+
public class SubRoutineInfoForDelete {
16+
17+
@Schema(description = "세부루틴 완료 여부 ID입니다. 해당 값이 없는 경우에는 null로 보내주세요.")
18+
private Long routineCompletionId;
19+
20+
@Schema(description = "서브 루틴의 ID 값입니다.",
21+
example = "4fa85f64-5717-4562-b3fc-2c963f66afa6",
22+
required = true)
23+
@NotNull
24+
private UUID subRoutineId;
25+
}

src/main/java/bitnagil/bitnagil_backend/routine/request/UpdateRoutineCompletionRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public class UpdateRoutineCompletionRequest {
2626
"\"routineType\": \"CHANGED_SUB_ROUTINE\", " +
2727
"\"routineId\": \"4fa85f64-5717-4562-b3fc-2c963f66afa6\", " +
2828
"\"historySeq\": 2, " +
29-
"\"isCompleted\": false" +
29+
"\"completeYn\": false" +
3030
"}, " +
3131
"{" +
3232
"\"routineType\": \"ROUTINE\", " +
3333
"\"routineId\": \"123e4567-e89b-12d3-a456-426614174000\", " +
3434
"\"historySeq\": 1, " +
35-
"\"isCompleted\": true" +
35+
"\"completeYn\": true" +
3636
"}" +
3737
"]",
3838
required = true

0 commit comments

Comments
 (0)