diff --git a/backend/src/main/java/org/dgu/backend/common/constant/SuccessStatus.java b/backend/src/main/java/org/dgu/backend/common/constant/SuccessStatus.java index 5d22f5c..8e2a758 100644 --- a/backend/src/main/java/org/dgu/backend/common/constant/SuccessStatus.java +++ b/backend/src/main/java/org/dgu/backend/common/constant/SuccessStatus.java @@ -24,6 +24,7 @@ public enum SuccessStatus implements BaseCode { // User SUCCESS_LOGOUT(HttpStatus.OK, "200", "유저 로그아웃에 성공했습니다."), SUCCESS_ADD_AGREEMENT(HttpStatus.CREATED, "201", "서비스 약관 동의 여부 등록에 성공했습니다."), + SUCCESS_GET_AGREEMENT(HttpStatus.OK, "200", "서비스 약관 동의 여부 조회에 성공했습니다."), // Portfolio SUCCESS_GET_PORTFOLIOS(HttpStatus.OK, "200", "포트폴리오 조회에 성공했습니다."), SUCCESS_GET_PORTFOLIO_DETAILS(HttpStatus.OK, "200", "포트폴리오 상세 조회에 성공했습니다."), diff --git a/backend/src/main/java/org/dgu/backend/controller/UserController.java b/backend/src/main/java/org/dgu/backend/controller/UserController.java index 730d9ce..95ff3fe 100644 --- a/backend/src/main/java/org/dgu/backend/controller/UserController.java +++ b/backend/src/main/java/org/dgu/backend/controller/UserController.java @@ -32,4 +32,13 @@ public ResponseEntity> addUserAgreement( userService.addUserAgreement(authorizationHeader); return ApiResponse.onSuccess(SuccessStatus.SUCCESS_ADD_AGREEMENT); } + + // 서비스 약관 동의 여부 조회 API + @GetMapping("/agreement") + public ResponseEntity> getUserAgreement( + @RequestHeader("Authorization") String authorizationHeader) { + + UserDto.getUserAgreementResponse getUserAgreementResponse = userService.getUserAgreement(authorizationHeader); + return ApiResponse.onSuccess(SuccessStatus.SUCCESS_GET_AGREEMENT, getUserAgreementResponse); + } } \ No newline at end of file diff --git a/backend/src/main/java/org/dgu/backend/dto/UserDto.java b/backend/src/main/java/org/dgu/backend/dto/UserDto.java index c32025d..92f180e 100644 --- a/backend/src/main/java/org/dgu/backend/dto/UserDto.java +++ b/backend/src/main/java/org/dgu/backend/dto/UserDto.java @@ -6,6 +6,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; +import org.dgu.backend.domain.User; public class UserDto { @Builder @@ -17,4 +18,19 @@ public static class UserUpbitKeyRequest { private String accessKey; private String secretKey; } + + @Builder + @Getter + @AllArgsConstructor + @JsonNaming(value = PropertyNamingStrategies.SnakeCaseStrategy.class) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class getUserAgreementResponse { + private Boolean isAgree; + + public static UserDto.getUserAgreementResponse of(User user) { + return getUserAgreementResponse.builder() + .isAgree(user.getIsAgree()) + .build(); + } + } } \ No newline at end of file diff --git a/backend/src/main/java/org/dgu/backend/service/UserService.java b/backend/src/main/java/org/dgu/backend/service/UserService.java index 6ca9dde..6cf15eb 100644 --- a/backend/src/main/java/org/dgu/backend/service/UserService.java +++ b/backend/src/main/java/org/dgu/backend/service/UserService.java @@ -5,4 +5,5 @@ public interface UserService { void addUserUpbitKeys(String authorizationHeader, UserDto.UserUpbitKeyRequest userUpbitKeyRequest); void addUserAgreement(String authorizationHeader); + UserDto.getUserAgreementResponse getUserAgreement(String authorizationHeader); } \ No newline at end of file diff --git a/backend/src/main/java/org/dgu/backend/service/UserServiceImpl.java b/backend/src/main/java/org/dgu/backend/service/UserServiceImpl.java index 93016f5..23fd4f2 100644 --- a/backend/src/main/java/org/dgu/backend/service/UserServiceImpl.java +++ b/backend/src/main/java/org/dgu/backend/service/UserServiceImpl.java @@ -50,6 +50,13 @@ public void addUserAgreement(String authorizationHeader) { user.updateAgreement(); } + // 서비스 약관 동의 여부를 조회하는 메서드 + @Override + public UserDto.getUserAgreementResponse getUserAgreement(String authorizationHeader) { + User user = jwtUtil.getUserFromHeader(authorizationHeader); + return UserDto.getUserAgreementResponse.of(user); + } + // 암호화 및 인코딩 메서드 private String encryptAndEncode(String data, KeyPair keyPair) { byte[] encryptedData = encryptionUtil.encrypt(data.getBytes(), keyPair.getPublic());