Skip to content

Refactor/jira kan 67 지갑 거래내역 관리 new#79

Merged
usingjun merged 75 commits intodevelopfrom
Refactor/JIRA-kan-67-지갑-거래내역-관리-new
Apr 6, 2025

Hidden character warning

The head ref may contain hidden characters: "Refactor/JIRA-kan-67-\uc9c0\uac11-\uac70\ub798\ub0b4\uc5ed-\uad00\ub9ac-new"
Merged

Refactor/jira kan 67 지갑 거래내역 관리 new#79
usingjun merged 75 commits intodevelopfrom
Refactor/JIRA-kan-67-지갑-거래내역-관리-new

Conversation

@usingjun
Copy link
Collaborator

@usingjun usingjun commented Apr 1, 2025

🛠️ 과제 요약

  • 지갑 거래내역 관리 & 지갑 리팩토링

📝 요구 사항과 구현 내용

  • 송금 시 상대방의 이름과 전화번호로 전송하는 방식으로 변경
  • controller단에서 로그인된 userId로 변경
  • 전반적인 리팩토링
  • rabbitMQ로 거래내역 저장
  • 재시도 3회 이상 시 slack알람 발송
  • Test환경 Docker로 변경
  • UserLogin 테스트 단위테스트, 통합테스트로 분리

✅ 피드백 반영사항

거래내역 비동기 처리 설명
https://www.notion.so/1bd5e1ebf98580e28293c1608beecaf7?pvs=4

querydsl 동적페이징
https://www.notion.so/queryDSL-1c75e1ebf98580e891eff5f34dc96d51?pvs=4

💬 PR 포인트 & 궁금한 점

  • 송금 시 상대방의 이름과 전화번호로 전송하는 방식으로 변경

  • Test환경 Docker로 변경
    `@Container
    static PostgreSQLContainer<?> postgresContainer = new PostgreSQLContainer<>("postgres:16")
    .withDatabaseName("xcp_test")
    .withUsername("testuser")
    .withPassword("testpass");

    @container
    static GenericContainer<?> rabbitMqContainer = new GenericContainer<>("rabbitmq:3-management")
    .withExposedPorts(5672, 15672)
    .withEnv("RABBITMQ_DEFAULT_USER", "guest")
    .withEnv("RABBITMQ_DEFAULT_PASS", "guest");

    @DynamicPropertySource
    static void overrideDataSourceProperties(DynamicPropertyRegistry registry) {
    registry.add("spring.datasource.url", postgresContainer::getJdbcUrl);
    registry.add("spring.datasource.username", postgresContainer::getUsername);
    registry.add("spring.datasource.password", postgresContainer::getPassword);
    }

    @DynamicPropertySource
    static void overrideProperties(DynamicPropertyRegistry registry) {
    registry.add("spring.rabbitmq.host", rabbitMqContainer::getHost);
    registry.add("spring.rabbitmq.port", () -> rabbitMqContainer.getMappedPort(5672));
    }`

  • 재시도 3회 이상 시 slack알람 발송
    `
    @RabbitListener(queues = "wallet-transaction-dlx-queue")
    public void handleDeadLetter(WalletTransactionMessage message,
    @Header(AmqpHeaders.DELIVERY_TAG) long tag,
    @Header("x-death") List<Map<String, Object>> xDeathHeader,
    Channel channel) throws IOException {

      int retryCount = 0;
      if (xDeathHeader != null && !xDeathHeader.isEmpty()) {
          Map<String, Object> death = xDeathHeader.get(0);
          retryCount = ((Long) death.get("count")).intValue();
      }
    
      if (retryCount < 3) {
          log.warn("♻️ DLQ 재시도 {}회차: {}", retryCount + 1, message);
          rabbitTemplate.convertAndSend("wallet-transaction-retry-queue", message);
      } else {
          log.error("🚨 DLQ 재시도 초과, 슬랙 알림 전송: {}", message);
          slackNotifier.send("🚨 DLQ 처리 실패: " + message);
      }
    
      // 수동 ack
      channel.basicAck(tag, false);
    

    }
    `

  • MockBean 해결하려고 했으나 실패
    https://silky-toothbrush-191.notion.site/MockBean-Deprecated-1c55e1ebf98580d6b078cf4e846dbf3f?pvs=4

@CryingPerson
이거 확인해줘
WalletInOutRequest @builder로 설정했는데 userId는 안받아서

public class ExchangeTransactionService {
if (fromBalance.getBalance().compareTo(amount) < 0) {
WalletInOutRequest chargeRequest = WalletInOutRequest.builder()
// .userId(userId)
.fromCurrency(Currency.getInstance(fromCurrency))
.toCurrency(Currency.getInstance(fromCurrency))
.amount(amount)
.chargeDatetime(LocalDateTime.now())
.build();

// walletService.charge(chargeRequest);
}

+++++
@Validation 관련 어노테이션
@target({FIELD}) | 필드에만 적용 가능 (예: DTO의 필드에 붙여서 사용)
@retention(RUNTIME) | 런타임 시에도 어노테이션 정보 유지
@constraint(validatedBy = CurrencyValidator.class) | 어떤 클래스에서 검증할 것인지 지정

CustomUserDetails 받는 방식으로 변경
public ResponseEntity<?> me(@AuthenticationPrincipal CustomUserDetails user) {
return ResponseEntity.ok("userId = " + user.getUserId());
}

🔗 연관된 이슈

  • postgresql streaming replication 고민중

usingjun added 30 commits March 20, 2025 09:26
@usingjun usingjun added the ✨ Feature 기능 개발 label Apr 1, 2025
@usingjun usingjun self-assigned this Apr 1, 2025
Copy link
Collaborator

@CryingPerson CryingPerson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전체적으로 설명이 좀 필요할거 같습니다

public static WalletTransactionListResponse fromEntity(WalletTransaction transaction) {
Wallet counterWallet = transaction.getCounterWallet();

return new WalletTransactionListResponse(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builder 패턴 대신 new 로 쓰신 이유가 있으신가여???

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굳이 builder패턴을 사용하지 않아도 된다고 판단했습니다

Copy link
Collaborator

@CryingPerson CryingPerson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다.!

@usingjun usingjun merged commit 3651d0e into develop Apr 6, 2025
1 check passed
@usingjun usingjun deleted the Refactor/JIRA-kan-67-지갑-거래내역-관리-new branch April 9, 2025 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 기능 개발

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants