[220402] git 충돌 정리

This commit is contained in:
appleg
2022-04-02 17:00:04 +09:00
parent b34992127a
commit fbf8a45977
4 changed files with 24 additions and 66 deletions

View File

@@ -83,14 +83,6 @@ CRUD 중에서 R 만을 담당하는 모듈이다. payment-command에서 발행
- Repository가 Controller에 직접 주입될 수 있다. 왜냐하면 DB 쿼리 외의 별다른 로직이 필요없기 때문이다.
- 마찬가지 이유로 Response DTO도 사용하지 않는다. 이미 DB에 저장된 모든 정보가 Response에 최적화 시켜져 있기 때문이다.
#### Query Model의 모듈 특징
- Query 모델에서는 Consuming과 동시에 Query 모델에서 필요한 데이터로 가공한다고 가정한다.
- 그러므로 몇 가지 요소가 생략될 수 있다.
- Repository가 Controller에 직접 주입될 수 있다. 왜냐하면 DB 쿼리 외의 별다른 로직이 필요없기 때문이다.
- 마찬가지 이유로 Response DTO도 사용하지 않는다. 이미 DB에 저장된 모든 정보가 Response에 최적화 시켜져 있기 때문이다.

View File

@@ -1,44 +0,0 @@
package com.example.cash.domain;
import com.example.user.domain.User;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.UUID;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class Cash {
@Id
private String id;
private BigDecimal amount;
@ManyToOne
@JoinColumn
private User user;
@CreatedDate
private LocalDateTime createdAt;
@LastModifiedDate
private LocalDateTime updatedAt;
public String getId() {
return id;
}
public static Cash of(BigDecimal amount, User user) {
return new Cash(UUID.fromString("cash").toString(), amount, user, null, null);
}
}

View File

@@ -1,14 +0,0 @@
package com.example;
import com.example.payment.domain.event.PaymentCreated;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Service;
@Service
public class PaymentCreatedListener {
@KafkaListener(topics = "PaymentCreated", groupId = "group1")
public void consume(PaymentCreated message) {
System.out.println("receive message : " + message.toString());
}
}

View File

@@ -0,0 +1,24 @@
package com.example.payment.infra.kafka;
import com.example.payment.domain.Payment;
import com.example.payment.domain.PaymentRepository;
import com.example.payment.domain.event.PaymentCreated;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
@Slf4j
public class PaymentCreatedListener {
private final PaymentRepository paymentRepository;
@KafkaListener(topics = "PaymentCreated", groupId = "group1")
public void consume(PaymentCreated message) {
log.info("event received: {}", message);
Payment payment = message.toPayment();
paymentRepository.save(payment);
}
}