Skip to content

Commit

Permalink
feat : 해당 유저의 관심 정책 및 수혜 정책의 총 크기 조회 API 추가
Browse files Browse the repository at this point in the history
LHS-11 committed Nov 9, 2023
1 parent 71c117d commit a6c8342
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -79,5 +79,33 @@ public CommonResponse<String> deleteApplyPolicy(@AuthUser User user, @PathVariab
userPolicyService.deleteApplyPolicy(user, policyId);
return CommonResponse.success(null);
}

@DeleteMapping("/all")
@Operation(summary = "총 관심 정책 삭제 API", description = "해당 유저의 총 관심 정책을 삭제할 때 사용합니다.")
public CommonResponse<String> deleteAllInterestPolicy(@AuthUser User user) {
userPolicyService.deleteAllInterestPolicy(user);
return CommonResponse.success(null);
}

@DeleteMapping("/apply/all")
@Operation(summary = "총 수혜(신청) 정책 삭제 API", description = "해당 유저의 총 신청 정책을 삭제할 때 사용합니다.")
public CommonResponse<String> deleteAllApplyPolicy(@AuthUser User user) {
userPolicyService.deleteAllApplyPolicy(user);
return CommonResponse.success(null);
}

@GetMapping("/size")
@Operation(summary = "총 관심 정책의 크기 조회 API", description = "해당 유저가 관심 신청 정책 크기를 조회할 때 사용합니다.")
public CommonResponse<PolicySizeResponseDto> getAllInterestPolicySize(@AuthUser User user) {
PolicySizeResponseDto result = userPolicyService.getAllInterestPolicySize(user);
return CommonResponse.success(result);
}

@GetMapping("/apply/size")
@Operation(summary = "총 수혜(신청) 정책 크기 조회 API", description = "해당 유저가 수혜하는 정책 크기를 조회할 때 사용합니다.")
public CommonResponse<PolicySizeResponseDto> getAllApplyPolicySize(@AuthUser User user) {
PolicySizeResponseDto result = userPolicyService.getAllApplyPolicySize(user);
return CommonResponse.success(result);
}
}

Original file line number Diff line number Diff line change
@@ -160,4 +160,24 @@ public void deleteApplyPolicy(User user, Long policyId) {
}

}

public void deleteAllInterestPolicy(User user) {
userPolicyRepository.deleteAllByUserAndInterestFlag(user, true);
}

public void deleteAllApplyPolicy(User user) {
userPolicyRepository.deleteAllByUserAndApplyFlag(user, true);
}

public PolicySizeResponseDto getAllInterestPolicySize(User user) {
return PolicySizeResponseDto.builder()
.size(userPolicyRepository.getInterestPolicyCount(user.getUserId()))
.build();
}

public PolicySizeResponseDto getAllApplyPolicySize(User user) {
return PolicySizeResponseDto.builder()
.size(userPolicyRepository.getApplyPolicyCount(user.getUserId()))
.build();
}
}

0 comments on commit a6c8342

Please sign in to comment.