From d91068f3d1a92cf411deafd807302a88d322bc0e Mon Sep 17 00:00:00 2001 From: fengb Date: Mon, 11 Sep 2023 09:08:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=93=E5=AD=98=E4=BF=A1=E6=81=AF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fengb --- .../mall/controller/ProductController.java | 27 ++++++++- .../mall/controller/StockController.java | 11 ++++ .../java/cc/hiver/mall/entity/Product.java | 1 + .../main/java/cc/hiver/mall/entity/Stock.java | 11 ++++ .../cc/hiver/mall/entity/StockExample.java | 60 +++++++++++++++++++ .../src/main/resources/mapper/StockMapper.xml | 29 ++++++--- 6 files changed, 131 insertions(+), 8 deletions(-) diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java index 96cd9d94..ee9d62d1 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java @@ -4,7 +4,9 @@ import cc.hiver.core.common.utils.ResultUtil; import cc.hiver.core.common.vo.Result; import cc.hiver.mall.entity.Product; import cc.hiver.mall.service.mybatis.ProductService; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -47,6 +49,20 @@ public class ProductController { } } + @RequestMapping(value = "/down", method = RequestMethod.POST) + @ApiOperation(value = "根据货品id下架货品") + public Result down(String id) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("del_flag",0); + updateWrapper.eq("id",id); + boolean result = productService.update(updateWrapper); + if(result) { + return ResultUtil.success("下架成功"); + } else { + return ResultUtil.error("下架失败"); + } + } + @RequestMapping(value = "/delById", method = RequestMethod.POST) @ApiOperation(value = "根据id删除货品") public Result delete(Product product) { @@ -73,13 +89,22 @@ public class ProductController { // } @RequestMapping(value = "/list", method = RequestMethod.GET) - @ApiOperation(value = "查询货品列表") + @ApiOperation(value = "查询所有货品列表") public Result list() { QueryWrapper queryWrapper = new QueryWrapper<>(); List list = productService.list(queryWrapper); return new ResultUtil>().setData(list); } + @RequestMapping(value = "/listWithUp", method = RequestMethod.GET) + @ApiOperation(value = "查询上架货品列表") + public Result listWithUp() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("del_flag",1); + List list = productService.list(queryWrapper); + return new ResultUtil>().setData(list); + } + @RequestMapping(value = "/listByName", method = RequestMethod.GET) @ApiOperation(value = "根据货品名称查询货品列表") public Result listByName(String name) { diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/StockController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/StockController.java index 36c2fd11..3a87e2f5 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/StockController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/StockController.java @@ -2,9 +2,11 @@ package cc.hiver.mall.controller; import cc.hiver.core.common.utils.ResultUtil; import cc.hiver.core.common.vo.Result; +import cc.hiver.mall.entity.Product; import cc.hiver.mall.entity.Stock; import cc.hiver.mall.pojo.vo.PurchaseVo; import cc.hiver.mall.service.mybatis.StockService; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -55,4 +57,13 @@ public class StockController { return new ResultUtil>().setData(list); } + @RequestMapping(value = "/count", method = RequestMethod.POST) + @ApiOperation(value = "根据货品id统计库存数量") + public long count(String id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("product_id",id); + long count = stockService.count(queryWrapper); + return count; + } + } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Product.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Product.java index 180528ab..f01b8e40 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Product.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Product.java @@ -18,6 +18,7 @@ public class Product implements Serializable { private Date createTime; + @ApiModelProperty(value = "商品是否上架 0-否 1-是") private Integer delFlag; private String updateBy; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Stock.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Stock.java index 21f51e49..78be8b0c 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Stock.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Stock.java @@ -78,6 +78,9 @@ public class Stock implements Serializable { @ApiModelProperty(value = "库存数量") private Integer stockCount; + @ApiModelProperty(value = "库存预警数量") + private Integer stockWarnCount; + private static final long serialVersionUID = 1L; public String getId() { @@ -272,6 +275,14 @@ public class Stock implements Serializable { this.stockCount = stockCount; } + public Integer getStockWarnCount() { + return stockWarnCount; + } + + public void setStockWarnCount(Integer stockWarnCount) { + this.stockWarnCount = stockWarnCount; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/StockExample.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/StockExample.java index f3734323..b8327d94 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/StockExample.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/StockExample.java @@ -1715,6 +1715,66 @@ public class StockExample { addCriterion("stock_count not between", value1, value2, "stockCount"); return (Criteria) this; } + + public Criteria andStockWarnCountIsNull() { + addCriterion("stock_warn_count is null"); + return (Criteria) this; + } + + public Criteria andStockWarnCountIsNotNull() { + addCriterion("stock_warn_count is not null"); + return (Criteria) this; + } + + public Criteria andStockWarnCountEqualTo(Integer value) { + addCriterion("stock_warn_count =", value, "stockWarnCount"); + return (Criteria) this; + } + + public Criteria andStockWarnCountNotEqualTo(Integer value) { + addCriterion("stock_warn_count <>", value, "stockWarnCount"); + return (Criteria) this; + } + + public Criteria andStockWarnCountGreaterThan(Integer value) { + addCriterion("stock_warn_count >", value, "stockWarnCount"); + return (Criteria) this; + } + + public Criteria andStockWarnCountGreaterThanOrEqualTo(Integer value) { + addCriterion("stock_warn_count >=", value, "stockWarnCount"); + return (Criteria) this; + } + + public Criteria andStockWarnCountLessThan(Integer value) { + addCriterion("stock_warn_count <", value, "stockWarnCount"); + return (Criteria) this; + } + + public Criteria andStockWarnCountLessThanOrEqualTo(Integer value) { + addCriterion("stock_warn_count <=", value, "stockWarnCount"); + return (Criteria) this; + } + + public Criteria andStockWarnCountIn(List values) { + addCriterion("stock_warn_count in", values, "stockWarnCount"); + return (Criteria) this; + } + + public Criteria andStockWarnCountNotIn(List values) { + addCriterion("stock_warn_count not in", values, "stockWarnCount"); + return (Criteria) this; + } + + public Criteria andStockWarnCountBetween(Integer value1, Integer value2) { + addCriterion("stock_warn_count between", value1, value2, "stockWarnCount"); + return (Criteria) this; + } + + public Criteria andStockWarnCountNotBetween(Integer value1, Integer value2) { + addCriterion("stock_warn_count not between", value1, value2, "stockWarnCount"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml index 3bb1f240..243218cf 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml @@ -26,6 +26,7 @@ + @@ -89,7 +90,7 @@ id, create_by, create_time, del_flag, update_by, update_time, product_id, product_name, unit, shop_id, category_id, attribute_list, supplier_id, product_sn, barcode, price, purchase_price, wholesale_price, product_picture, product_video, product_intro, sales_week, - print_barcode, stock_count + print_barcode, stock_count, stock_warn_count @@ -373,6 +380,9 @@ stock_count = #{record.stockCount,jdbcType=INTEGER}, + + stock_warn_count = #{record.stockWarnCount,jdbcType=INTEGER}, + @@ -403,7 +413,8 @@ product_intro = #{record.productIntro,jdbcType=VARCHAR}, sales_week = #{record.salesWeek,jdbcType=VARCHAR}, print_barcode = #{record.printBarcode,jdbcType=VARCHAR}, - stock_count = #{record.stockCount,jdbcType=INTEGER} + stock_count = #{record.stockCount,jdbcType=INTEGER}, + stock_warn_count = #{record.stockWarnCount,jdbcType=INTEGER} @@ -480,6 +491,9 @@ stock_count = #{stockCount,jdbcType=INTEGER}, + + stock_warn_count = #{stockWarnCount,jdbcType=INTEGER}, + where id = #{id,jdbcType=VARCHAR} @@ -507,7 +521,8 @@ product_intro = #{productIntro,jdbcType=VARCHAR}, sales_week = #{salesWeek,jdbcType=VARCHAR}, print_barcode = #{printBarcode,jdbcType=VARCHAR}, - stock_count = #{stockCount,jdbcType=INTEGER} + stock_count = #{stockCount,jdbcType=INTEGER}, + stock_warn_count = #{stockWarnCount,jdbcType=INTEGER} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file