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

style: Update buyername and sellername to use username. #105

Merged
merged 4 commits into from
Jan 12, 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public class OrderWithProductDetail {
@NotNull
private Long buyerid;

@NotNull
private String buyername;

@NotNull
private String sellername;

@NotNull
private Long sellerid;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ntou.auction.spring.order.service;

import ntou.auction.spring.account.entity.User;
import ntou.auction.spring.account.service.UserService;
import ntou.auction.spring.mail.EmailService;
import ntou.auction.spring.order.entity.Order;
import ntou.auction.spring.order.response.OrderWithProductDetail;
Expand All @@ -22,15 +24,15 @@ public class OrderService {

private final ProductService productService;

private final ShoppingcartService shoppingcartService;
private final UserService userService;
private final EmailService emailService;

private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

public OrderService(OrderRepository repository, ProductService productService, ShoppingcartService shoppingcartService, EmailService emailService) {
public OrderService(OrderRepository repository, ProductService productService, UserService userService, EmailService emailService) {
this.repository = repository;
this.productService = productService;
this.shoppingcartService = shoppingcartService;
this.userService = userService;
this.emailService = emailService;
}

Expand Down Expand Up @@ -159,6 +161,10 @@ public List<OrderWithProductDetail> orderToOrderWithProductDetail(List<Order> ge
addOrder.setUpdateTime(order.getUpdateTime());
addOrder.setStatus(order.getStatus());
addOrder.setOrderid(order.getId());
User buyer = userService.get(order.getBuyerid()).orElse(null);
User seller = userService.get(order.getSellerid()).orElse(null);
if(buyer!=null) addOrder.setBuyername(buyer.getUsername());
if(seller!=null) addOrder.setSellername(seller.getUsername());
List<ProductAddAmount> temp = new ArrayList<>();
for (List<Long> product : order.getProductAddAmountList()) {
temp.add(new ProductAddAmount(productService.getID(product.get(0)), product.get(1)));
Expand Down
Loading