增加省市显示
This commit is contained in:
parent
57d5161b2c
commit
49394a5172
|
|
@ -95,9 +95,24 @@ public class WorkerAreaController extends BaseController {
|
||||||
|
|
||||||
@GetMapping("worker/edit")
|
@GetMapping("worker/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult getEditWorker(Long workerId){
|
public AjaxResult getEditWorker(Long workerId, Integer type){
|
||||||
Map<Long, List<String>> countryMap = new HashMap<>();
|
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){
|
for (WorkerArea area : byWorker){
|
||||||
List<String> ids;
|
List<String> ids;
|
||||||
if(countryMap.containsKey(area.getDistrictId())){
|
if(countryMap.containsKey(area.getDistrictId())){
|
||||||
|
|
@ -105,9 +120,16 @@ public class WorkerAreaController extends BaseController {
|
||||||
}else {
|
}else {
|
||||||
ids = new ArrayList<>();
|
ids = new ArrayList<>();
|
||||||
}
|
}
|
||||||
ids.add(String.valueOf(area.getStreetId()));
|
|
||||||
countryMap.put(area.getDistrictId(), ids);
|
// 收集城市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<>();
|
List<WorkerArea> result = new ArrayList<>();
|
||||||
for (Map.Entry<Long, List<String>> longListEntry : countryMap.entrySet()) {
|
for (Map.Entry<Long, List<String>> longListEntry : countryMap.entrySet()) {
|
||||||
WorkerArea model = new WorkerArea();
|
WorkerArea model = new WorkerArea();
|
||||||
|
|
@ -117,7 +139,16 @@ public class WorkerAreaController extends BaseController {
|
||||||
model.setCityArea(cityArea);
|
model.setCityArea(cityArea);
|
||||||
SysArea provinceArea = sysAreaService.selectById(Long.valueOf(cityArea.getParentCode()));
|
SysArea provinceArea = sysAreaService.selectById(Long.valueOf(cityArea.getParentCode()));
|
||||||
model.setProvinceArea(provinceArea);
|
model.setProvinceArea(provinceArea);
|
||||||
|
|
||||||
|
// 需求2:增加cityIds字段
|
||||||
|
List<Long> cityIdList = cityIds.stream()
|
||||||
|
.map(Long::valueOf)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
model.setCityIds(cityIdList);
|
||||||
|
|
||||||
|
// 设置街道ID列表
|
||||||
model.setStreetIds(longListEntry.getValue());
|
model.setStreetIds(longListEntry.getValue());
|
||||||
|
|
||||||
result.add(model);
|
result.add(model);
|
||||||
}
|
}
|
||||||
return AjaxResult.success(result);
|
return AjaxResult.success(result);
|
||||||
|
|
|
||||||
|
|
@ -147,12 +147,26 @@ public class WorkerGoodsCategoryController extends BaseController {
|
||||||
|
|
||||||
@GetMapping("worker/edit")
|
@GetMapping("worker/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult getEditWorker(Long workerId) {
|
public AjaxResult getEditWorker(Long workerId, Integer type) {
|
||||||
Map<Long, List<String>> twoMap = new HashMap<>();
|
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)){
|
if(CollectionUtils.isEmpty(list)){
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorkerGoodsCategory item: list) {
|
for (WorkerGoodsCategory item: list) {
|
||||||
List<String> ids;
|
List<String> ids;
|
||||||
GoodsCategory goodsCategory = goodsCategoryService.selectById(item.getGoodsCategoryId());
|
GoodsCategory goodsCategory = goodsCategoryService.selectById(item.getGoodsCategoryId());
|
||||||
|
|
@ -164,6 +178,7 @@ public class WorkerGoodsCategoryController extends BaseController {
|
||||||
ids.add(String.valueOf(goodsCategory.getGoodsCategoryId()));
|
ids.add(String.valueOf(goodsCategory.getGoodsCategoryId()));
|
||||||
twoMap.put(goodsCategory.getParentCategoryId(), ids);
|
twoMap.put(goodsCategory.getParentCategoryId(), ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<WorkerGoodsCategory> result = new ArrayList<>();
|
List<WorkerGoodsCategory> result = new ArrayList<>();
|
||||||
for (Map.Entry<Long, List<String>> longListEntry : twoMap.entrySet()) {
|
for (Map.Entry<Long, List<String>> longListEntry : twoMap.entrySet()) {
|
||||||
WorkerGoodsCategory model = new WorkerGoodsCategory();
|
WorkerGoodsCategory model = new WorkerGoodsCategory();
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,12 @@
|
||||||
|
|
||||||
<sql id="selectWorkerArea">
|
<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,
|
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
|
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>
|
</sql>
|
||||||
|
|
||||||
<insert id="insert" parameterType="com.ghy.worker.domain.WorkerArea" useGeneratedKeys="true" keyProperty="workerAreaId">
|
<insert id="insert" parameterType="com.ghy.worker.domain.WorkerArea" useGeneratedKeys="true" keyProperty="workerAreaId">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue