Skip to content

Commit

Permalink
[FEAT] 히스토리 status 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ssjy4974 committed Jan 21, 2024
1 parent 0211f78 commit fa671bd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
implementation 'software.amazon.awssdk:dynamodb:2.1.0'

implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation group: 'io.github.dailyon-maven', name: 'daily-on-common', version: '0.0.9'
implementation group: 'io.github.dailyon-maven', name: 'daily-on-common', version: '0.1.0'

implementation 'org.springframework.kafka:spring-kafka'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.dailyon.auctionservice.service.AuctionHistoryService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import dailyon.domain.order.kafka.OrderDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
Expand All @@ -27,4 +28,16 @@ public void cancel(String message, Acknowledgment ack) {
e.printStackTrace();
}
}

@KafkaListener(topics = "approve-payment")
public void updateStatus(String message, Acknowledgment ack) {
OrderDTO orderDTO = null;
try {
orderDTO = objectMapper.readValue(message, OrderDTO.class);
auctionHistoryService.update(orderDTO.getAuctionId(), String.valueOf(orderDTO.getMemberId()));
ack.acknowledge();
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -57,4 +56,11 @@ public void delete(BiddingDTO biddingDTO) {
.get();
auctionHistoryRepository.delete(auctionHistory);
}

public void update(String auctionId, String memberId) {
AuctionHistory auctionHistory =
auctionHistoryRepository.findByAuctionIdAndMemberId(auctionId, memberId).get();
auctionHistory.setPaid(true);
auctionHistoryRepository.save(auctionHistory);
}
}

0 comments on commit fa671bd

Please sign in to comment.