Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] 히스토리 status 변경 #55

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}