完成奇怪的需求若干
This commit is contained in:
parent
07350aa6d5
commit
6dd21f31e7
|
|
@ -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<GoodsCategory> thirdCategories = goodsCategoryService.selectGoodsCategoryList(params);
|
||||
thirdCategoryIds.addAll(thirdCategories.stream().map(GoodsCategory::getGoodsCategoryId).collect(Collectors.toList()));
|
||||
});
|
||||
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<GoodsCategory> filteredCategory = goodsCategoryService.selectGoodsCategoryList(params);
|
||||
List<Long> filteredCategoryIds = filteredCategory.stream().map(GoodsCategory::getGoodsCategoryId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(filteredCategoryIds)) {
|
||||
goods.setDeptGoodsCategoryId(null);
|
||||
goods.setDeptGoodsCategoryIds(filteredCategoryIds);
|
||||
} else {
|
||||
goods.setDeptGoodsCategoryId(-1l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
startPage();
|
||||
|
||||
List<Goods> list = goodsService.selectGoodsList(goods);
|
||||
list.forEach(one -> {
|
||||
// 补全商品服务区域
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -22,4 +22,6 @@ public class WorkerListRequest {
|
|||
private Long workerId;
|
||||
|
||||
private Long exceptParentAreaId;
|
||||
|
||||
private boolean justShowCurWorkerArea;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@ public interface DeptGoodsCategoryService {
|
|||
List<Ztree> tree(Long parentId);
|
||||
|
||||
/**
|
||||
* @param deptId 筛选条件
|
||||
* @param deptGoodsCategory 筛选条件
|
||||
* @return 父子层级的list
|
||||
*/
|
||||
List<DeptGoodsCategory> appList(Long deptId);
|
||||
List<DeptGoodsCategory> appList(DeptGoodsCategory deptGoodsCategory);
|
||||
|
||||
/**
|
||||
* @param deptGoodsCategory 查询条件
|
||||
|
|
|
|||
|
|
@ -66,9 +66,7 @@ public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<DeptGoodsCategory> appList(Long deptId) {
|
||||
DeptGoodsCategory deptGoodsCategory = new DeptGoodsCategory();
|
||||
deptGoodsCategory.setDeptId(deptId);
|
||||
public List<DeptGoodsCategory> appList(DeptGoodsCategory deptGoodsCategory) {
|
||||
// 第一层
|
||||
List<DeptGoodsCategory> goodsCategoryList = deptGoodsCategoryMapper.appList(deptGoodsCategory);
|
||||
// 第二层
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@
|
|||
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">
|
||||
AND dept_goods_category_id = #{deptGoodsCategoryId}
|
||||
</if>
|
||||
<if test="deptGoodsCategoryIds != null">
|
||||
<if test="deptGoodsCategoryIds != null and deptGoodsCategoryIds.size > 0">
|
||||
AND dept_goods_category_id in
|
||||
<foreach collection="deptGoodsCategoryIds" item="deptGoodsCategoryId" open="(" separator="," close=")">
|
||||
#{deptGoodsCategoryId}
|
||||
|
|
|
|||
|
|
@ -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<Long> districtIds;
|
||||
|
||||
@Excel(name = "街道区域id", cellType = Excel.ColumnType.NUMERIC)
|
||||
private Long streetId;
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,16 @@
|
|||
<include refid="selectWorkerArea"></include>
|
||||
<where>
|
||||
<if test="districtId != null">
|
||||
AND district_id = #{districtId}
|
||||
AND wa.district_id = #{districtId}
|
||||
</if>
|
||||
<if test="districtIds != null and districtIds.size > 0">
|
||||
AND wa.district_id in
|
||||
<foreach collection="districtIds" item="districtId" open="(" separator="," close=")">
|
||||
#{districtId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="workerId != null">
|
||||
AND wa.worker_id = #{workerId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in New Issue