/**
|
# __----~~~~~~~~~~~------___
|
# . . ~~//====...... __--~ ~~
|
# -. \_|// |||\\ ~~~~~~::::... /~
|
# ___-==_ _-~o~ \/ ||| \\ _/~~-
|
# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~
|
# _-~~ .=~ | \\-_ '-~7 /- / || \ /
|
# .~ .~ | \\ -_ / /- / || \ /
|
# / ____ / | \\ ~-_/ /|- _/ .|| \ /
|
# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\
|
# ' ~-| /| |-~\~~ __--~~
|
# |-~~-_/ | | ~\_ _-~ /\
|
# / \ \__ \/~ \__
|
# _--~ _/ | .-~~____--~-/ ~~==.
|
# ((->/~ '.|||' -_| ~~-/ , . _||
|
# -_ ~\ ~~---l__i__i__i--~~_/
|
# _-~-__ ~) \--______________--~~
|
# //.-~~~-~_--~- |-------~~~~~~~~
|
# //.-~~~--\
|
# 神兽保佑
|
# 永无BUG!
|
*/
|
package com.nanjing.water.host.controller.base;
|
|
import com.nanjing.water.common.ExecutedResult;
|
import com.nanjing.water.common.PagerResult;
|
import com.nanjing.water.common.util.ParameterUtil;
|
import com.nanjing.water.common.validator.ParameterValidateResult;
|
import com.nanjing.water.common.validator.ParameterValidator;
|
import com.nanjing.water.entity.request.ReqListId;
|
import com.nanjing.water.entity.request.sysregion.ReqCreateSysRegion;
|
import com.nanjing.water.entity.request.sysregion.ReqModifySysRegion;
|
import com.nanjing.water.entity.response.region.ResRegionTree;
|
import com.nanjing.water.entity.search.SearchSysRegion;
|
import com.nanjing.water.host.BasicController;
|
import com.nanjing.water.host.api.NonLogin;
|
import com.nanjing.water.repository.vo.SysRegionVO;
|
import com.nanjing.water.service.SysRegionService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
|
/**
|
* 06.系统行政地区
|
* @author lin.liu
|
* @order 06
|
*/
|
@RestController
|
@RequestMapping(value = "sysRegion")
|
public class SysRegionController extends BasicController {
|
@Autowired
|
private SysRegionService service;
|
|
/**
|
* 创建[系统行政地区]
|
* @author lin.liu
|
* @description 创建[系统行政地区]
|
*/
|
@PostMapping(value = "create")
|
public ExecutedResult<Long> create(@RequestBody ReqCreateSysRegion request) {
|
//#region 参数验证
|
ParameterValidator validator = new ParameterValidator()
|
// 非空
|
//.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName())
|
// 限制最大长度
|
//.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50)
|
;
|
ParameterValidateResult result = validator.validate();
|
if (result.getIsFiled()) {
|
return failed(result.getErrorMsg());
|
}
|
//#endregion
|
return this.service.create(request);
|
}
|
|
/**
|
* 编辑[系统行政地区]
|
* @author lin.liu
|
* @description 编辑[系统行政地区]
|
*/
|
@PostMapping(value = "modify")
|
public ExecutedResult<String> modify(@RequestBody ReqModifySysRegion request) {
|
//#region 参数验证
|
ParameterValidator validator = new ParameterValidator()
|
// 必须大于0
|
.addGreater(ParameterUtil.named("[系统行政地区]id"), request.getId(), 0L)
|
// 非空
|
//.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName())
|
// 限制最大长度
|
//.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50)
|
;
|
ParameterValidateResult result = validator.validate();
|
if (result.getIsFiled()) {
|
return failed(result.getErrorMsg());
|
}
|
//#endregion
|
return this.service.modify(request);
|
}
|
|
/**
|
* 获取[系统行政地区]
|
* @author lin.liu
|
* @description 获取[系统行政地区]
|
*/
|
@GetMapping(value = "get/{code}")
|
public ExecutedResult<SysRegionVO> get(@PathVariable String code) {
|
return this.service.get(code);
|
}
|
/**
|
* 根据id批量获取[系统行政地区]
|
* @author lin.liu
|
* @description 根据id批量获取[系统行政地区]
|
*/
|
@PostMapping(value = "getList")
|
public ExecutedResult<List<SysRegionVO>> getList(@RequestBody ReqListId request) {
|
return this.service.getList(request.getListId());
|
}
|
|
/**
|
* 获取指定区域的子级区域
|
*
|
* @param code 区域编号,不传获取所有一级区域
|
* @author lin.liu
|
* @date 2024/05/13
|
*/
|
@GetMapping(value = "getListChild")
|
public ExecutedResult<List<ResRegionTree>> getListChild(@RequestParam String code) {
|
return this.service.getListChild(code);
|
}
|
/**
|
* 查询[系统行政地区]
|
* @author lin.liu
|
* @description 查询[系统行政地区]
|
*/
|
@PostMapping(value = "search")
|
public ExecutedResult<PagerResult<SysRegionVO>> search(@RequestBody SearchSysRegion request) {
|
return this.service.search(request);
|
}
|
/**
|
* 获取指定区域的子级区域(包含自身)
|
*
|
* @param code 区域编号
|
* @author lin.liu
|
* @date 2024/05/13
|
*/
|
@NonLogin
|
@GetMapping(value = "currAndTree/{code}")
|
public ExecutedResult<ResRegionTree> currAndTree(@PathVariable String code) {
|
//#region 参数验证
|
ParameterValidator validator = new ParameterValidator()
|
.addNotNullOrEmpty(ParameterUtil.named("区域编号"), code);
|
ParameterValidateResult result = validator.validate();
|
if (result.getIsFiled()) {
|
return ExecutedResult.failed(result.getErrorMsg());
|
}
|
//#endregion
|
return this.service.currAndTree(code);
|
}
|
}
|