Skip to content

Commit

Permalink
Merge pull request #103 from Team-Daengnyang/feature/#101
Browse files Browse the repository at this point in the history
[FEAT] 계좌에 색상과 이미지 생성
  • Loading branch information
csb9427 authored Aug 28, 2024
2 parents 8fd2335 + 9971bbf commit 34f5f76
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fav.daengnyang.domain.account.service.AccountService;
import com.fav.daengnyang.domain.account.service.dto.request.AccountCreateColorRequest;
import com.fav.daengnyang.domain.account.service.dto.request.AccountCreateRequest;
import com.fav.daengnyang.domain.account.service.dto.request.ColorUpdateRequest;
import com.fav.daengnyang.domain.account.service.dto.response.AccountCreateColorResponse;
import com.fav.daengnyang.domain.account.service.dto.response.AccountCreateResponse;
import com.fav.daengnyang.domain.account.service.dto.response.AccountInfoResponse;
import com.fav.daengnyang.domain.account.service.dto.response.AccountResponse;
Expand Down Expand Up @@ -60,4 +62,11 @@ public ResponseEntity<SuccessResponse<AccountInfoResponse>> getAccountInfo(
AccountInfoResponse response = accountService.getAccountInfo(memberPrincipal.getMemberId(), memberPrincipal.getUserKey());
return ResponseEntity.ok(SuccessResponse.ok(response));
}
@PatchMapping("/create-color")
public ResponseEntity<SuccessResponse<AccountCreateColorResponse>> updateAccountColor(
@AuthenticationPrincipal MemberPrincipal memberPrincipal,
@RequestBody AccountCreateColorRequest request) {
AccountCreateColorResponse response = accountService.createColorAccount(request, memberPrincipal.getMemberId());
return ResponseEntity.ok(SuccessResponse.ok(response));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public class Account {
@Column(name = "account_color")
private String accountColor;

@Setter
@Column(name = "account_image")
private String accountImage;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id", nullable = false)
private Member member;
Expand All @@ -36,5 +40,4 @@ public Account(String accountTitle, String accountNumber, String accountColor, M
this.accountColor = accountColor;
this.member = member;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import com.fav.daengnyang.domain.account.entity.AccountCode;
import com.fav.daengnyang.domain.account.repository.AccountCodeRepository;
import com.fav.daengnyang.domain.account.repository.AccountRepository;
import com.fav.daengnyang.domain.account.service.dto.request.AccountCreateColorRequest;
import com.fav.daengnyang.domain.account.service.dto.request.AccountCreateRequest;
import com.fav.daengnyang.domain.account.service.dto.response.AccountCreateColorResponse;
import com.fav.daengnyang.domain.account.service.dto.response.AccountCreateResponse;
import com.fav.daengnyang.domain.account.service.dto.response.AccountInfoResponse;
import com.fav.daengnyang.domain.account.service.dto.response.AccountResponse;
Expand Down Expand Up @@ -363,4 +365,24 @@ private Map<String, Object> callInquireAccountBalanceApi(String accountNo, Strin
throw new RuntimeException("API 호출 오류: " + response.getBody());
}
}

public AccountCreateColorResponse createColorAccount(AccountCreateColorRequest request, Long memberId) {
// 1. 회원과 연결된 계좌 찾기
Account account = accountRepository.findByMemberId(memberId)
.orElseThrow(() -> new CustomException(ErrorCode.ACCOUNT_NOT_FOUND));

// 2. 계좌 색상 및 이미지 업데이트
account.setAccountColor(request.getAccountColor());
account.setAccountImage(request.getAccountImage());

// 3. 계좌 저장 (업데이트)
Account createdAccount = accountRepository.save(account);

// 4. 응답 데이터 생성
return AccountCreateColorResponse.builder()
.accountId(createdAccount.getAccountNumber())
.accountColor(createdAccount.getAccountColor())
.accountImage(createdAccount.getAccountImage())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.fav.daengnyang.domain.account.service.dto.request;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
public class AccountCreateColorRequest {
private String accountColor;
private String accountImage;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.fav.daengnyang.domain.account.service.dto.response;

import lombok.Builder;
import lombok.Data;
import lombok.Getter;

@Data
@Getter
@Builder
public class AccountCreateColorResponse {
private String accountId;
private String accountColor;
private String accountImage;
}

0 comments on commit 34f5f76

Please sign in to comment.