|
@@ -1,95 +1,95 @@
|
|
|
-package cn.com.ty.lift.system.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.service.impl.RegionServiceImpl;
|
|
|
-import cn.com.ty.lift.system.user.service.impl.AreaCodeService;
|
|
|
-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.List;
|
|
|
-
|
|
|
-/**
|
|
|
- * <p>
|
|
|
- * 区域表 前端控制器
|
|
|
- * </p>
|
|
|
- *
|
|
|
- * @author wang-hai-cheng
|
|
|
- * @since 2019-12-09
|
|
|
- */
|
|
|
-@AllArgsConstructor
|
|
|
-@RestController
|
|
|
-@RequestMapping("/region")
|
|
|
-public class RegionController {
|
|
|
- private final RegionServiceImpl regionService;
|
|
|
- private final AreaCodeService areaCodeService;
|
|
|
-
|
|
|
- @PostMapping("/list")
|
|
|
- public RestResponse list(@RequestBody RegionReq regionReq) {
|
|
|
- IPage<Region> page = regionService.page(new Page<>(regionReq.getPageNum(), regionReq.getPageSize()));
|
|
|
- if (page.getRecords().isEmpty()) {
|
|
|
- return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
|
- }
|
|
|
- return RestResponse.ok(page, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/add")
|
|
|
- public RestResponse add(@RequestBody Region region) {
|
|
|
- if (regionService.save(region)) {
|
|
|
- return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, "新增成功");
|
|
|
- }
|
|
|
- return RestResponse.ok(null, ApiConstants.RESULT_ERROR, "新增失败");
|
|
|
- }
|
|
|
-
|
|
|
- @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, "删除失败");
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/update")
|
|
|
- public RestResponse update(@RequestBody Region region) {
|
|
|
- if (regionService.updateById(region)) {
|
|
|
- return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, "修改成功");
|
|
|
- }
|
|
|
- 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("/project/regions")
|
|
|
- public RestResponse regions(@RequestBody Region region) {
|
|
|
- List<Region> regions = regionService.list(new QueryWrapper<Region>()
|
|
|
- .eq("mt_company_id", region.getMtCompanyId()));
|
|
|
- if (regions.isEmpty()) {
|
|
|
- return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
|
- }
|
|
|
- return RestResponse.ok(regions, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/project/areas")
|
|
|
- public RestResponse areas(@RequestBody AreaCode areaCode) {
|
|
|
- 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, "无数据");
|
|
|
- }
|
|
|
- return RestResponse.ok(areaCodes, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
- }
|
|
|
-}
|
|
|
+//package cn.com.ty.lift.system.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.service.impl.RegionServiceImpl;
|
|
|
+//import cn.com.ty.lift.system.user.service.impl.AreaCodeService;
|
|
|
+//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.List;
|
|
|
+//
|
|
|
+///**
|
|
|
+// * <p>
|
|
|
+// * 区域表 前端控制器
|
|
|
+// * </p>
|
|
|
+// *
|
|
|
+// * @author wang-hai-cheng
|
|
|
+// * @since 2019-12-09
|
|
|
+// */
|
|
|
+//@AllArgsConstructor
|
|
|
+//@RestController
|
|
|
+//@RequestMapping("/region")
|
|
|
+//public class RegionController {
|
|
|
+// private final RegionServiceImpl regionService;
|
|
|
+// private final AreaCodeService areaCodeService;
|
|
|
+//
|
|
|
+// @PostMapping("/list")
|
|
|
+// public RestResponse list(@RequestBody RegionReq regionReq) {
|
|
|
+// IPage<Region> page = regionService.page(new Page<>(regionReq.getPageNum(), regionReq.getPageSize()));
|
|
|
+// if (page.getRecords().isEmpty()) {
|
|
|
+// return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
|
+// }
|
|
|
+// return RestResponse.ok(page, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
+// }
|
|
|
+//
|
|
|
+// @PostMapping("/add")
|
|
|
+// public RestResponse add(@RequestBody Region region) {
|
|
|
+// if (regionService.save(region)) {
|
|
|
+// return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, "新增成功");
|
|
|
+// }
|
|
|
+// return RestResponse.ok(null, ApiConstants.RESULT_ERROR, "新增失败");
|
|
|
+// }
|
|
|
+//
|
|
|
+// @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, "删除失败");
|
|
|
+// }
|
|
|
+//
|
|
|
+// @PostMapping("/update")
|
|
|
+// public RestResponse update(@RequestBody Region region) {
|
|
|
+// if (regionService.updateById(region)) {
|
|
|
+// return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, "修改成功");
|
|
|
+// }
|
|
|
+// 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("/project/regions")
|
|
|
+// public RestResponse regions(@RequestBody Region region) {
|
|
|
+// List<Region> regions = regionService.list(new QueryWrapper<Region>()
|
|
|
+// .eq("mt_company_id", region.getMtCompanyId()));
|
|
|
+// if (regions.isEmpty()) {
|
|
|
+// return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
|
+// }
|
|
|
+// return RestResponse.ok(regions, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
+// }
|
|
|
+//
|
|
|
+// @PostMapping("/project/areas")
|
|
|
+// public RestResponse areas(@RequestBody AreaCode areaCode) {
|
|
|
+// 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, "无数据");
|
|
|
+// }
|
|
|
+// return RestResponse.ok(areaCodes, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
+// }
|
|
|
+//}
|