根据类目条件查询商品及师傅列表接口修改
This commit is contained in:
parent
a6f90fb51c
commit
8fea394012
|
|
@ -31,6 +31,8 @@ public class GoodsController extends BaseController {
|
||||||
@Resource
|
@Resource
|
||||||
private DeptGoodsCategoryService deptGoodsCategoryService;
|
private DeptGoodsCategoryService deptGoodsCategoryService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private GoodsCategoryService goodsCategoryService;
|
||||||
|
@Resource
|
||||||
private GoodsImgsService goodsImgsService;
|
private GoodsImgsService goodsImgsService;
|
||||||
@Resource
|
@Resource
|
||||||
private GoodsAreaService goodsAreaService;
|
private GoodsAreaService goodsAreaService;
|
||||||
|
|
@ -65,6 +67,21 @@ public class GoodsController extends BaseController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo appList(@RequestBody Goods goods) {
|
public TableDataInfo appList(@RequestBody Goods goods) {
|
||||||
startPage();
|
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<Goods> list = goodsService.selectGoodsList(goods);
|
||||||
list.forEach(one -> {
|
list.forEach(one -> {
|
||||||
// 补全商品
|
// 补全商品
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,11 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@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")
|
@RequiresPermissions("goods:deptcategory:edit")
|
||||||
@GetMapping("/edit/{id}")
|
@GetMapping("/edit/{id}")
|
||||||
public String edit(@PathVariable("id") Long id, ModelMap mmap) {
|
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.enums.WorkerStatus;
|
||||||
import com.ghy.common.utils.ExceptionUtil;
|
import com.ghy.common.utils.ExceptionUtil;
|
||||||
import com.ghy.goods.domain.Goods;
|
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.goods.service.GoodsService;
|
||||||
import com.ghy.web.pojo.vo.WorkerListRequest;
|
import com.ghy.web.pojo.vo.WorkerListRequest;
|
||||||
import com.ghy.web.pojo.vo.WorkerListResponse;
|
import com.ghy.web.pojo.vo.WorkerListResponse;
|
||||||
|
|
@ -55,6 +57,9 @@ public class WorkerController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private GoodsService goodsService;
|
private GoodsService goodsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GoodsCategoryService goodsCategoryService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WorkerBankService workerBankService;
|
private WorkerBankService workerBankService;
|
||||||
|
|
||||||
|
|
@ -128,7 +133,22 @@ public class WorkerController extends BaseController {
|
||||||
List<Long> workerIdsByArea = workerAreaList.stream().map(WorkerArea::getWorkerId).collect(Collectors.toList());
|
List<Long> workerIdsByArea = workerAreaList.stream().map(WorkerArea::getWorkerId).collect(Collectors.toList());
|
||||||
// 查询满足技能条件的师傅技能记录
|
// 查询满足技能条件的师傅技能记录
|
||||||
WorkerGoodsCategory workerGoodsCategory = new WorkerGoodsCategory();
|
WorkerGoodsCategory workerGoodsCategory = new WorkerGoodsCategory();
|
||||||
|
// 判断类目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());
|
workerGoodsCategory.setGoodsCategoryId(workerListRequest.getGoodsCategoryId());
|
||||||
|
}
|
||||||
|
}
|
||||||
List<WorkerGoodsCategory> workerGoodsCategoryList = workerGoodsCategoryService.getWorkerGoodsCategory(workerGoodsCategory);
|
List<WorkerGoodsCategory> workerGoodsCategoryList = workerGoodsCategoryService.getWorkerGoodsCategory(workerGoodsCategory);
|
||||||
List<Long> workerIdsByCategory = workerGoodsCategoryList.stream().map(WorkerGoodsCategory::getWorkerId).collect(Collectors.toList());
|
List<Long> workerIdsByCategory = workerGoodsCategoryList.stream().map(WorkerGoodsCategory::getWorkerId).collect(Collectors.toList());
|
||||||
// 两个list中的workerid取交集
|
// 两个list中的workerid取交集
|
||||||
|
|
|
||||||
|
|
@ -52,4 +52,5 @@ public class DeptGoodsCategory extends GoodsCategory {
|
||||||
|
|
||||||
private List<DeptGoodsCategory> child;
|
private List<DeptGoodsCategory> child;
|
||||||
|
|
||||||
|
private Boolean isAllNode;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ public class Goods extends BaseEntity {
|
||||||
@Excel(name = "类别id,必须是关联到系统的第三级目录")
|
@Excel(name = "类别id,必须是关联到系统的第三级目录")
|
||||||
private Long deptGoodsCategoryId;
|
private Long deptGoodsCategoryId;
|
||||||
|
|
||||||
|
private List<Long> deptGoodsCategoryIds;
|
||||||
|
|
||||||
@Excel(name = "商品图片", cellType = Excel.ColumnType.IMAGE)
|
@Excel(name = "商品图片", cellType = Excel.ColumnType.IMAGE)
|
||||||
private String goodsImgUrl;
|
private String goodsImgUrl;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ public interface GoodsCategoryService {
|
||||||
*/
|
*/
|
||||||
List<GoodsCategory> selectGoodsCategoryList(GoodsCategory goodsCategory);
|
List<GoodsCategory> selectGoodsCategoryList(GoodsCategory goodsCategory);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询类目管理树
|
* 查询类目管理树
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,9 @@
|
||||||
<if test="goodsCategoryName != null and goodsCategoryName != ''">
|
<if test="goodsCategoryName != null and goodsCategoryName != ''">
|
||||||
AND goods_category_name LIKE concat('%', #{goodsCategoryName}, '%')
|
AND goods_category_name LIKE concat('%', #{goodsCategoryName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="parentCategoryId != null">
|
||||||
|
AND parent_category_id = #{parentCategoryId}
|
||||||
|
</if>
|
||||||
<if test="status != null and status != ''">
|
<if test="status != null and status != ''">
|
||||||
AND status = #{status}
|
AND status = #{status}
|
||||||
</if>
|
</if>
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,11 @@
|
||||||
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">
|
||||||
AND dept_goods_category_id = #{deptGoodsCategoryId}
|
AND dept_goods_category_id = #{deptGoodsCategoryId}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="deptGoodsCategoryIds != null">
|
||||||
|
<foreach collection="deptGoodsCategoryIds" item="deptGoodsCategoryId" open="(" separator="," close=")">
|
||||||
|
#{deptGoodsCategoryId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
<if test="areaId != null and areaId != ''">
|
<if test="areaId != null and areaId != ''">
|
||||||
AND country_area_id = #{areaId}
|
AND country_area_id = #{areaId}
|
||||||
</if>
|
</if>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ package com.ghy.worker.domain;
|
||||||
import com.ghy.common.core.domain.BaseEntity;
|
import com.ghy.common.core.domain.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 师傅服务类目
|
* 师傅服务类目
|
||||||
*
|
*
|
||||||
|
|
@ -27,4 +29,6 @@ public class WorkerGoodsCategory extends BaseEntity {
|
||||||
private Long goodsCategoryId;
|
private Long goodsCategoryId;
|
||||||
|
|
||||||
private String goodsCategoryName;
|
private String goodsCategoryName;
|
||||||
|
|
||||||
|
private List<Long> goodsCategoryIds;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,11 @@
|
||||||
<if test="goodsCategoryId != null">
|
<if test="goodsCategoryId != null">
|
||||||
AND wgc.goods_category_id = #{goodsCategoryId}
|
AND wgc.goods_category_id = #{goodsCategoryId}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="goodsCategoryIds != null">
|
||||||
|
<foreach collection="goodsCategoryIds" item="goodsCategoryId" open="(" separator="," close=")">
|
||||||
|
#{goodsCategoryId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue