From a1c80ed1127c69f886349227ee1746f058c77a8b Mon Sep 17 00:00:00 2001 From: charging-kuafuai Date: Sun, 5 Nov 2023 14:50:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=AE=A1=E7=90=86=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E4=BF=A1=E6=81=AF=EF=BC=8C=E4=B8=BB=E8=A6=81=E5=8C=85?= =?UTF-8?q?=E6=8B=AC=EF=BC=9A=E4=BA=A7=E5=93=81=E5=9E=8B=E5=8F=B7=EF=BC=8C?= =?UTF-8?q?=E4=BA=A4=E4=BB=98=E6=97=B6=E9=97=B4=EF=BC=8C=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=EF=BC=8C=E5=8F=AF=E4=BA=A4=E4=BB=98=E6=95=B0?= =?UTF-8?q?=E9=87=8F=EF=BC=8C=E4=BA=A4=E6=98=93=E5=AF=B9=E6=89=8B=E6=96=B9?= =?UTF-8?q?=EF=BC=8C=E9=A2=84=E4=BB=98=E6=AC=BE=E6=AF=94=E4=BE=8B=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SupplierProductController.java | 31 ++++++++++ .../mapper/SupplierProductMapper.java | 21 +++++++ .../aiassistant/model/SupplierProduct.java | 60 +++++++++++++++++++ .../service/SupplierProductService.java | 11 ++++ .../impl/SupplierProductServiceImpl.java | 37 ++++++++++++ 5 files changed, 160 insertions(+) create mode 100644 src/main/java/com/aiassistant/controller/SupplierProductController.java create mode 100644 src/main/java/com/aiassistant/mapper/SupplierProductMapper.java create mode 100644 src/main/java/com/aiassistant/model/SupplierProduct.java create mode 100644 src/main/java/com/aiassistant/service/SupplierProductService.java create mode 100644 src/main/java/com/aiassistant/service/impl/SupplierProductServiceImpl.java diff --git a/src/main/java/com/aiassistant/controller/SupplierProductController.java b/src/main/java/com/aiassistant/controller/SupplierProductController.java new file mode 100644 index 0000000..6d417b1 --- /dev/null +++ b/src/main/java/com/aiassistant/controller/SupplierProductController.java @@ -0,0 +1,31 @@ +package com.aiassistant.controller; + +import com.aiassistant.model.SupplierProduct; +import com.aiassistant.service.SupplierProductService; +import com.aiassistant.utils.ResultModel; +import com.aiassistant.utils.ResultPageModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/supplierProduct") +public class SupplierProductController { + private final SupplierProductService supplierProductService; + + @Autowired + public SupplierProductController(SupplierProductService supplierProductService) { + this.supplierProductService = supplierProductService; + } + + @PostMapping("/add") + public ResultModel addSupplierProduct(SupplierProduct supplierProduct) { + return supplierProductService.addSupplierProduct(supplierProduct); + } + + @PostMapping("/list") + public ResultPageModel getSupplierProductList() { + return supplierProductService.getSupplierProductList(); + } +} diff --git a/src/main/java/com/aiassistant/mapper/SupplierProductMapper.java b/src/main/java/com/aiassistant/mapper/SupplierProductMapper.java new file mode 100644 index 0000000..fcaa6c4 --- /dev/null +++ b/src/main/java/com/aiassistant/mapper/SupplierProductMapper.java @@ -0,0 +1,21 @@ +package com.aiassistant.mapper; + +import com.aiassistant.model.SupplierProduct; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +@Mapper +public interface SupplierProductMapper { + @Insert("insert into supplier_product(product_model,delivery_time,product_price,deliverable_quantity,trading_counterparty,advance_payment_ratio) "+ + "values(#{productModel},#{deliveryTime},#{productPrice},#{deliverableQuantity},#{tradingCounterparty},#{advancePaymentRatio})") + SupplierProduct insertSupplierProduct(SupplierProduct supplierProduct); + + @Select("select * from supplier_product") + List getSupplierProductList(); + + @Select("select * from supplier_product where product_model = #{productModel}") + SupplierProduct selectByProductModel(String productModel); +} diff --git a/src/main/java/com/aiassistant/model/SupplierProduct.java b/src/main/java/com/aiassistant/model/SupplierProduct.java new file mode 100644 index 0000000..71ab183 --- /dev/null +++ b/src/main/java/com/aiassistant/model/SupplierProduct.java @@ -0,0 +1,60 @@ +package com.aiassistant.model; + +import java.util.Date; + +public class SupplierProduct { + private String productModel; + private Date deliveryTime; + private Double productPrice; + private Integer deliverableQuantity; + private String tradingCounterparty; + private Double advancePaymentRatio; + + public String getProductModel() { + return productModel; + } + + public void setProductModel(String productModel) { + this.productModel = productModel; + } + + public Date getDeliveryTime() { + return deliveryTime; + } + + public void setDeliveryTime(Date deliveryTime) { + this.deliveryTime = deliveryTime; + } + + public Double getProductPrice() { + return productPrice; + } + + public void setProductPrice(Double productPrice) { + this.productPrice = productPrice; + } + + public Integer getDeliverableQuantity() { + return deliverableQuantity; + } + + public void setDeliverableQuantity(Integer deliverableQuantity) { + this.deliverableQuantity = deliverableQuantity; + } + + public String getTradingCounterparty() { + return tradingCounterparty; + } + + public void setTradingCounterparty(String tradingCounterparty) { + this.tradingCounterparty = tradingCounterparty; + } + + public Double getAdvancePaymentRatio() { + return advancePaymentRatio; + } + + public void setAdvancePaymentRatio(Double advancePaymentRatio) { + this.advancePaymentRatio = advancePaymentRatio; + } +} diff --git a/src/main/java/com/aiassistant/service/SupplierProductService.java b/src/main/java/com/aiassistant/service/SupplierProductService.java new file mode 100644 index 0000000..96cf3e0 --- /dev/null +++ b/src/main/java/com/aiassistant/service/SupplierProductService.java @@ -0,0 +1,11 @@ +package com.aiassistant.service; + +import com.aiassistant.model.SupplierProduct; +import com.aiassistant.utils.ResultModel; +import com.aiassistant.utils.ResultPageModel; + +public interface SupplierProductService { + ResultModel addSupplierProduct(SupplierProduct supplierProduct); + ResultPageModel getSupplierProductList(); + SupplierProduct getSupplierProductByProductModel(String productModel); +} diff --git a/src/main/java/com/aiassistant/service/impl/SupplierProductServiceImpl.java b/src/main/java/com/aiassistant/service/impl/SupplierProductServiceImpl.java new file mode 100644 index 0000000..c6ff93f --- /dev/null +++ b/src/main/java/com/aiassistant/service/impl/SupplierProductServiceImpl.java @@ -0,0 +1,37 @@ +package com.aiassistant.service.impl; + +import com.aiassistant.mapper.SupplierProductMapper; +import com.aiassistant.model.SupplierProduct; +import com.aiassistant.service.SupplierProductService; +import com.aiassistant.utils.ResultModel; +import com.aiassistant.utils.ResultPageModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SupplierProductServiceImpl implements SupplierProductService { + + private final SupplierProductMapper supplierProductMapper; + + @Autowired + public SupplierProductServiceImpl(SupplierProductMapper supplierProductMapper) { + this.supplierProductMapper = supplierProductMapper; + } + + @Override + public ResultModel addSupplierProduct(SupplierProduct supplierProduct) { + supplierProductMapper.insertSupplierProduct(supplierProduct); + return ResultModel.ofSuccess("Supplier product added successfully"); + } + + @Override + public ResultPageModel getSupplierProductList() { + ResultPageModel resultPageModel = ResultPageModel.of(supplierProductMapper.getSupplierProductList()) + return resultPageModel; + } + + @Override + public SupplierProduct getSupplierProductByProductModel(String productModel) { + return supplierProductMapper.selectByProductModel(productModel); + } +}