Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] : 서비스 약관 동의 여부 조회 API 구현 (GET) #55

Merged
merged 3 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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", "포트폴리오 상세 조회에 성공했습니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,13 @@ public ResponseEntity<ApiResponse<Object>> addUserAgreement(
userService.addUserAgreement(authorizationHeader);
return ApiResponse.onSuccess(SuccessStatus.SUCCESS_ADD_AGREEMENT);
}

// 서비스 약관 동의 여부 조회 API
@GetMapping("/agreement")
public ResponseEntity<ApiResponse<UserDto.getUserAgreementResponse>> getUserAgreement(
@RequestHeader("Authorization") String authorizationHeader) {

UserDto.getUserAgreementResponse getUserAgreementResponse = userService.getUserAgreement(authorizationHeader);
return ApiResponse.onSuccess(SuccessStatus.SUCCESS_GET_AGREEMENT, getUserAgreementResponse);
}
}
16 changes: 16 additions & 0 deletions backend/src/main/java/org/dgu/backend/dto/UserDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.dgu.backend.domain.User;

public class UserDto {
@Builder
Expand All @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
public interface UserService {
void addUserUpbitKeys(String authorizationHeader, UserDto.UserUpbitKeyRequest userUpbitKeyRequest);
void addUserAgreement(String authorizationHeader);
UserDto.getUserAgreementResponse getUserAgreement(String authorizationHeader);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading