|
@@ -10,33 +10,29 @@ import api.common.pojo.vo.model.ConfigVO;
|
|
|
import api.common.util.ObjectUtil;
|
|
|
import com.css.simulation.resource.model.service.ConfigService;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
-@Controller
|
|
|
-@RequestMapping(value = "/config",name = LogConstants.MODULE_CONFIG)
|
|
|
+@RestController
|
|
|
+@RequestMapping(value = "/config", name = LogConstants.MODULE_CONFIG)
|
|
|
public class ConfigCtrl {
|
|
|
|
|
|
- @Autowired
|
|
|
- ConfigService configService;
|
|
|
+ @Resource
|
|
|
+ private ConfigService configService;
|
|
|
|
|
|
/**
|
|
|
* 获取列表
|
|
|
*/
|
|
|
@RequestMapping("/getConfigPageList")
|
|
|
- @ResponseBody
|
|
|
- public ResponseBodyVO<PageInfo<ConfigVO>> getConfigPageList(@RequestBody @Validated ConfigPageParam pageParam){
|
|
|
- ResponseBodyVO<PageInfo<ConfigVO>> response = new ResponseBodyVO<PageInfo<ConfigVO>>(ResponseBodyVO.Response.SUCCESS);
|
|
|
- response.setInfo(configService.getConfigPageList(pageParam));
|
|
|
- return response;
|
|
|
+ public ResponseBodyVO<PageInfo<ConfigVO>> getConfigPageList(@RequestBody @Validated ConfigPageParam pageParam) {
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, configService.getConfigPageList(pageParam));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -44,8 +40,7 @@ public class ConfigCtrl {
|
|
|
* 根据id获取详情
|
|
|
*/
|
|
|
@RequestMapping("/getConfigInfo")
|
|
|
- @ResponseBody
|
|
|
- public ResponseBodyVO<ConfigVO> getConfigInfo(@RequestBody ConfigVO configVO){
|
|
|
+ public ResponseBodyVO<ConfigVO> getConfigInfo(@RequestBody ConfigVO configVO) {
|
|
|
ResponseBodyVO<ConfigVO> response = new ResponseBodyVO<ConfigVO>(ResponseBodyVO.Response.SUCCESS);
|
|
|
response.setInfo(configService.getConfigInfo(configVO));
|
|
|
return response;
|
|
@@ -55,26 +50,25 @@ public class ConfigCtrl {
|
|
|
* 新增、修改
|
|
|
*/
|
|
|
@RequestMapping("/saveConfig")
|
|
|
- @ResponseBody
|
|
|
- public ResponseBodyVO<ConfigPO> saveConfig(@RequestBody ConfigVO configVO){
|
|
|
- if(ObjectUtil.isNull(configVO)){
|
|
|
- return new ResponseBodyVO(false, 500, "参数必传!",null);
|
|
|
+ public ResponseBodyVO<ConfigPO> saveConfig(@RequestBody ConfigVO configVO) {
|
|
|
+ if (ObjectUtil.isNull(configVO)) {
|
|
|
+ return new ResponseBodyVO(false, 500, "参数必传!", null);
|
|
|
}
|
|
|
//端口重复校验
|
|
|
Map<String, List<ConfigSensorVO>> configSensors = configVO.getConfigSensors();
|
|
|
- if(ObjectUtil.isNotNull(configSensors)){
|
|
|
+ if (ObjectUtil.isNotNull(configSensors)) {
|
|
|
List<ConfigSensorVO> configSensorVOS = configSensors.get("ogt");//完美传感器
|
|
|
- if(ObjectUtil.isNotNull(configSensorVOS)){
|
|
|
+ if (ObjectUtil.isNotNull(configSensorVOS)) {
|
|
|
long count = configSensorVOS.stream().mapToInt(ConfigSensorVO::getSensorPort).distinct().count();
|
|
|
- if(configSensorVOS.size() != count){
|
|
|
- return new ResponseBodyVO(false, 500, "端口重复!",null);
|
|
|
+ if (configSensorVOS.size() != count) {
|
|
|
+ return new ResponseBodyVO(false, 500, "端口重复!", null);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
ResponseBodyVO<ConfigPO> response = new ResponseBodyVO<ConfigPO>(ResponseBodyVO.Response.SUCCESS);
|
|
|
ConfigPO po = configService.saveConfig(configVO);
|
|
|
- if(ObjectUtil.isNull(po.getId())){
|
|
|
- return new ResponseBodyVO(false, 500, "配置名称重复!",null);
|
|
|
+ if (ObjectUtil.isNull(po.getId())) {
|
|
|
+ return new ResponseBodyVO(false, 500, "配置名称重复!", null);
|
|
|
}
|
|
|
response.setInfo(po);
|
|
|
return response;
|
|
@@ -84,26 +78,25 @@ public class ConfigCtrl {
|
|
|
* 另存为
|
|
|
*/
|
|
|
@RequestMapping("/saveAnotherConfig")
|
|
|
- @ResponseBody
|
|
|
- public ResponseBodyVO<ConfigPO> saveAnotherConfig(@RequestBody ConfigVO configVO){
|
|
|
- if(ObjectUtil.isNull(configVO)){
|
|
|
- return new ResponseBodyVO(false, 500, "参数必传!",null);
|
|
|
+ public ResponseBodyVO<ConfigPO> saveAnotherConfig(@RequestBody ConfigVO configVO) {
|
|
|
+ if (ObjectUtil.isNull(configVO)) {
|
|
|
+ return new ResponseBodyVO(false, 500, "参数必传!", null);
|
|
|
}
|
|
|
//端口重复校验
|
|
|
Map<String, List<ConfigSensorVO>> configSensors = configVO.getConfigSensors();
|
|
|
- if(ObjectUtil.isNotNull(configSensors)){
|
|
|
+ if (ObjectUtil.isNotNull(configSensors)) {
|
|
|
List<ConfigSensorVO> configSensorVOS = configSensors.get("ogt");//完美传感器
|
|
|
- if(ObjectUtil.isNotNull(configSensorVOS)){
|
|
|
+ if (ObjectUtil.isNotNull(configSensorVOS)) {
|
|
|
long count = configSensorVOS.stream().mapToInt(ConfigSensorVO::getSensorPort).distinct().count();
|
|
|
- if(configSensorVOS.size() != count){
|
|
|
- return new ResponseBodyVO(false, 500, "端口重复!",null);
|
|
|
+ if (configSensorVOS.size() != count) {
|
|
|
+ return new ResponseBodyVO(false, 500, "端口重复!", null);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
ResponseBodyVO<ConfigPO> response = new ResponseBodyVO<ConfigPO>(ResponseBodyVO.Response.SUCCESS);
|
|
|
ConfigPO po = configService.saveAnotherConfig(configVO);
|
|
|
- if(ObjectUtil.isNull(po.getId())){
|
|
|
- return new ResponseBodyVO(false, 500, "配置名称重复!",null);
|
|
|
+ if (ObjectUtil.isNull(po.getId())) {
|
|
|
+ return new ResponseBodyVO(false, 500, "配置名称重复!", null);
|
|
|
}
|
|
|
response.setInfo(po);
|
|
|
return response;
|
|
@@ -113,16 +106,15 @@ public class ConfigCtrl {
|
|
|
* 详情分享
|
|
|
*/
|
|
|
@RequestMapping("/shareConfigByInfo")
|
|
|
- @ResponseBody
|
|
|
@PreAuthorize("@AuthorityCheck.admin()")
|
|
|
- public ResponseBodyVO<ConfigPO> shareConfigByInfo(@RequestBody ConfigVO configVO){
|
|
|
- if(ObjectUtil.isNull(configVO)){
|
|
|
- return new ResponseBodyVO(false, 500, "参数必传!",null);
|
|
|
+ public ResponseBodyVO<ConfigPO> shareConfigByInfo(@RequestBody ConfigVO configVO) {
|
|
|
+ if (ObjectUtil.isNull(configVO)) {
|
|
|
+ return new ResponseBodyVO(false, 500, "参数必传!", null);
|
|
|
}
|
|
|
ResponseBodyVO<ConfigPO> response = new ResponseBodyVO<ConfigPO>(ResponseBodyVO.Response.SUCCESS);
|
|
|
ConfigPO po = configService.shareConfigByInfo(configVO);
|
|
|
- if(ObjectUtil.isNull(po.getId())){
|
|
|
- return new ResponseBodyVO(false, 500, "配置名称重复!",null);
|
|
|
+ if (ObjectUtil.isNull(po.getId())) {
|
|
|
+ return new ResponseBodyVO(false, 500, "配置名称重复!", null);
|
|
|
}
|
|
|
response.setInfo(po);
|
|
|
return response;
|
|
@@ -132,16 +124,15 @@ public class ConfigCtrl {
|
|
|
* 列表分享
|
|
|
*/
|
|
|
@RequestMapping("/shareConfigById")
|
|
|
- @ResponseBody
|
|
|
@PreAuthorize("@AuthorityCheck.admin()")
|
|
|
- public ResponseBodyVO<ConfigPO> shareConfigById(@RequestBody ConfigVO configVO){
|
|
|
- if(ObjectUtil.isNull(configVO) || ObjectUtil.isNull(configVO.getId())){
|
|
|
- return new ResponseBodyVO(false, 500, "参数必传!",null);
|
|
|
+ public ResponseBodyVO<ConfigPO> shareConfigById(@RequestBody ConfigVO configVO) {
|
|
|
+ if (ObjectUtil.isNull(configVO) || ObjectUtil.isNull(configVO.getId())) {
|
|
|
+ return new ResponseBodyVO(false, 500, "参数必传!", null);
|
|
|
}
|
|
|
ResponseBodyVO<ConfigPO> response = new ResponseBodyVO<ConfigPO>(ResponseBodyVO.Response.SUCCESS);
|
|
|
ConfigPO po = configService.shareConfigById(configVO);
|
|
|
- if(ObjectUtil.isNull(po.getId())){
|
|
|
- return new ResponseBodyVO(false, 500, "配置名称重复!",null);
|
|
|
+ if (ObjectUtil.isNull(po.getId())) {
|
|
|
+ return new ResponseBodyVO(false, 500, "配置名称重复!", null);
|
|
|
}
|
|
|
response.setInfo(po);
|
|
|
return response;
|
|
@@ -151,13 +142,12 @@ public class ConfigCtrl {
|
|
|
* 删除
|
|
|
*/
|
|
|
@RequestMapping("/delConfigById")
|
|
|
- @ResponseBody
|
|
|
- public ResponseBodyVO delConfigById(@RequestBody ConfigVO configVO){
|
|
|
+ public ResponseBodyVO delConfigById(@RequestBody ConfigVO configVO) {
|
|
|
int i = configService.delConfigById(configVO);
|
|
|
- if(i>0){
|
|
|
+ if (i > 0) {
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
- }else{
|
|
|
- return new ResponseBodyVO(false, 500, "删除失败!",null);
|
|
|
+ } else {
|
|
|
+ return new ResponseBodyVO(false, 500, "删除失败!", null);
|
|
|
}
|
|
|
}
|
|
|
}
|