|
@@ -1,22 +1,17 @@
|
|
|
-package cn.com.ty.lift.system.region.controller;
|
|
|
+package cn.com.ty.lift.enterprise.region.controller;
|
|
|
|
|
|
import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
import cn.com.ty.lift.common.model.AreaCode;
|
|
|
-import cn.com.ty.lift.system.region.dao.entity.Region;
|
|
|
-import cn.com.ty.lift.system.region.dao.entity.model.RegionReq;
|
|
|
-import cn.com.ty.lift.system.region.dao.mapper.CommonMapper;
|
|
|
-import cn.com.ty.lift.system.region.service.impl.RegionServiceImpl;
|
|
|
-import cn.com.ty.lift.system.user.service.impl.AreaCodeService;
|
|
|
+import cn.com.ty.lift.enterprise.common.mapper.CommonMapper;
|
|
|
+import cn.com.ty.lift.enterprise.region.dao.entity.Region;
|
|
|
+import cn.com.ty.lift.enterprise.region.dao.entity.model.RegionReq;
|
|
|
+import cn.com.ty.lift.enterprise.region.service.impl.RegionServiceImpl;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -31,46 +26,11 @@ import java.util.Map;
|
|
|
@RequestMapping("/region")
|
|
|
public class RegionController {
|
|
|
private final RegionServiceImpl regionService;
|
|
|
- private final AreaCodeService areaCodeService;
|
|
|
private final CommonMapper mapper;
|
|
|
|
|
|
-
|
|
|
@PostMapping("/list")
|
|
|
public RestResponse list(@RequestBody RegionReq regionReq) {
|
|
|
- long current = regionReq.getPageNum() * regionReq.getPageSize() - 1;
|
|
|
- List<Map<String, Object>> list = mapper.list(
|
|
|
- "r.id, r.area_code, r.province_code, a.name cityName, r.area_name, r.remark, u.name",
|
|
|
- "region r left join user_info u on r.user_id = u.user_id left join area_code a on r.city_code = a.code left join area_code on r.province_code = a.name",
|
|
|
- "where r.mt_company_id =" + regionReq.getMtCompanyId());
|
|
|
- List<Map<String, Object>> projects = mapper.list("region_id,num", "project", "");
|
|
|
- int count = 0;
|
|
|
- Integer num = 0;
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- Object id = list.get(i).get("id");
|
|
|
- for (int j = 0; j < projects.size(); j++) {
|
|
|
-// System.out.println("================"+projects.get(i).get("region_id"));
|
|
|
-// System.out.println("================"+list.get(j).get("id"));
|
|
|
- if (projects.get(j).get("region_id").equals(id)) {
|
|
|
- count += 1;
|
|
|
- }
|
|
|
-// num += projects.get(j).get("num");
|
|
|
- //
|
|
|
- //
|
|
|
- //
|
|
|
- //
|
|
|
- //
|
|
|
- }
|
|
|
- list.get(i).put("project_num", count);
|
|
|
- count = 0;
|
|
|
- num = 0;
|
|
|
- }
|
|
|
-
|
|
|
- System.out.println(list);
|
|
|
- // if (page.getRecords().isEmpty()) {
|
|
|
-// return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
|
-// }
|
|
|
-// return RestResponse.ok(page, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
- return RestResponse.ok(null, "", "");
|
|
|
+ return regionService.regions(regionReq);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/add")
|
|
@@ -83,10 +43,8 @@ public class RegionController {
|
|
|
|
|
|
@PostMapping("/delete")
|
|
|
public RestResponse delete(@RequestBody Region region) {
|
|
|
- if (regionService.removeById(region.getId())) {
|
|
|
- return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, "删除成功");
|
|
|
- }
|
|
|
- return RestResponse.ok(null, ApiConstants.RESULT_ERROR, "删除失败");
|
|
|
+ return regionService.delete(region);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@PostMapping("/update")
|
|
@@ -118,9 +76,11 @@ public class RegionController {
|
|
|
|
|
|
@PostMapping("/project/areas")
|
|
|
public RestResponse areas(@RequestBody AreaCode areaCode) {
|
|
|
+ mapper.list("id,","area_code"," where parent="+areaCode.getParent()+)
|
|
|
List<AreaCode> areaCodes = areaCodeService.list(new QueryWrapper<AreaCode>()
|
|
|
.eq("parent", areaCode.getParent())
|
|
|
.eq("level", 3));
|
|
|
+
|
|
|
if (areaCodes.isEmpty()) {
|
|
|
return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
|
}
|