[UPLUS-57] 할인 추가삭제 기능 추가/developer브랜치와 병합 및 오류 수정 - #10
arlen02-01 wants to merge 2 commits into
Conversation
Summary of ChangesHello @arlen02-01, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 고객 및 구독 관리 기능을 대폭 확장하고 새로운 할인 정책 관리 시스템을 도입합니다. 고객 정보를 조회하고 수정하는 API를 추가하며, 구독에 대한 할인 정책을 유연하게 관리할 수 있는 엔티티와 서비스 로직을 구현합니다. 또한, 민감한 구독 정보를 안전하게 처리하기 위해 전화번호 복호화 및 마스킹 기능을 포함합니다. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
이 PR은 할인 추가/삭제 기능과 관련된 새로운 엔티티, 리포지토리, 서비스를 추가하고 기존 고객 및 구독 관련 코드를 수정합니다. 전반적으로 기능 추가의 방향은 좋지만, 몇 가지 중요한 문제점들이 보입니다. 특히, SubscriptionService에서 엔티티를 직접 수정하여 마스킹된 데이터를 저장하는 부분은 데이터 손실을 유발할 수 있는 심각한 버그입니다. 또한, 금액을 다루는 필드에 Double 타입을 사용하는 것은 정밀도 문제를 일으킬 수 있으므로 BigDecimal로 변경해야 합니다. 컨트롤러에서 엔티티를 직접 노출하는 대신 DTO를 사용하는 것이 좋으며, 예외 처리와 명명 규칙을 일관성 있게 적용할 필요가 있습니다. 아래의 상세 리뷰를 확인하고 수정해 주시기 바랍니다.
| public void setPhoneNumber(String maskedNum) { | ||
| this.phoneNumber = maskedNum; | ||
| } |
There was a problem hiding this comment.
| public List<Subscription> findSubscription(Long customerId) throws Exception { | ||
| List<Subscription> subscriptions = | ||
| subscriptionRepository.findByCustomer_CustomerId(customerId); | ||
|
|
||
| if (subscriptions.isEmpty()) { | ||
| throw new IllegalStateException("보유중인 회선이 없습니다."); | ||
| }else { | ||
| //복호화 -> 마스킹 | ||
| for (int i = 0; i < subscriptions.size(); i++) { | ||
| String num = aesUtil.decrypt(subscriptions.get(i).getPhoneNumber()); | ||
| String maskedNum = num.substring(0,4)+"**"+num.substring(6,9)+"**"+num.substring(11,12); //"010-**34-**78" | ||
| subscriptions.get(i).setPhoneNumber(maskedNum); | ||
| } | ||
| } | ||
|
|
||
| return subscriptions; | ||
| } |
There was a problem hiding this comment.
@Transactional 메서드 내에서 조회한 Subscription 엔티티의 전화번호를 마스킹 처리한 값으로 변경하고 있습니다. 이로 인해 트랜잭션이 커밋될 때 암호화된 원래 전화번호가 마스킹된 값으로 데이터베이스에 덮어씌워져 데이터가 유실되는 심각한 문제가 발생합니다.
프레젠테이션 계층에 필요한 데이터 가공(마스킹)은 엔티티를 직접 수정하는 대신 별도의 DTO(Data Transfer Object)를 만들어 처리해야 합니다. Subscription 엔티티의 상태를 변경하지 않도록 하고, 마스킹된 값을 DTO에 담아 반환하도록 전체적인 구조를 변경해주세요.
| @Column(name = "value", nullable = false) | ||
| private Double value; |
There was a problem hiding this comment.
금액이나 비율과 같은 값을 Double 타입으로 저장하면 부동 소수점 연산 시 정밀도 문제가 발생할 수 있습니다. 금융 관련 계산에서는 BigDecimal 타입을 사용하는 것이 표준적인 방법입니다. value 필드의 타입을 BigDecimal로 변경해주세요.
| @Column(name = "value", nullable = false) | |
| private Double value; | |
| @Column(name = "value", nullable = false) | |
| private java.math.BigDecimal value; |
| private DiscountType discountType; | ||
|
|
||
| @Column(name = "value", nullable = false) | ||
| private Double value; |
There was a problem hiding this comment.
| public ResponseEntity<List<Customer>> loadByContactEnc( | ||
| @RequestParam String contactEnc | ||
| ) { | ||
| List<Customer> customers = customerService.loadByContactEnc(contactEnc); | ||
| return ResponseEntity.ok(customers); | ||
| } |
There was a problem hiding this comment.
| 복지 | ||
| ,프로모션 | ||
| ,결합 |
| Rate | ||
| ,Fixed |
| private final CustomerRepository customerRepository; | ||
|
|
||
| @Transactional | ||
| public List<Customer> loadByContactEnc(String contactEnc) {//유저 조회 |
There was a problem hiding this comment.
| if (discounts.isEmpty()) { | ||
| throw new IllegalStateException("해당 회선에 적용된 할인이 없습니다"); | ||
| } |
| //복호화 -> 마스킹 | ||
| for (int i = 0; i < subscriptions.size(); i++) { | ||
| String num = aesUtil.decrypt(subscriptions.get(i).getPhoneNumber()); | ||
| String maskedNum = num.substring(0,4)+"**"+num.substring(6,9)+"**"+num.substring(11,12); //"010-**34-**78" |
🍀 이슈 번호
UPLUS-57
✅ 작업 사항
할인 추가삭제 기능 추가/developer브랜치와 병합 및 오류 수정
📋 체크리스트
⌨ 기타