Skip to content

Commit

Permalink
供应商信息管理,新增供应商信息,主要包括:产品型号,交付时间,产品价格,可交付数量,交易对手方,预付款比例等
Browse files Browse the repository at this point in the history
  • Loading branch information
charging-kuafuai committed Nov 5, 2023
1 parent 747eda9 commit a1c80ed
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<SupplierProduct> getSupplierProductList() {
return supplierProductService.getSupplierProductList();
}
}
21 changes: 21 additions & 0 deletions src/main/java/com/aiassistant/mapper/SupplierProductMapper.java
Original file line number Diff line number Diff line change
@@ -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<SupplierProduct> getSupplierProductList();

@Select("select * from supplier_product where product_model = #{productModel}")
SupplierProduct selectByProductModel(String productModel);
}
60 changes: 60 additions & 0 deletions src/main/java/com/aiassistant/model/SupplierProduct.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
11 changes: 11 additions & 0 deletions src/main/java/com/aiassistant/service/SupplierProductService.java
Original file line number Diff line number Diff line change
@@ -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<SupplierProduct> getSupplierProductList();
SupplierProduct getSupplierProductByProductModel(String productModel);
}
Original file line number Diff line number Diff line change
@@ -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<SupplierProduct> getSupplierProductList() {
ResultPageModel<SupplierProduct> resultPageModel = ResultPageModel.of(supplierProductMapper.getSupplierProductList())
return resultPageModel;
}

@Override
public SupplierProduct getSupplierProductByProductModel(String productModel) {
return supplierProductMapper.selectByProductModel(productModel);
}
}

0 comments on commit a1c80ed

Please sign in to comment.