根据类目条件查询商品及师傅列表接口修改
This commit is contained in:
parent
a6f90fb51c
commit
8fea394012
|
|
@ -31,6 +31,8 @@ public class GoodsController extends BaseController {
|
|||
@Resource
|
||||
private DeptGoodsCategoryService deptGoodsCategoryService;
|
||||
@Resource
|
||||
private GoodsCategoryService goodsCategoryService;
|
||||
@Resource
|
||||
private GoodsImgsService goodsImgsService;
|
||||
@Resource
|
||||
private GoodsAreaService goodsAreaService;
|
||||
|
|
@ -65,6 +67,21 @@ public class GoodsController extends BaseController {
|
|||
@ResponseBody
|
||||
public TableDataInfo appList(@RequestBody Goods goods) {
|
||||
startPage();
|
||||
|
||||
// 判断类目id是否为第三级,不是的话需要找到所有符合条件的第三级类目id作为新的条件
|
||||
if (goods.getDeptGoodsCategoryId() != null) {
|
||||
GoodsCategory goodsCategory = goodsCategoryService.selectById(goods.getDeptGoodsCategoryId());
|
||||
if (goodsCategory.getLevel() == 0) {
|
||||
goods.setDeptGoodsCategoryId(null);
|
||||
} else if (goodsCategory.getLevel() == 1) {
|
||||
GoodsCategory params = new GoodsCategory();
|
||||
params.setParentCategoryId(goodsCategory.getGoodsCategoryId());
|
||||
List<GoodsCategory> filteredCategory = goodsCategoryService.selectGoodsCategoryList(params);
|
||||
List<Long> filteredCategoryIds = filteredCategory.stream().map(GoodsCategory::getGoodsCategoryId).collect(Collectors.toList());
|
||||
goods.setDeptGoodsCategoryId(null);
|
||||
goods.setDeptGoodsCategoryIds(filteredCategoryIds);
|
||||
}
|
||||
}
|
||||
List<Goods> list = goodsService.selectGoodsList(goods);
|
||||
list.forEach(one -> {
|
||||
// 补全商品
|
||||
|
|
|
|||
|
|
@ -15,9 +15,11 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
|
|
@ -63,6 +65,29 @@ public class GoodsDeptCategoryController extends BaseController {
|
|||
|
||||
}
|
||||
|
||||
@PostMapping("/app/listByStep")
|
||||
@ResponseBody
|
||||
public AjaxResult appListByStep(@RequestBody DeptGoodsCategory deptGoodsCategory) {
|
||||
List<DeptGoodsCategory> resList = new ArrayList<DeptGoodsCategory>();
|
||||
try {
|
||||
if (deptGoodsCategory.getIsAllNode() == null || !deptGoodsCategory.getIsAllNode()) {
|
||||
List<DeptGoodsCategory> list = deptGoodsCategoryService.listByStep(deptGoodsCategory);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
DeptGoodsCategory allGoodsNode = new DeptGoodsCategory();
|
||||
allGoodsNode.setGoodsCategoryName("全部");
|
||||
allGoodsNode.setIsAllNode(true);
|
||||
resList.add(allGoodsNode);
|
||||
resList.addAll(list);
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(resList);
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequiresPermissions("goods:deptcategory:edit")
|
||||
@GetMapping("/edit/{id}")
|
||||
public String edit(@PathVariable("id") Long id, ModelMap mmap) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import com.ghy.common.enums.GoodsStatus;
|
|||
import com.ghy.common.enums.WorkerStatus;
|
||||
import com.ghy.common.utils.ExceptionUtil;
|
||||
import com.ghy.goods.domain.Goods;
|
||||
import com.ghy.goods.domain.GoodsCategory;
|
||||
import com.ghy.goods.service.GoodsCategoryService;
|
||||
import com.ghy.goods.service.GoodsService;
|
||||
import com.ghy.web.pojo.vo.WorkerListRequest;
|
||||
import com.ghy.web.pojo.vo.WorkerListResponse;
|
||||
|
|
@ -55,6 +57,9 @@ public class WorkerController extends BaseController {
|
|||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
|
||||
@Autowired
|
||||
private GoodsCategoryService goodsCategoryService;
|
||||
|
||||
@Autowired
|
||||
private WorkerBankService workerBankService;
|
||||
|
||||
|
|
@ -128,7 +133,22 @@ public class WorkerController extends BaseController {
|
|||
List<Long> workerIdsByArea = workerAreaList.stream().map(WorkerArea::getWorkerId).collect(Collectors.toList());
|
||||
// 查询满足技能条件的师傅技能记录
|
||||
WorkerGoodsCategory workerGoodsCategory = new WorkerGoodsCategory();
|
||||
workerGoodsCategory.setGoodsCategoryId(workerListRequest.getGoodsCategoryId());
|
||||
// 判断类目id是否为第三级,不是的话需要找到所有符合条件的第三级类目id作为新的条件
|
||||
if (workerListRequest.getGoodsCategoryId() != null) {
|
||||
GoodsCategory goodsCategory = goodsCategoryService.selectById(workerListRequest.getGoodsCategoryId());
|
||||
if (goodsCategory.getLevel() == 0) {
|
||||
workerGoodsCategory.setGoodsCategoryId(null);
|
||||
} else if (goodsCategory.getLevel() == 1) {
|
||||
GoodsCategory params = new GoodsCategory();
|
||||
params.setParentCategoryId(goodsCategory.getGoodsCategoryId());
|
||||
List<GoodsCategory> filteredCategory = goodsCategoryService.selectGoodsCategoryList(params);
|
||||
List<Long> filteredCategoryIds = filteredCategory.stream().map(GoodsCategory::getGoodsCategoryId).collect(Collectors.toList());
|
||||
workerGoodsCategory.setGoodsCategoryId(null);
|
||||
workerGoodsCategory.setGoodsCategoryIds(filteredCategoryIds);
|
||||
} else {
|
||||
workerGoodsCategory.setGoodsCategoryId(workerListRequest.getGoodsCategoryId());
|
||||
}
|
||||
}
|
||||
List<WorkerGoodsCategory> workerGoodsCategoryList = workerGoodsCategoryService.getWorkerGoodsCategory(workerGoodsCategory);
|
||||
List<Long> workerIdsByCategory = workerGoodsCategoryList.stream().map(WorkerGoodsCategory::getWorkerId).collect(Collectors.toList());
|
||||
// 两个list中的workerid取交集
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class DeptGoodsCategory extends GoodsCategory {
|
|||
|
||||
@Excel(name = "分公司id", cellType = Excel.ColumnType.NUMERIC)
|
||||
private Long deptId;
|
||||
|
||||
|
||||
@Excel(name = "分公司备注类目名称", cellType = Excel.ColumnType.STRING)
|
||||
private String deptCategoryName;
|
||||
|
||||
|
|
@ -52,4 +52,5 @@ public class DeptGoodsCategory extends GoodsCategory {
|
|||
|
||||
private List<DeptGoodsCategory> child;
|
||||
|
||||
private Boolean isAllNode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ public class Goods extends BaseEntity {
|
|||
@Excel(name = "类别id,必须是关联到系统的第三级目录")
|
||||
private Long deptGoodsCategoryId;
|
||||
|
||||
private List<Long> deptGoodsCategoryIds;
|
||||
|
||||
@Excel(name = "商品图片", cellType = Excel.ColumnType.IMAGE)
|
||||
private String goodsImgUrl;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ public interface GoodsCategoryService {
|
|||
*/
|
||||
List<GoodsCategory> selectGoodsCategoryList(GoodsCategory goodsCategory);
|
||||
|
||||
|
||||
/**
|
||||
* 查询类目管理树
|
||||
*
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@
|
|||
<if test="goodsCategoryName != null and goodsCategoryName != ''">
|
||||
AND goods_category_name LIKE concat('%', #{goodsCategoryName}, '%')
|
||||
</if>
|
||||
<if test="parentCategoryId != null">
|
||||
AND parent_category_id = #{parentCategoryId}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
|
|
@ -108,4 +111,4 @@
|
|||
#{goodsCategoryId}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -94,6 +94,11 @@
|
|||
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">
|
||||
AND dept_goods_category_id = #{deptGoodsCategoryId}
|
||||
</if>
|
||||
<if test="deptGoodsCategoryIds != null">
|
||||
<foreach collection="deptGoodsCategoryIds" item="deptGoodsCategoryId" open="(" separator="," close=")">
|
||||
#{deptGoodsCategoryId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="areaId != null and areaId != ''">
|
||||
AND country_area_id = #{areaId}
|
||||
</if>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.ghy.worker.domain;
|
|||
import com.ghy.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 师傅服务类目
|
||||
*
|
||||
|
|
@ -27,4 +29,6 @@ public class WorkerGoodsCategory extends BaseEntity {
|
|||
private Long goodsCategoryId;
|
||||
|
||||
private String goodsCategoryName;
|
||||
|
||||
private List<Long> goodsCategoryIds;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,11 @@
|
|||
<if test="goodsCategoryId != null">
|
||||
AND wgc.goods_category_id = #{goodsCategoryId}
|
||||
</if>
|
||||
<if test="goodsCategoryIds != null">
|
||||
<foreach collection="goodsCategoryIds" item="goodsCategoryId" open="(" separator="," close=")">
|
||||
#{goodsCategoryId}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue