Commit 906402aa authored by lemin's avatar lemin

commit

parent 55010bb9
......@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.showcase.synapse.sales.dto.ProductSalesDto;
import com.showcase.synapse.sales.dto.SalesCreateDto;
import com.showcase.synapse.sales.entity.ProductEntity;
import com.showcase.synapse.sales.entity.SalesEntity;
......@@ -31,8 +32,8 @@ public class SalesController {
}
@GetMapping("/product/")
public ResponseEntity<List<ProductEntity>> getProducts() throws ExecutionException, InterruptedException {
List<ProductEntity> productEntities = salesService.getProducts();
public ResponseEntity<List<ProductSalesDto>> getProducts() throws ExecutionException, InterruptedException {
List<ProductSalesDto> productEntities = salesService.getProducts();
return ResponseEntity.ok(productEntities);
}
......
package com.showcase.synapse.sales.service;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
......@@ -12,6 +12,7 @@ import org.axonframework.queryhandling.QueryGateway;
import org.springframework.stereotype.Service;
import com.showcase.synapse.sales.command.CreateSalesCommand;
import com.showcase.synapse.sales.dto.ProductSalesDto;
import com.showcase.synapse.sales.entity.ProductEntity;
import com.showcase.synapse.sales.entity.SalesEntity;
import com.showcase.synapse.sales.query.GetProductsQuery;
......@@ -45,26 +46,35 @@ public class SalesService {
return returnValue;
}
public List<ProductEntity> getProducts() throws ExecutionException, InterruptedException {
List<ProductEntity> productInventoryList = queryGateway.query(new GetProductsQuery(),
public List<ProductSalesDto> getProducts() throws ExecutionException, InterruptedException {
List<ProductEntity> productList = queryGateway.query(new GetProductsQuery(),
ResponseTypes.multipleInstancesOf(ProductEntity.class)).get();
if(productInventoryList != null && productInventoryList.size() > 0) {
List<ProductSalesDto> productInventoryList = null;
if(productList != null && productList.size() > 0) {
productInventoryList = new ArrayList<ProductSalesDto>();
ProductEntity tempPE = null;
int size = productInventoryList.size();
for (int i = 0; i < size; i++) {
ProductSalesDto dto = null;
int size = productList.size();
for (int i = 0; i < size; i++) {
tempPE = productList.get(i);
if(tempPE.getInventory() != null && tempPE.getInventory().getWhid() != null) {
dto = new ProductSalesDto();
dto.setProductId(tempPE.getId());
dto.setProductName(tempPE.getName());
dto.setProductComment(tempPE.getComment());
dto.setPrice(tempPE.getPrice().multiply(tempPE.getChannel().getDiscountRate().add(new BigDecimal(1))));
dto.setSalesChannel(tempPE.getChannel().getName());
dto.setWhId(tempPE.getInventory().getWhid());
dto.setWhName(tempPE.getInventory().getWhName());
dto.setQuantity(tempPE.getInventory().getQuantity());
productInventoryList.add(dto);
}
}
}
// "productid": "5e75ede3-eb2c-4403-bf41-5f0dbbec07eb",
// "productname": "아이폰15",
// "productcomment": "MSA Product : 아이폰15",
// "price": 30000.00,
// "saleschannel": "company"
// "whid": "494647f8-20b8-4f65-99c9-b28044b270dc",
// "whName": "Busan warehouse",
// "quantity": 5000
return productInventoryList;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment