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..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,14 +1,16 @@ 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; -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; @@ -21,8 +23,9 @@ public class GoodsDeptCategoryController extends BaseController { @Resource GoodsCategoryService goodsCategoryService; -// @Resource -// GoodsDeptCategoryService goodsDeptCategoryService; + + @Resource + GoodsDeptCategoryService goodsDeptCategoryService; @RequiresPermissions("goods:deptcategory:view") @GetMapping() @@ -32,11 +35,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() { @@ -45,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-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/domain/DeptGoodsCategory.java b/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java index 44f39ae1..24590fe9 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 * 分公司使用类目 @@ -38,4 +40,8 @@ public class DeptGoodsCategory extends BaseEntity { @Excel(name = "三级分销扣点比例", cellType = Excel.ColumnType.STRING) private String threeRate; + private Long parentCategoryId; + + 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 f13e576f..e8c91dd3 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 @@ -45,4 +45,7 @@ public interface DeptGoodsCategoryMapper { */ int deleteDeptGoodsCategoryByIds(Collection 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 0ef5de7d..81051500 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,5 +1,7 @@ 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.domain.GoodsCategory; import com.ghy.goods.mapper.DeptGoodsCategoryMapper; @@ -20,6 +22,8 @@ import java.util.stream.Collectors; @Service public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService { + @Resource + private DeptGoodsCategoryMapper goodsCategoryMapper; @Resource GoodsCategoryService goodsCategoryService; @Resource @@ -65,4 +69,46 @@ public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService { public DeptGoodsCategory get(long id) { return deptGoodsCategoryMapper.selectById(id); } + + @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/java/com/ghy/goods/service/impl/GoodsCategoryServiceImpl.java b/ghy-goods/src/main/java/com/ghy/goods/service/impl/GoodsCategoryServiceImpl.java index 61f8508c..4451d15f 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); } } diff --git a/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml b/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml index a1b61805..6bfc9083 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 @@ + + - @@ -23,6 +24,23 @@ one_rate, two_rate, three_rate, create_by, create_time, remark FROM dept_goods_category + + UPDATE dept_goods_category