/**
|
# __----~~~~~~~~~~~------___
|
# . . ~~//====...... __--~ ~~
|
# -. \_|// |||\\ ~~~~~~::::... /~
|
# ___-==_ _-~o~ \/ ||| \\ _/~~-
|
# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~
|
# _-~~ .=~ | \\-_ '-~7 /- / || \ /
|
# .~ .~ | \\ -_ / /- / || \ /
|
# / ____ / | \\ ~-_/ /|- _/ .|| \ /
|
# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\
|
# ' ~-| /| |-~\~~ __--~~
|
# |-~~-_/ | | ~\_ _-~ /\
|
# / \ \__ \/~ \__
|
# _--~ _/ | .-~~____--~-/ ~~==.
|
# ((->/~ '.|||' -_| ~~-/ , . _||
|
# -_ ~\ ~~---l__i__i__i--~~_/
|
# _-~-__ ~) \--______________--~~
|
# //.-~~~-~_--~- |-------~~~~~~~~
|
# //.-~~~--\
|
# 神兽保佑
|
# 永无BUG!
|
*/
|
package com.nanjing.water.host.controller;
|
|
import com.nanjing.water.common.ConstantFactory;
|
import com.nanjing.water.common.ExecutedResult;
|
import com.nanjing.water.common.PagerResult;
|
import com.nanjing.water.common.util.ListUtil;
|
import com.nanjing.water.common.util.ParameterUtil;
|
import com.nanjing.water.common.util.StringUtil;
|
import com.nanjing.water.common.validator.ParameterValidateResult;
|
import com.nanjing.water.common.validator.ParameterValidator;
|
import com.nanjing.water.entity.request.watermonitorypoint.ReqCreateWaterMonitoryPoint;
|
import com.nanjing.water.entity.request.watermonitorypoint.ReqModifyWaterMonitoryPoint;
|
import com.nanjing.water.entity.response.point.ResMonitoryPointData;
|
import com.nanjing.water.entity.search.SearchWaterMonitoryPoint;
|
import com.nanjing.water.host.BasicController;
|
import com.nanjing.water.repository.vo.WaterMonitoryPointVO;
|
import com.nanjing.water.service.WaterMonitoryPointService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
|
/**
|
* 140.监控点
|
* @author lin.liu
|
* @order 140
|
*/
|
@RestController
|
@RequestMapping(value = "waterMonitoryPoint")
|
public class WaterMonitoryPointController extends BasicController {
|
@Autowired
|
private WaterMonitoryPointService service;
|
|
/**
|
* 创建[监控点]
|
* @author lin.liu
|
* @description 创建[监控点]
|
*/
|
@PostMapping(value = "create")
|
public ExecutedResult<Long> create(@RequestBody ReqCreateWaterMonitoryPoint request) {
|
//#region 参数验证
|
ParameterValidator validator = new ParameterValidator()
|
// 非空
|
.addNotNullOrEmpty(ParameterUtil.named("监控点名称"), request.getPointName())
|
// 限制最大长度
|
.addLengthMax(ParameterUtil.named("监控点名称"), request.getPointName(), ConstantFactory.LENGTH_MAX200);
|
|
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 ReqModifyWaterMonitoryPoint request) {
|
//#region 参数验证
|
ParameterValidator validator = new ParameterValidator()
|
// 必须大于0
|
.addGreater(ParameterUtil.named("监控id"), request.getId(), 0L)
|
// 非空
|
.addNotNullOrEmpty(ParameterUtil.named("监控点名称"), request.getPointName())
|
// 限制最大长度
|
.addLengthMax(ParameterUtil.named("监控点名称"), request.getPointName(), ConstantFactory.LENGTH_MAX200);
|
|
ParameterValidateResult result = validator.validate();
|
if (result.getIsFiled()) {
|
return failed(result.getErrorMsg());
|
}
|
//#endregion
|
return this.service.modify(request);
|
}
|
/**
|
* 删除监控点
|
*
|
* @param id 删除监控点
|
* @author li。ling。yu
|
* @date 2023/07/17
|
*/
|
@PostMapping(value = "remove")
|
public ExecutedResult<String> remove(@RequestParam Long id) {
|
return this.service.remove(id);
|
}
|
|
/**
|
* 查询监控点
|
* @author lin.liu
|
* @description 查询监控点
|
*/
|
@PostMapping(value = "search")
|
public ExecutedResult<PagerResult<WaterMonitoryPointVO>> search(@RequestBody SearchWaterMonitoryPoint request) {
|
return this.service.search(request);
|
}
|
|
/**
|
* 所有监控点最新数据
|
* @author lin.liu
|
*/
|
@GetMapping(value = "listData")
|
public ExecutedResult<List<ResMonitoryPointData>> listData() {
|
return this.service.listData();
|
}
|
}
|