增加省市显示
This commit is contained in:
parent
57d5161b2c
commit
49394a5172
|
|
@ -95,9 +95,24 @@ public class WorkerAreaController extends BaseController {
|
|||
|
||||
@GetMapping("worker/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult getEditWorker(Long workerId){
|
||||
public AjaxResult getEditWorker(Long workerId, Integer type){
|
||||
Map<Long, List<String>> countryMap = new HashMap<>();
|
||||
List<WorkerArea> byWorker = workerAreaService.getByWorker(workerId);
|
||||
|
||||
// 需求1:根据类型查询对应的区域数据
|
||||
List<WorkerArea> byWorker;
|
||||
if (Integer.valueOf(1).equals(type)) {
|
||||
// 服务类型:查询服务区域
|
||||
byWorker = workerAreaService.getByWorkerIdAndType(workerId, 1);
|
||||
} else if (Integer.valueOf(2).equals(type)) {
|
||||
// 商品类型:查询商品区域
|
||||
byWorker = workerAreaService.getByWorkerIdAndType(workerId, 2);
|
||||
} else {
|
||||
// 不传类型:查询所有区域
|
||||
byWorker = workerAreaService.getByWorker(workerId);
|
||||
}
|
||||
|
||||
// 收集城市ID
|
||||
Set<Long> cityIds = new HashSet<>();
|
||||
for (WorkerArea area : byWorker){
|
||||
List<String> ids;
|
||||
if(countryMap.containsKey(area.getDistrictId())){
|
||||
|
|
@ -105,9 +120,16 @@ public class WorkerAreaController extends BaseController {
|
|||
}else {
|
||||
ids = new ArrayList<>();
|
||||
}
|
||||
|
||||
// 收集城市ID
|
||||
if (area.getCityId() != null) {
|
||||
cityIds.add(area.getCityId());
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
@ -117,7 +139,16 @@ public class WorkerAreaController extends BaseController {
|
|||
model.setCityArea(cityArea);
|
||||
SysArea provinceArea = sysAreaService.selectById(Long.valueOf(cityArea.getParentCode()));
|
||||
model.setProvinceArea(provinceArea);
|
||||
|
||||
// 需求2:增加cityIds字段
|
||||
List<Long> cityIdList = cityIds.stream()
|
||||
.map(Long::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
model.setCityIds(cityIdList);
|
||||
|
||||
// 设置街道ID列表
|
||||
model.setStreetIds(longListEntry.getValue());
|
||||
|
||||
result.add(model);
|
||||
}
|
||||
return AjaxResult.success(result);
|
||||
|
|
|
|||
|
|
@ -147,12 +147,26 @@ public class WorkerGoodsCategoryController extends BaseController {
|
|||
|
||||
@GetMapping("worker/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult getEditWorker(Long workerId) {
|
||||
public AjaxResult getEditWorker(Long workerId, Integer type) {
|
||||
Map<Long, List<String>> twoMap = new HashMap<>();
|
||||
List<WorkerGoodsCategory> list = workerGoodsCategoryService.getByWorker(workerId);
|
||||
|
||||
// 根据类型查询对应的商品分类数据
|
||||
List<WorkerGoodsCategory> list;
|
||||
if (Integer.valueOf(1).equals(type)) {
|
||||
// 服务类型:查询服务商品分类
|
||||
list = workerGoodsCategoryService.getByWorkerIdAndType(workerId, 1);
|
||||
} else if (Integer.valueOf(2).equals(type)) {
|
||||
// 商品类型:查询商品分类
|
||||
list = workerGoodsCategoryService.getByWorkerIdAndType(workerId, 2);
|
||||
} else {
|
||||
// 不传类型:查询所有商品分类
|
||||
list = workerGoodsCategoryService.getByWorker(workerId);
|
||||
}
|
||||
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
for (WorkerGoodsCategory item: list) {
|
||||
List<String> ids;
|
||||
GoodsCategory goodsCategory = goodsCategoryService.selectById(item.getGoodsCategoryId());
|
||||
|
|
@ -164,6 +178,7 @@ public class WorkerGoodsCategoryController extends BaseController {
|
|||
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();
|
||||
|
|
|
|||
|
|
@ -20,9 +20,12 @@
|
|||
|
||||
<sql id="selectWorkerArea">
|
||||
SELECT wa.worker_area_id, wa.worker_id, wa.province_id, wa.city_id, wa.district_id, wa.street_id, wa.create_by, wa.create_time,
|
||||
wa.update_by, wa.update_time, wa.remark, wa.service_type, sa.area_name, sa.merger_name
|
||||
wa.update_by, wa.update_time, wa.remark, wa.service_type,
|
||||
COALESCE(street.area_name, city.area_name) AS area_name,
|
||||
COALESCE(street.merger_name, city.merger_name) AS merger_name
|
||||
FROM worker_area wa
|
||||
LEFT JOIN sys_area sa on wa.street_id = sa.area_id
|
||||
LEFT JOIN sys_area street ON wa.street_id = street.area_id
|
||||
LEFT JOIN sys_area city ON wa.city_id = city.area_id
|
||||
</sql>
|
||||
|
||||
<insert id="insert" parameterType="com.ghy.worker.domain.WorkerArea" useGeneratedKeys="true" keyProperty="workerAreaId">
|
||||
|
|
|
|||
Loading…
Reference in New Issue