diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsController.java b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsController.java index 8829e7f6..e610de5d 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsController.java @@ -11,6 +11,7 @@ import com.ghy.common.utils.StringUtils; import com.ghy.common.utils.poi.ExcelUtil; import com.ghy.goods.domain.*; import com.ghy.goods.service.*; +import org.apache.commons.collections.CollectionUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; @@ -67,11 +68,11 @@ public class GoodsController extends BaseController { @PostMapping("/app/list") @ResponseBody public TableDataInfo appList(@RequestBody Goods goods) { - startPage(); - // 判断类目id是否为第三级,不是的话需要找到所有符合条件的第三级类目id作为新的条件 if (goods.getDeptGoodsCategoryId() != null) { + logger.info("入参:" + goods.getDeptGoodsCategoryId()); GoodsCategory goodsCategory = goodsCategoryService.selectById(goods.getDeptGoodsCategoryId()); + logger.info("查询到的类目:" + goodsCategory); if (goodsCategory.getLevel() == 0) { goods.setDeptGoodsCategoryId(null); } else if (goodsCategory.getLevel() == 1) { @@ -85,17 +86,28 @@ public class GoodsController extends BaseController { List thirdCategories = goodsCategoryService.selectGoodsCategoryList(params); thirdCategoryIds.addAll(thirdCategories.stream().map(GoodsCategory::getGoodsCategoryId).collect(Collectors.toList())); }); - goods.setDeptGoodsCategoryId(null); - goods.setDeptGoodsCategoryIds(thirdCategoryIds); + if (CollectionUtils.isNotEmpty(thirdCategoryIds)) { + goods.setDeptGoodsCategoryId(null); + goods.setDeptGoodsCategoryIds(thirdCategoryIds); + } else { + goods.setDeptGoodsCategoryId(-1l); + } } else if (goodsCategory.getLevel() == 2) { GoodsCategory params = new GoodsCategory(); params.setParentCategoryId(goodsCategory.getGoodsCategoryId()); List filteredCategory = goodsCategoryService.selectGoodsCategoryList(params); List filteredCategoryIds = filteredCategory.stream().map(GoodsCategory::getGoodsCategoryId).collect(Collectors.toList()); - goods.setDeptGoodsCategoryId(null); - goods.setDeptGoodsCategoryIds(filteredCategoryIds); + if (CollectionUtils.isNotEmpty(filteredCategoryIds)) { + goods.setDeptGoodsCategoryId(null); + goods.setDeptGoodsCategoryIds(filteredCategoryIds); + } else { + goods.setDeptGoodsCategoryId(-1l); + } } } + + startPage(); + List list = goodsService.selectGoodsList(goods); list.forEach(one -> { // 补全商品服务区域 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 5dc4c370..4b52fc47 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 @@ -175,7 +175,7 @@ public class GoodsDeptCategoryController extends BaseController { @PostMapping("/app/list") @ResponseBody public AjaxResult appList(@RequestBody DeptGoodsCategory deptGoodsCategory) { - return AjaxResult.success(deptGoodsCategoryService.appList(deptGoodsCategory.getDeptId())); + return AjaxResult.success(deptGoodsCategoryService.appList(deptGoodsCategory)); } @PostMapping("/app/category") diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/worker/WorkerController.java b/ghy-admin/src/main/java/com/ghy/web/controller/worker/WorkerController.java index 6a36c879..9a0ee323 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/worker/WorkerController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/worker/WorkerController.java @@ -245,7 +245,15 @@ public class WorkerController extends BaseController { goods.setStatus(Integer.valueOf(GoodsStatus.OK.getCode())); WorkerListResponse workerListResponse = JSONObject.parseObject(JSON.toJSONString(w), WorkerListResponse.class); workerListResponse.setGoodsList(goodsService.selectGoodsList(goods)); - workerListResponse.setWorkerAreas(workerAreaService.getByWorker(w.getWorkerId())); + if (workerListRequest.isJustShowCurWorkerArea()) { + workerListResponse.setWorkerAreas(workerAreaService.getWorkerAreaList(new WorkerArea(){{ + setWorkerId(w.getWorkerId()); + setDistrictId(worker.getDistrictId()); + setDistrictIds(worker.getDistrictIds()); + }})); + } else { + workerListResponse.setWorkerAreas(workerAreaService.getByWorker(w.getWorkerId())); + } workerListResponse.setGoodsCategories(workerGoodsCategoryService.getByWorker(w.getWorkerId())); workerListResponse.setSpecialSkills(specialSkillService.getByWorker(w.getWorkerId())); resList.add(workerListResponse); diff --git a/ghy-admin/src/main/java/com/ghy/web/pojo/vo/WorkerListRequest.java b/ghy-admin/src/main/java/com/ghy/web/pojo/vo/WorkerListRequest.java index eab56087..8716ffe5 100644 --- a/ghy-admin/src/main/java/com/ghy/web/pojo/vo/WorkerListRequest.java +++ b/ghy-admin/src/main/java/com/ghy/web/pojo/vo/WorkerListRequest.java @@ -22,4 +22,6 @@ public class WorkerListRequest { private Long workerId; private Long exceptParentAreaId; + + private boolean justShowCurWorkerArea; } diff --git a/ghy-goods/src/main/java/com/ghy/goods/service/DeptGoodsCategoryService.java b/ghy-goods/src/main/java/com/ghy/goods/service/DeptGoodsCategoryService.java index 5cbc5f68..7fe28156 100644 --- a/ghy-goods/src/main/java/com/ghy/goods/service/DeptGoodsCategoryService.java +++ b/ghy-goods/src/main/java/com/ghy/goods/service/DeptGoodsCategoryService.java @@ -53,10 +53,10 @@ public interface DeptGoodsCategoryService { List tree(Long parentId); /** - * @param deptId 筛选条件 + * @param deptGoodsCategory 筛选条件 * @return 父子层级的list */ - List appList(Long deptId); + List appList(DeptGoodsCategory deptGoodsCategory); /** * @param deptGoodsCategory 查询条件 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 78beade6..61398106 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 @@ -66,9 +66,7 @@ public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService { } @Override - public List appList(Long deptId) { - DeptGoodsCategory deptGoodsCategory = new DeptGoodsCategory(); - deptGoodsCategory.setDeptId(deptId); + public List appList(DeptGoodsCategory deptGoodsCategory) { // 第一层 List goodsCategoryList = deptGoodsCategoryMapper.appList(deptGoodsCategory); // 第二层 diff --git a/ghy-goods/src/main/resources/mapper/goods/GoodsMapper.xml b/ghy-goods/src/main/resources/mapper/goods/GoodsMapper.xml index 5f1bcc28..f700386e 100644 --- a/ghy-goods/src/main/resources/mapper/goods/GoodsMapper.xml +++ b/ghy-goods/src/main/resources/mapper/goods/GoodsMapper.xml @@ -101,7 +101,7 @@ AND dept_goods_category_id = #{deptGoodsCategoryId} - + AND dept_goods_category_id in #{deptGoodsCategoryId} diff --git a/ghy-worker/src/main/java/com/ghy/worker/domain/WorkerArea.java b/ghy-worker/src/main/java/com/ghy/worker/domain/WorkerArea.java index f480e2fd..5fe4fe2a 100644 --- a/ghy-worker/src/main/java/com/ghy/worker/domain/WorkerArea.java +++ b/ghy-worker/src/main/java/com/ghy/worker/domain/WorkerArea.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 * 师傅服务区域 @@ -26,6 +28,8 @@ public class WorkerArea extends BaseEntity { @Excel(name = "区/县区域id", cellType = Excel.ColumnType.NUMERIC) private Long districtId; + private List districtIds; + @Excel(name = "街道区域id", cellType = Excel.ColumnType.NUMERIC) private Long streetId; diff --git a/ghy-worker/src/main/resources/mapper/worker/WorkerAreaMapper.xml b/ghy-worker/src/main/resources/mapper/worker/WorkerAreaMapper.xml index a6bbc42b..78af8f7b 100644 --- a/ghy-worker/src/main/resources/mapper/worker/WorkerAreaMapper.xml +++ b/ghy-worker/src/main/resources/mapper/worker/WorkerAreaMapper.xml @@ -64,7 +64,16 @@ - AND district_id = #{districtId} + AND wa.district_id = #{districtId} + + + AND wa.district_id in + + #{districtId} + + + + AND wa.worker_id = #{workerId}