diff --git a/src/main/java/com/fav/daengnyang/domain/account/controller/AccountController.java b/src/main/java/com/fav/daengnyang/domain/account/controller/AccountController.java index a686f88..f2f9597 100644 --- a/src/main/java/com/fav/daengnyang/domain/account/controller/AccountController.java +++ b/src/main/java/com/fav/daengnyang/domain/account/controller/AccountController.java @@ -17,6 +17,7 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; +import java.util.HashMap; import java.util.List; @RestController @@ -84,4 +85,11 @@ public ResponseEntity> creatAccountC AccountCreateColorResponse response = accountService.createColorAccount(request, memberPrincipal.getMemberId()); return ResponseEntity.ok(SuccessResponse.ok(response)); } + + @GetMapping("/name") + public SuccessResponse getRandomName(){ + HashMap name = accountService.getRandomName(); + + return SuccessResponse.ok(name); + } } \ No newline at end of file diff --git a/src/main/java/com/fav/daengnyang/domain/account/service/AccountService.java b/src/main/java/com/fav/daengnyang/domain/account/service/AccountService.java index 93e94bd..0f55dcd 100644 --- a/src/main/java/com/fav/daengnyang/domain/account/service/AccountService.java +++ b/src/main/java/com/fav/daengnyang/domain/account/service/AccountService.java @@ -59,13 +59,34 @@ public class AccountService { @Value("${api.key}") private String apiKey; + private final List names = Arrays.asList( + "김민준", "이서준", "박지훈", "최성민", "정우진", + "강현우", "조준호", "임태현", "오진우", "윤경민", + "허시우", "송유진", "문재현", "장도현", "이기찬", + "김남준", "김주원", "박원빈", "김한결", "오병호", + "이승현", "김서연", "이지민", "박수빈", "최유진", + "정예린", "강은지", "조수아", "임하늘", "오지아", + "윤나연", "허민지", "송경희", "문진아", "장현정", + "이소희", "김가연", "김유나", "박소연", "최세진", + "김하은", "유서하" + ); + private final Random random = new Random(); private final List categories = initializeCategories(); + public HashMap getRandomName() { + int index = random.nextInt(names.size()); + HashMap data = new HashMap<>(); + data.put("name", names.get(index)); + return data; + } + + private List initializeCategories() { List categoryList = new ArrayList<>(); - for (int i = 0; i < 4; i++) categoryList.add("식비"); + for (int i = 0; i < 3; i++) categoryList.add("식비"); for (int i = 0; i < 2; i++) categoryList.add("교통"); - for (int i = 0; i < 3; i++) categoryList.add("쇼핑"); + for (int i = 0; i < 2; i++) categoryList.add("쇼핑"); + for (int i = 0; i < 1; i++) categoryList.add("반려"); categoryList.add("기타"); return categoryList; } @@ -179,11 +200,11 @@ public void transferMoney(MemberPrincipal memberPrincipal, TransferRequest trans String transferNo = callTransferMoney(member.getDepositAccount(), memberPrincipal.getUserKey(), transferRequest); // 2. 메모하기 log.info("transferNo: {}", transferNo); - transactionService.makeMemo(member.getDepositAccount(), transferNo, setMemoCategory(), memberPrincipal.getUserKey()); + String memo = transferRequest.getName() + "," + setMemoCategory(); + transactionService.makeMemo(member.getDepositAccount(), transferNo, memo, memberPrincipal.getUserKey()); } private String setMemoCategory(){ - Random random = new Random(); int index = random.nextInt(categories.size()); return categories.get(index); } @@ -196,7 +217,7 @@ private String callTransferMoney(String accountNo, String userKey, TransferReque body.put("Header", header); body.put("accountNo", accountNo); body.put("transactionBalance", transferRequest.getAmount()); - body.put("transferSummary", "출금"); + body.put("transactionSummary", "출금"); // 2. HttpHeaders 설정 HttpHeaders headers = new HttpHeaders(); diff --git a/src/main/java/com/fav/daengnyang/domain/account/service/dto/request/TransferRequest.java b/src/main/java/com/fav/daengnyang/domain/account/service/dto/request/TransferRequest.java index d97dd82..03e8da6 100644 --- a/src/main/java/com/fav/daengnyang/domain/account/service/dto/request/TransferRequest.java +++ b/src/main/java/com/fav/daengnyang/domain/account/service/dto/request/TransferRequest.java @@ -16,4 +16,6 @@ public class TransferRequest { private String account; @NotNull private Long amount; + @NotBlank + private String name; } diff --git a/src/main/java/com/fav/daengnyang/domain/targetDetail/service/TargetDetailService.java b/src/main/java/com/fav/daengnyang/domain/targetDetail/service/TargetDetailService.java index 7553bae..6d71948 100644 --- a/src/main/java/com/fav/daengnyang/domain/targetDetail/service/TargetDetailService.java +++ b/src/main/java/com/fav/daengnyang/domain/targetDetail/service/TargetDetailService.java @@ -65,6 +65,8 @@ private void extractTransactionDetails(String accountNo, String userKey, Transac // 각 거래 항목의 세부 정보를 리스트에 추가 for (Map transaction : transactionList) { + String name = ((String) transaction.get("transactionMemo")).split(",")[0]; + TransactionDetailResponse detail = TransactionDetailResponse.builder() .transactionUniqueNo(Long.valueOf((String) transaction.get("transactionUniqueNo"))) .transactionDate((String) transaction.get("transactionDate")) @@ -72,7 +74,7 @@ private void extractTransactionDetails(String accountNo, String userKey, Transac .transactionBalance(Long.valueOf(transaction.get("transactionBalance").toString())) .transactionAfterBalance(Long.valueOf(transaction.get("transactionAfterBalance").toString())) .transactionSummary((String) transaction.get("transactionSummary")) - .transactionMemo((String) transaction.get("transactionMemo")) + .transactionMemo(name) .build(); transactionDetails.add(detail); }