Skip to content

Commit

Permalink
Merge pull request #222 from Make-A-Wish-Sopt/feature/jiyoung-#221-de…
Browse files Browse the repository at this point in the history
…velop

[FIX] 에러 메세지 수정
  • Loading branch information
wlwpfh authored Jan 15, 2025
2 parents 71575ea + 3a2b412 commit c32b570
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import static com.sopterm.makeawish.common.message.ErrorMessage.NOT_VALID_USER_ACCOUNT;
import static com.sopterm.makeawish.common.message.ErrorMessage.NO_EXIST_USER_ACCOUNT;
import static com.sopterm.makeawish.common.message.SuccessMessage.*;
import static java.util.Objects.nonNull;
Expand All @@ -30,7 +29,7 @@ public class UserController {

private final UserService userService;
private final AbuseService abuseService;
private static final int VERIFY_ACCOUNT_SUCCESS = 0;
private static final String VERIFY_ACCOUNT_SUCCESS = "100";

@Operation(summary = "유저 계좌 정보 가져오기")
@GetMapping("/account")
Expand Down Expand Up @@ -69,9 +68,9 @@ public ResponseEntity<ApiResponse> checkAccountInformation(
@Parameter(hidden = true) @AuthenticationPrincipal InternalMemberDetails memberDetails,
@RequestBody UserAccountVerifyRequestDTO verifyRequestDTO) throws Exception {
val response = userService.verifyUserAccount(memberDetails.getId(), verifyRequestDTO);
return response == VERIFY_ACCOUNT_SUCCESS
return response.getResult().equals(VERIFY_ACCOUNT_SUCCESS)
? ResponseEntity.ok(ApiResponse.success(SUCCESS_VERIFY_USER_ACCOUNT.getMessage()))
: ResponseEntity.ok(ApiResponse.fail(NOT_VALID_USER_ACCOUNT.getMessage(), response));
: ResponseEntity.ok(ApiResponse.fail(response.getResultMessage()));
}

@Operation(summary = "어뷰징 유저 확인")
Expand Down
31 changes: 16 additions & 15 deletions src/main/java/com/sopterm/makeawish/service/UserService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sopterm.makeawish.service;

import com.popbill.api.AccountCheckInfo;
import com.popbill.api.AccountCheckService;
import com.popbill.api.PopbillException;
import com.sopterm.makeawish.domain.abuse.AbuseLog;
Expand All @@ -18,6 +19,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

import static com.sopterm.makeawish.common.message.ErrorMessage.INVALID_USER;
import static com.sopterm.makeawish.common.message.ErrorMessage.NO_EXIST_USER_ACCOUNT;
import static java.util.Objects.isNull;
Expand All @@ -36,7 +39,7 @@ public class UserService {

@Value("${popbill.businessNumber}")
private String corpNum;
private static final int ABUSE_CAUTION_COUNT = 4;
private static final List<String> USER_FAIL_CODE = List.of("300", "301", "400", "801", "898", "899");

public UserAccountResponseDTO getUserAccount(Long userId) {
val wisher = getUser(userId);
Expand Down Expand Up @@ -69,21 +72,19 @@ private User getUser(Long userId) {
}

@Transactional
public Integer verifyUserAccount(Long userId, UserAccountVerifyRequestDTO verifyRequestDTO) throws PopbillException {
public AccountCheckInfo verifyUserAccount(Long userId, UserAccountVerifyRequestDTO verifyRequestDTO) throws PopbillException {
abuseService.checkAbuseUser(userId);
var response = 0;
try {
val accountInfo = accountCheckService.CheckAccountInfo(corpNum, verifyRequestDTO.BankCode(), verifyRequestDTO.AccountNumber());
if (!verifyRequestDTO.name().equals(accountInfo.getAccountName())) {
val abuseLog = AbuseLog.builder()
.user(getUser(userId))
.build();
abuseService.createAbuseLog(abuseLog);
response = abuseService.countAbuseLogByUser(userId);
}
} catch (PopbillException e) {
throw new PopbillException(e.getCode(), e.getMessage());
val accountInfo = accountCheckService.CheckAccountInfo(corpNum, verifyRequestDTO.BankCode(), verifyRequestDTO.AccountNumber());
if (checkIsUserFail(accountInfo.getResult())) {
val abuseLog = AbuseLog.builder()
.user(getUser(userId))
.build();
abuseService.createAbuseLog(abuseLog);
}
return response;
return accountInfo;
}

private boolean checkIsUserFail(String result) {
return USER_FAIL_CODE.contains(result);
}
}

0 comments on commit c32b570

Please sign in to comment.