入驻区域/类目编辑
This commit is contained in:
parent
39b6a6ea09
commit
28fa9f30d7
|
|
@ -2,17 +2,20 @@ package com.ghy.web.controller.worker;
|
||||||
|
|
||||||
import com.ghy.common.core.domain.AjaxResult;
|
import com.ghy.common.core.domain.AjaxResult;
|
||||||
import com.ghy.common.core.text.Convert;
|
import com.ghy.common.core.text.Convert;
|
||||||
|
import com.ghy.system.domain.SysArea;
|
||||||
|
import com.ghy.system.service.ISysAreaService;
|
||||||
import com.ghy.worker.domain.WorkerArea;
|
import com.ghy.worker.domain.WorkerArea;
|
||||||
import com.ghy.worker.request.WorkerAreaSaveRequest;
|
import com.ghy.worker.request.WorkerAreaSaveRequest;
|
||||||
import com.ghy.worker.service.WorkerAreaService;
|
import com.ghy.worker.service.WorkerAreaService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
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.Set;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -28,6 +31,9 @@ public class WorkerAreaController {
|
||||||
@Resource
|
@Resource
|
||||||
private WorkerAreaService workerAreaService;
|
private WorkerAreaService workerAreaService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysAreaService sysAreaService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询某个师傅的所有接单地区
|
* 查询某个师傅的所有接单地区
|
||||||
*
|
*
|
||||||
|
|
@ -39,6 +45,36 @@ public class WorkerAreaController {
|
||||||
return AjaxResult.success(workerAreaService.getByWorker(workerId));
|
return AjaxResult.success(workerAreaService.getByWorker(workerId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("worker/edit")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult getEditWorker(Long workerId){
|
||||||
|
Map<Long, List<String>> countryMap = new HashMap<>();
|
||||||
|
List<WorkerArea> byWorker = workerAreaService.getByWorker(workerId);
|
||||||
|
for (WorkerArea area : byWorker){
|
||||||
|
List<String> ids;
|
||||||
|
if(countryMap.containsKey(area.getDistrictId())){
|
||||||
|
ids = countryMap.get(area.getDistrictId());
|
||||||
|
}else {
|
||||||
|
ids = new ArrayList<>();
|
||||||
|
}
|
||||||
|
ids.add(String.valueOf(area.getStreetId()));
|
||||||
|
countryMap.put(area.getDistrictId(), ids);
|
||||||
|
}
|
||||||
|
List<WorkerArea> result = new ArrayList<>();
|
||||||
|
for (Map.Entry<Long, List<String>> longListEntry : countryMap.entrySet()) {
|
||||||
|
WorkerArea model = new WorkerArea();
|
||||||
|
SysArea countryArea = sysAreaService.selectById(longListEntry.getKey());
|
||||||
|
model.setDistrictArea(countryArea);
|
||||||
|
SysArea cityArea = sysAreaService.selectById(Long.valueOf(countryArea.getParentCode()));
|
||||||
|
model.setCityArea(cityArea);
|
||||||
|
SysArea provinceArea = sysAreaService.selectById(Long.valueOf(cityArea.getParentCode()));
|
||||||
|
model.setProvinceArea(provinceArea);
|
||||||
|
model.setStreetIds(longListEntry.getValue());
|
||||||
|
result.add(model);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("save")
|
@PostMapping("save")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,7 @@ 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.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -61,6 +58,37 @@ public class WorkerGoodsCategoryController {
|
||||||
}
|
}
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
@GetMapping("worker/edit")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult getEditWorker(Long workerId) {
|
||||||
|
Map<Long, List<String>> twoMap = new HashMap<>();
|
||||||
|
List<WorkerGoodsCategory> list = workerGoodsCategoryService.getByWorker(workerId);
|
||||||
|
if(CollectionUtils.isEmpty(list)){
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
for (WorkerGoodsCategory item: list) {
|
||||||
|
List<String> ids;
|
||||||
|
GoodsCategory goodsCategory = goodsCategoryService.selectById(item.getGoodsCategoryId());
|
||||||
|
if(twoMap.containsKey(goodsCategory.getParentCategoryId())){
|
||||||
|
ids = twoMap.get(goodsCategory.getParentCategoryId());
|
||||||
|
}else {
|
||||||
|
ids = new ArrayList<>();
|
||||||
|
}
|
||||||
|
ids.add(String.valueOf(goodsCategory.getGoodsCategoryId()));
|
||||||
|
twoMap.put(goodsCategory.getParentCategoryId(), ids);
|
||||||
|
}
|
||||||
|
List<WorkerGoodsCategory> result = new ArrayList<>();
|
||||||
|
for (Map.Entry<Long, List<String>> longListEntry : twoMap.entrySet()) {
|
||||||
|
WorkerGoodsCategory model = new WorkerGoodsCategory();
|
||||||
|
GoodsCategory goodsCategory = goodsCategoryService.selectById(longListEntry.getKey());
|
||||||
|
model.setTwoGoodsCategory(goodsCategory);
|
||||||
|
model.setOneGoodsCategory(goodsCategoryService.selectById(goodsCategory.getParentCategoryId()));
|
||||||
|
model.setCategoryIds(longListEntry.getValue());
|
||||||
|
result.add(model);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("save")
|
@PostMapping("save")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,10 @@
|
||||||
<groupId>com.ghy</groupId>
|
<groupId>com.ghy</groupId>
|
||||||
<artifactId>ghy-goods</artifactId>
|
<artifactId>ghy-goods</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ghy</groupId>
|
||||||
|
<artifactId>ghy-system</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ghy.worker.domain;
|
||||||
|
|
||||||
import com.ghy.common.annotation.Excel;
|
import com.ghy.common.annotation.Excel;
|
||||||
import com.ghy.common.core.domain.BaseEntity;
|
import com.ghy.common.core.domain.BaseEntity;
|
||||||
|
import com.ghy.system.domain.SysArea;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -21,17 +22,22 @@ public class WorkerArea extends BaseEntity {
|
||||||
|
|
||||||
@Excel(name = "省份区域id", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "省份区域id", cellType = Excel.ColumnType.NUMERIC)
|
||||||
private Long provinceId;
|
private Long provinceId;
|
||||||
|
private SysArea provinceArea;
|
||||||
|
|
||||||
@Excel(name = "市区域id", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "市区域id", cellType = Excel.ColumnType.NUMERIC)
|
||||||
private Long cityId;
|
private Long cityId;
|
||||||
|
private SysArea cityArea;
|
||||||
|
|
||||||
@Excel(name = "区/县区域id", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "区/县区域id", cellType = Excel.ColumnType.NUMERIC)
|
||||||
private Long districtId;
|
private Long districtId;
|
||||||
|
private SysArea districtArea;
|
||||||
|
|
||||||
private List<Long> districtIds;
|
private List<Long> districtIds;
|
||||||
|
|
||||||
@Excel(name = "街道区域id", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "街道区域id", cellType = Excel.ColumnType.NUMERIC)
|
||||||
private Long streetId;
|
private Long streetId;
|
||||||
|
|
||||||
|
private List<String> streetIds;
|
||||||
|
|
||||||
private String mergerName;
|
private String mergerName;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ghy.worker.domain;
|
package com.ghy.worker.domain;
|
||||||
|
|
||||||
import com.ghy.common.core.domain.BaseEntity;
|
import com.ghy.common.core.domain.BaseEntity;
|
||||||
|
import com.ghy.goods.domain.GoodsCategory;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -28,6 +29,12 @@ public class WorkerGoodsCategory extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private Long goodsCategoryId;
|
private Long goodsCategoryId;
|
||||||
|
|
||||||
|
private GoodsCategory oneGoodsCategory;
|
||||||
|
|
||||||
|
private GoodsCategory twoGoodsCategory;
|
||||||
|
|
||||||
|
private List<String> categoryIds;
|
||||||
|
|
||||||
private String goodsCategoryName;
|
private String goodsCategoryName;
|
||||||
|
|
||||||
private String mergeName;
|
private String mergeName;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue