From f05e7914b3691f34f6b43d779760871e884e91e4 Mon Sep 17 00:00:00 2001 From: clunt Date: Tue, 10 May 2022 16:02:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=95=86=E5=9F=8E?= =?UTF-8?q?=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