From ad7357aea7ed9248aec405f79a214ab5b614f579 Mon Sep 17 00:00:00 2001 From: clunt Date: Tue, 10 May 2022 11:11:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=88=86=E5=85=AC?= =?UTF-8?q?=E5=8F=B8=E7=B1=BB=E7=9B=AE=E4=BB=8E=E6=80=BB=E5=85=AC=E5=8F=B8?= =?UTF-8?q?=E9=80=89=E5=8F=96=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/GoodsCategoryController.java | 2 +- .../goods/GoodsDeptCategoryController.java | 19 ++- .../templates/goods/category/edit.html | 141 ------------------ .../templates/goods/deptcategory/add.html | 35 ++++- .../goods/deptcategory/deptcategory.html | 5 +- .../com/ghy/framework/config/ShiroConfig.java | 1 + .../impl/GoodsCategoryServiceImpl.java | 1 + 7 files changed, 49 insertions(+), 155 deletions(-) delete mode 100644 ghy-admin/src/main/resources/templates/goods/category/edit.html diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsCategoryController.java b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsCategoryController.java index cc6ecd91..8755edb1 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsCategoryController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsCategoryController.java @@ -152,7 +152,7 @@ public class GoodsCategoryController extends BaseController { /** * 商品类别表 */ - @RequiresPermissions("goods:goods:list") +// @RequiresPermissions("goods:goods:list") @PostMapping("/list") @ResponseBody public List list(GoodsCategory category) { diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java index 46cedd5e..43462e0d 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java @@ -2,13 +2,12 @@ package com.ghy.web.controller.goods; import com.ghy.common.core.controller.BaseController; import com.ghy.common.core.domain.Ztree; +import com.ghy.goods.domain.GoodsCategory; import com.ghy.goods.service.GoodsCategoryService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; @@ -32,11 +31,21 @@ public class GoodsDeptCategoryController extends BaseController { @RequiresPermissions("goods:deptcategory:add") - @GetMapping("/add") - public String edit(ModelMap mmap) { + @GetMapping("/add/{id}") + public String edit(@PathVariable(name = "id") Long id, ModelMap mmap) { return PREFIX + "/add"; } + /** + * 商品类别表 + */ + @RequiresPermissions("goods:goods:list") + @PostMapping("/list") + @ResponseBody + public List list(GoodsCategory category) { + return goodsCategoryService.selectGoodsCategoryList(category); + } + @GetMapping("/tree") @ResponseBody public List goodsDeptCategoryTree() { diff --git a/ghy-admin/src/main/resources/templates/goods/category/edit.html b/ghy-admin/src/main/resources/templates/goods/category/edit.html deleted file mode 100644 index 93d6466c..00000000 --- a/ghy-admin/src/main/resources/templates/goods/category/edit.html +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - -
-
- - -
- -
-
- - -
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- - -
-
-
-
-
- - - - diff --git a/ghy-admin/src/main/resources/templates/goods/deptcategory/add.html b/ghy-admin/src/main/resources/templates/goods/deptcategory/add.html index 697b2635..c6bbd8a8 100644 --- a/ghy-admin/src/main/resources/templates/goods/deptcategory/add.html +++ b/ghy-admin/src/main/resources/templates/goods/deptcategory/add.html @@ -1,14 +1,13 @@ - +
-
+
-
@@ -34,9 +33,33 @@ }; $.tree.init(options); }); - - function edit() { - var menuIds = $.tree.getCheckedNodes(); + + $('input').on('ifChanged', function(obj){ + var type = $(this).val(); + var checked = obj.currentTarget.checked; + if (type == 1) { + if (checked) { + $._tree.expandAll(true); + } else { + $._tree.expandAll(false); + } + } else if (type == "2") { + if (checked) { + $._tree.checkAllNodes(true); + } else { + $._tree.checkAllNodes(false); + } + } else if (type == "3") { + if (checked) { + $._tree.setting.check.chkboxType = { "Y": "ps", "N": "ps" }; + } else { + $._tree.setting.check.chkboxType = { "Y": "", "N": "" }; + } + } + }) + + function add() { + var menuIds = $.tree.getCheckedNodes("goodsCategoryId"); $.ajax({ cache : true, type : "POST", diff --git a/ghy-admin/src/main/resources/templates/goods/deptcategory/deptcategory.html b/ghy-admin/src/main/resources/templates/goods/deptcategory/deptcategory.html index fd93b16b..f5ddcb58 100644 --- a/ghy-admin/src/main/resources/templates/goods/deptcategory/deptcategory.html +++ b/ghy-admin/src/main/resources/templates/goods/deptcategory/deptcategory.html @@ -32,7 +32,7 @@
- + 修改 @@ -50,7 +50,7 @@ var editFlag = [[${@permission.hasPermi('goods:category:edit')}]]; var removeFlag = [[${@permission.hasPermi('goods:category:remove')}]]; var datas = [[${@dict.getType('sys_normal_disable')}]]; - var prefix = ctx + "goods/category" + var prefix = ctx + "goods/deptcategory" $(function() { var options = { @@ -58,6 +58,7 @@ parentCode: "parentCategoryId", uniqueId: "goodsCategoryId", url: prefix + "/list", + addUrl: prefix + "/add/{id}", createUrl: prefix + "/add/{id}", updateUrl: prefix + "/edit/{id}", removeUrl: prefix + "/remove/{id}", diff --git a/ghy-framework/src/main/java/com/ghy/framework/config/ShiroConfig.java b/ghy-framework/src/main/java/com/ghy/framework/config/ShiroConfig.java index 29dd6dd8..cad7ed66 100644 --- a/ghy-framework/src/main/java/com/ghy/framework/config/ShiroConfig.java +++ b/ghy-framework/src/main/java/com/ghy/framework/config/ShiroConfig.java @@ -278,6 +278,7 @@ public class ShiroConfig //部分接口不需要登陆校验 filterChainDefinitionMap.put("/wx/**", "anon"); filterChainDefinitionMap.put("/pay/**", "anon"); + filterChainDefinitionMap.put("/goods/**", "anon"); filterChainDefinitionMap.put("/adapay/**", "anon"); filterChainDefinitionMap.put("/MP_verify_bRFuvYpyQ4WLr0on.txt", "anon"); // 对静态资源设置匿名访问 diff --git a/ghy-goods/src/main/java/com/ghy/goods/service/impl/GoodsCategoryServiceImpl.java b/ghy-goods/src/main/java/com/ghy/goods/service/impl/GoodsCategoryServiceImpl.java index 875b9898..ae939fbe 100644 --- a/ghy-goods/src/main/java/com/ghy/goods/service/impl/GoodsCategoryServiceImpl.java +++ b/ghy-goods/src/main/java/com/ghy/goods/service/impl/GoodsCategoryServiceImpl.java @@ -114,6 +114,7 @@ public class GoodsCategoryServiceImpl implements GoodsCategoryService { ztree.setpId(goodsCategory.getParentCategoryId()); ztree.setName(goodsCategory.getGoodsCategoryName()); ztree.setTitle(goodsCategory.getGoodsCategoryName()); + ztrees.add(ztree); } } From f05e7914b3691f34f6b43d779760871e884e91e4 Mon Sep 17 00:00:00 2001 From: clunt Date: Tue, 10 May 2022 16:02:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=95=86?= =?UTF-8?q?=E5=9F=8E=E6=AE=B5=E9=A6=96=E9=A1=B5=E7=B1=BB=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/GoodsDeptCategoryController.java | 14 ++++- .../ghy/goods/domain/DeptGoodsCategory.java | 9 ++++ .../goods/mapper/DeptGoodsCategoryMapper.java | 3 ++ .../service/GoodsDeptCategoryService.java | 9 +++- .../impl/DeptGoodsCategoryServiceImpl.java | 54 ++++++++++++++++++- .../mapper/goods/DeptGoodsCategoryMapper.xml | 22 +++++++- 6 files changed, 105 insertions(+), 6 deletions(-) diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java index 43462e0d..19bac7ae 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java @@ -1,9 +1,12 @@ package com.ghy.web.controller.goods; import com.ghy.common.core.controller.BaseController; +import com.ghy.common.core.domain.AjaxResult; import com.ghy.common.core.domain.Ztree; +import com.ghy.goods.domain.DeptGoodsCategory; import com.ghy.goods.domain.GoodsCategory; import com.ghy.goods.service.GoodsCategoryService; +import com.ghy.goods.service.GoodsDeptCategoryService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; @@ -20,8 +23,9 @@ public class GoodsDeptCategoryController extends BaseController { @Resource GoodsCategoryService goodsCategoryService; -// @Resource -// GoodsDeptCategoryService goodsDeptCategoryService; + + @Resource + GoodsDeptCategoryService goodsDeptCategoryService; @RequiresPermissions("goods:deptcategory:view") @GetMapping() @@ -54,4 +58,10 @@ public class GoodsDeptCategoryController extends BaseController { return goodsCategoryService.selectCategoryTree(null); } + @PostMapping("/app/list") + @ResponseBody + public AjaxResult appList(@RequestBody DeptGoodsCategory deptGoodsCategory){ + return AjaxResult.success(goodsDeptCategoryService.appList(deptGoodsCategory.getDeptId())); + } + } diff --git a/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java b/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java index f860eba1..91056221 100644 --- a/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java +++ b/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java @@ -4,6 +4,8 @@ import com.ghy.common.annotation.Excel; import com.ghy.common.core.domain.BaseEntity; import lombok.Data; +import java.util.List; + /** * @author clunt * 分公司使用类目 @@ -31,4 +33,11 @@ public class DeptGoodsCategory extends BaseEntity { @Excel(name = "三级分销扣点比例", cellType = Excel.ColumnType.STRING) private String threeRate; + + private Long parentCategoryId; + + private String goodsCategoryName; + + private List child; + } diff --git a/ghy-goods/src/main/java/com/ghy/goods/mapper/DeptGoodsCategoryMapper.java b/ghy-goods/src/main/java/com/ghy/goods/mapper/DeptGoodsCategoryMapper.java index 44e757a4..c902d0b0 100644 --- a/ghy-goods/src/main/java/com/ghy/goods/mapper/DeptGoodsCategoryMapper.java +++ b/ghy-goods/src/main/java/com/ghy/goods/mapper/DeptGoodsCategoryMapper.java @@ -44,4 +44,7 @@ public interface DeptGoodsCategoryMapper { */ int deleteDeptGoodsCategoryByIds(Long[] goodsCategoryId); + + List appList(DeptGoodsCategory deptGoodsCategory); + } diff --git a/ghy-goods/src/main/java/com/ghy/goods/service/GoodsDeptCategoryService.java b/ghy-goods/src/main/java/com/ghy/goods/service/GoodsDeptCategoryService.java index 0749399c..31331125 100644 --- a/ghy-goods/src/main/java/com/ghy/goods/service/GoodsDeptCategoryService.java +++ b/ghy-goods/src/main/java/com/ghy/goods/service/GoodsDeptCategoryService.java @@ -1,11 +1,18 @@ package com.ghy.goods.service; import com.ghy.common.core.domain.Ztree; +import com.ghy.goods.domain.DeptGoodsCategory; import java.util.List; public interface GoodsDeptCategoryService { - List tree(Long parentId); + + /** + * @param deptId 筛选条件 + * @return 父子层级的list + */ + List appList(Long deptId); + } diff --git a/ghy-goods/src/main/java/com/ghy/goods/service/impl/DeptGoodsCategoryServiceImpl.java b/ghy-goods/src/main/java/com/ghy/goods/service/impl/DeptGoodsCategoryServiceImpl.java index 73fd4d56..e1920fc5 100644 --- a/ghy-goods/src/main/java/com/ghy/goods/service/impl/DeptGoodsCategoryServiceImpl.java +++ b/ghy-goods/src/main/java/com/ghy/goods/service/impl/DeptGoodsCategoryServiceImpl.java @@ -1,17 +1,69 @@ package com.ghy.goods.service.impl; +import com.ghy.common.core.domain.Ztree; +import com.ghy.common.utils.StringUtils; +import com.ghy.goods.domain.DeptGoodsCategory; +import com.ghy.goods.mapper.DeptGoodsCategoryMapper; import com.ghy.goods.service.DeptGoodsCategoryService; +import com.ghy.goods.service.GoodsDeptCategoryService; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + /** * @author clunt * 分公司使用类目 */ @Slf4j @Service -public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService { +public class DeptGoodsCategoryServiceImpl implements GoodsDeptCategoryService { + @Autowired + private DeptGoodsCategoryMapper goodsCategoryMapper; + @Override + public List tree(Long parentId) { + return null; + } + @Override + public List appList(Long deptId) { + DeptGoodsCategory deptGoodsCategory = new DeptGoodsCategory(); + deptGoodsCategory.setDeptId(deptId); + // 第一层 + List goodsCategoryList = goodsCategoryMapper.appList(deptGoodsCategory); + // 第二层 + this.fillChild(goodsCategoryList); + // 第三层 + for (DeptGoodsCategory category : goodsCategoryList){ + if(StringUtils.isNotNull(category.getChild())){ + this.fillChild(category.getChild()); + } + } + // 第四层 + for (DeptGoodsCategory category : goodsCategoryList){ + if(StringUtils.isNotNull(category.getChild())){ + for (DeptGoodsCategory result : category.getChild()){ + if(StringUtils.isNotNull(result.getChild())){ + this.fillChild(result.getChild()); + } + } + } + } + return goodsCategoryList; + } + + private void fillChild(List goodsCategoryList){ + List childList; + for (DeptGoodsCategory deptGoodsCategory : goodsCategoryList){ + childList = goodsCategoryMapper.appList(deptGoodsCategory); + if(childList.size()>0){ + deptGoodsCategory.setChild(childList); + } + } + } } diff --git a/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml b/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml index 0f166ef9..a3726c00 100644 --- a/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml +++ b/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml @@ -6,11 +6,12 @@ + + - @@ -19,10 +20,27 @@ - SELECT dept_goods_category_id, dept_id, dept_goods_category_id, category_sort, + SELECT dept_goods_category_id, dept_id, goods_category_id, category_sort, one_rate, two_rate, three_rate, create_by, create_time, remark FROM dept_goods_category + + UPDATE dept_goods_category