|
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -29,6 +30,22 @@ public class RegionController {
|
|
|
private final RegionServiceImpl regionService;
|
|
|
private final CommonMapper mapper;
|
|
|
|
|
|
+ @PostMapping
|
|
|
+ public RestResponse region(@RequestBody Region region) {
|
|
|
+ region = regionService.getById(region.getId());
|
|
|
+ Map<String, Object> regionUser = mapper.one(" u.name ",
|
|
|
+ " region r left join user_info u on u.user_id = r.user_id ",
|
|
|
+ " where r.user_id = " + region.getUserId() + " and r.id = " + region.getId());
|
|
|
+ Map<String, Object> regionClerk = mapper.one(" u.name ",
|
|
|
+ " region r left join user_info u on u.user_id = r.clerk ",
|
|
|
+ " where r.clerk = " + region.getClerk() + " and r.id = " + region.getId());
|
|
|
+ HashMap<String, Object> data = new HashMap<>();
|
|
|
+ data.put("regionUser", regionUser);
|
|
|
+ data.put("regionClerk", regionClerk);
|
|
|
+ return RestResponse.ok(data, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@PostMapping("/list")
|
|
|
public RestResponse list(@RequestBody RegionReq regionReq) {
|
|
|
return regionService.regions(regionReq);
|
|
@@ -55,14 +72,14 @@ public class RegionController {
|
|
|
return RestResponse.ok(null, ApiConstants.RESULT_ERROR, "修改失败");
|
|
|
}
|
|
|
|
|
|
- @PostMapping
|
|
|
- public RestResponse get(@RequestBody Region region) {
|
|
|
- Region byId = regionService.getById(region.getId());
|
|
|
- if (null == byId) {
|
|
|
- return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "未找到");
|
|
|
- }
|
|
|
- return RestResponse.ok(byId, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
- }
|
|
|
+// @PostMapping
|
|
|
+// public RestResponse get(@RequestBody Region region) {
|
|
|
+// Region byId = regionService.getById(region.getId());
|
|
|
+// if (null == byId) {
|
|
|
+// return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "未找到");
|
|
|
+// }
|
|
|
+// return RestResponse.ok(byId, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
+// }
|
|
|
|
|
|
@PostMapping("/project/regions")
|
|
|
public RestResponse regions(@RequestBody Region region) {
|
|
@@ -75,11 +92,13 @@ public class RegionController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/project/areas")
|
|
|
- public RestResponse areas(@RequestBody AreaCode areaCode) {
|
|
|
- List<Map<String, Object>> areaCodes = mapper.list("id,name", "area_code", " where parent=" + areaCode.getParent() + " level=3");
|
|
|
- if (areaCodes.isEmpty()) {
|
|
|
+ public RestResponse areas(@RequestBody Region region) {
|
|
|
+ Region byId = regionService.getById(region.getId());
|
|
|
+ String cityCode = byId.getCityCode();
|
|
|
+ List<Map<String, Object>> area_code = mapper.list("name,code", "area_code", "where parent=" + cityCode);
|
|
|
+ if (area_code.isEmpty()) {
|
|
|
return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
|
}
|
|
|
- return RestResponse.ok(areaCodes, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
+ return RestResponse.ok(area_code, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
}
|
|
|
}
|