From e7b2550fb49efe469d7b54027ac22bd94b9ebad1 Mon Sep 17 00:00:00 2001 From: WenZongX <2937021973@qq.com> Date: Mon, 15 Nov 2021 15:27:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=80=9A=E8=BF=87=E7=B1=BB?= =?UTF-8?q?=E5=88=AB=E5=92=8C=E5=85=B3=E9=94=AE=E8=AF=8D=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/shop/controller/GoodsController.java | 13 +++++++++++++ .../src/main/java/com/shop/mapper/GoodsMapper.java | 8 ++++++++ .../main/java/com/shop/service/GoodsService.java | 1 + .../src/main/resources/mapping/GoodsMapper.xml | 5 +++++ 4 files changed, 27 insertions(+) diff --git a/back-end_code/src/main/java/com/shop/controller/GoodsController.java b/back-end_code/src/main/java/com/shop/controller/GoodsController.java index 04da698..0b0942d 100644 --- a/back-end_code/src/main/java/com/shop/controller/GoodsController.java +++ b/back-end_code/src/main/java/com/shop/controller/GoodsController.java @@ -240,6 +240,19 @@ public class GoodsController { return jsonObject; } + //通过类别和关键词查询商品 + @RequestMapping(value = "/searchGoodsByClassAndKeyName") + public Object searchGoodsByClassAndKeyName(HttpServletRequest request, HttpServletResponse response){ + int goods_class = Integer.getInteger(request.getParameter("goods_class")); + String key_name = request.getParameter("key_name"); + JSONObject jsonObject = new JSONObject(); + List goodsList =goodsService.searchGoodsByClassAndKeyName(goods_class,key_name); + message = "success"; + jsonObject.put("goods",goodsList); + jsonObject.put("message",message); + return jsonObject; + } + //修改商品库存 @RequestMapping(value = "/updateGoodStock") public Object updateGoodStock(HttpServletRequest request, HttpServletResponse response){ diff --git a/back-end_code/src/main/java/com/shop/mapper/GoodsMapper.java b/back-end_code/src/main/java/com/shop/mapper/GoodsMapper.java index cb7ddcd..f777990 100644 --- a/back-end_code/src/main/java/com/shop/mapper/GoodsMapper.java +++ b/back-end_code/src/main/java/com/shop/mapper/GoodsMapper.java @@ -91,4 +91,12 @@ public interface GoodsMapper { */ int updateGoodStock(int item_id,int new_stock); + /** + * 通过类别和关键词查询商品 + * @param goods_class + * @param key_name + * @return + */ + List searchGoodsByClassAndKeyName(int goods_class,String key_name); + } diff --git a/back-end_code/src/main/java/com/shop/service/GoodsService.java b/back-end_code/src/main/java/com/shop/service/GoodsService.java index 3b9a608..dabb988 100644 --- a/back-end_code/src/main/java/com/shop/service/GoodsService.java +++ b/back-end_code/src/main/java/com/shop/service/GoodsService.java @@ -44,4 +44,5 @@ public class GoodsService { // return goodsMapper.updateGoodStock(item_id,new_stock); // } public int updateGoodStock(int item_id,int new_stock){return goodsMapper.updateGoodStock(item_id,new_stock);} + public List searchGoodsByClassAndKeyName(int goods_class,String key_name){return searchGoodsByClassAndKeyName(goods_class,key_name);} } diff --git a/back-end_code/src/main/resources/mapping/GoodsMapper.xml b/back-end_code/src/main/resources/mapping/GoodsMapper.xml index 5709cc0..d557517 100644 --- a/back-end_code/src/main/resources/mapping/GoodsMapper.xml +++ b/back-end_code/src/main/resources/mapping/GoodsMapper.xml @@ -149,4 +149,9 @@ select * from goods where goodsName like '%${key_name}%' + + + \ No newline at end of file -- Gitee