/**
|
# __----~~~~~~~~~~~------___
|
# . . ~~//====...... __--~ ~~
|
# -. \_|// |||\\ ~~~~~~::::... /~
|
# ___-==_ _-~o~ \/ ||| \\ _/~~-
|
# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~
|
# _-~~ .=~ | \\-_ '-~7 /- / || \ /
|
# .~ .~ | \\ -_ / /- / || \ /
|
# / ____ / | \\ ~-_/ /|- _/ .|| \ /
|
# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\
|
# ' ~-| /| |-~\~~ __--~~
|
# |-~~-_/ | | ~\_ _-~ /\
|
# / \ \__ \/~ \__
|
# _--~ _/ | .-~~____--~-/ ~~==.
|
# ((->/~ '.|||' -_| ~~-/ , . _||
|
# -_ ~\ ~~---l__i__i__i--~~_/
|
# _-~-__ ~) \--______________--~~
|
# //.-~~~-~_--~- |-------~~~~~~~~
|
# //.-~~~--\
|
# 神兽保佑
|
# 永无BUG!
|
*/
|
package com.nanjing.water.host.controller;
|
|
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.host.BasicController;
|
import com.nanjing.water.host.api.NonLogin;
|
import com.nanjing.water.host.mqtt.WebSocket;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.HttpRange;
|
import org.springframework.http.HttpRequest;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.io.IOException;
|
import java.util.List;
|
import java.util.concurrent.Executors;
|
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.TimeUnit;
|
|
import com.nanjing.water.service.HeartbeatDataService;
|
import com.nanjing.water.entity.request.heartbeatdata.ReqCreateHeartbeatData;
|
import com.nanjing.water.entity.request.heartbeatdata.ReqModifyHeartbeatData;
|
import com.nanjing.water.entity.search.SearchHeartbeatData;
|
import com.nanjing.water.repository.vo.HeartbeatDataVO;
|
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
|
/**
|
* 9000.HeartbeatData
|
* @author lin.liu
|
* @order 9000
|
*/
|
@RestController
|
@CrossOrigin
|
@RequestMapping(value = "heartbeatData")
|
public class HeartbeatDataController extends BasicController {
|
@Autowired
|
private HeartbeatDataService service;
|
@Autowired
|
private WebSocket webSocket;
|
|
/**
|
* 创建[null]
|
* @author lin.liu
|
*/
|
@PostMapping(value = "create")
|
public ExecutedResult<Long> create(@RequestBody ReqCreateHeartbeatData 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 service.create(request);
|
}
|
|
/**
|
* 编辑[null]
|
* @author lin.liu
|
*/
|
@PostMapping(value = "modify")
|
public ExecutedResult<String> modify(@RequestBody ReqModifyHeartbeatData request) {
|
//#region 参数验证
|
ParameterValidator validator = new ParameterValidator()
|
// 必须大于0
|
.addGreater(ParameterUtil.named("[null]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 service.modify(request);
|
}
|
|
/**
|
* 获取[null]
|
* @author lin.liu
|
*/
|
@GetMapping(value = "get/{id}")
|
public ExecutedResult<HeartbeatDataVO> get(@PathVariable Long id) {
|
return service.get(id);
|
}
|
/**
|
* 获取[心跳包]
|
* @author lin.liu
|
*/
|
@GetMapping(value = "getByCode")
|
public ExecutedResult<HeartbeatDataVO> getByCode() {
|
return service.getByCode();
|
}
|
|
|
/**
|
* 查询[null]
|
* @author lin.liu
|
*/
|
@PostMapping(value = "search")
|
public ExecutedResult<PagerResult<HeartbeatDataVO>> search(@RequestBody SearchHeartbeatData request) {
|
return service.search(request);
|
}
|
}
|