From e2ea7986cf5e27e448a25c48c8c4cc771c067b0e Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期三, 21 六月 2023 16:41:42 +0800
Subject: [PATCH] 优化报警类型配置
---
ard-work/src/main/java/com/ruoyi/alarm/config/service/IArdAlarmTypeConfigService.java | 13 ++++---------
ard-work/src/main/java/com/ruoyi/alarm/config/controller/ArdAlarmTypeConfigController.java | 12 +++++++-----
ard-work/src/main/java/com/ruoyi/alarm/config/service/impl/ArdAlarmTypeConfigServiceImpl.java | 19 +++++++++++--------
3 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/alarm/config/controller/ArdAlarmTypeConfigController.java b/ard-work/src/main/java/com/ruoyi/alarm/config/controller/ArdAlarmTypeConfigController.java
index dec9207..db5fc0a 100644
--- a/ard-work/src/main/java/com/ruoyi/alarm/config/controller/ArdAlarmTypeConfigController.java
+++ b/ard-work/src/main/java/com/ruoyi/alarm/config/controller/ArdAlarmTypeConfigController.java
@@ -1,12 +1,15 @@
package com.ruoyi.alarm.config.controller;
import java.util.List;
+import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.ruoyi.alarm.config.domain.ArdAlarmTypeConfig;
import com.ruoyi.alarm.config.service.IArdAlarmTypeConfigService;
import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,7 +45,7 @@
/**
* 鏌ヨ鎶ヨ绫诲瀷鐢ㄦ埛鍏宠仈鍒楄〃
*/
- @PreAuthorize("@ss.hasPermi('alarm:alarmConfig:list')")
+ //@PreAuthorize("@ss.hasPermi('alarm:alarmConfig:list')")
@GetMapping("/list")
@ApiOperation("鏌ヨ鎶ヨ绫诲瀷鐢ㄦ埛鍏宠仈鍒楄〃")
public TableDataInfo list(ArdAlarmTypeConfig ardAlarmTypeConfig)
@@ -77,14 +80,13 @@
/**
* 鎵归噺鏂板鎶ヨ绫诲瀷鐢ㄦ埛鍏宠仈
*/
- @PreAuthorize("@ss.hasPermi('alarm:alarmConfig:add')")
@Log(title = "鎵归噺閰嶇疆鎶ヨ绫诲瀷", businessType = BusinessType.INSERT)
@PostMapping("/batchConfig")
@ApiOperation("鎵归噺閰嶇疆鎶ヨ绫诲瀷")
- public AjaxResult addBatch(@RequestBody List<Integer> commands)
+ @ApiOperationSupport(includeParameters = {"map.userId", "map.commands"})
+ public AjaxResult addBatch(@RequestBody Map<String,Object> map)
{
- ardAlarmTypeConfigService.deleteArdAlarmTypeConfigByCurrentUserId();
- return AjaxResult.success(ardAlarmTypeConfigService.insertArdAlarmTypeConfig(commands));
+ return AjaxResult.success(ardAlarmTypeConfigService.insertArdAlarmTypeConfig(map));
}
/**
diff --git a/ard-work/src/main/java/com/ruoyi/alarm/config/service/IArdAlarmTypeConfigService.java b/ard-work/src/main/java/com/ruoyi/alarm/config/service/IArdAlarmTypeConfigService.java
index 501a797..cb29a8f 100644
--- a/ard-work/src/main/java/com/ruoyi/alarm/config/service/IArdAlarmTypeConfigService.java
+++ b/ard-work/src/main/java/com/ruoyi/alarm/config/service/IArdAlarmTypeConfigService.java
@@ -1,6 +1,8 @@
package com.ruoyi.alarm.config.service;
import java.util.List;
+import java.util.Map;
+
import com.ruoyi.alarm.config.domain.ArdAlarmTypeConfig;
@@ -63,16 +65,9 @@
/**
* 鎵归噺鎶ヨ绫诲瀷鐢ㄦ埛鍏宠仈
*
- * @param command 鎶ヨ绫诲瀷鍒楄〃
+ * @param configInfoMap 鎶ヨ绫诲瀷鍒楄〃
* @return 缁撴灉
*/
- public int insertArdAlarmTypeConfig(List<Integer> command);
-
- /**
- * 鎵归噺鍒犻櫎鎶ヨ绫诲瀷鐢ㄦ埛鍏宠仈
- *
- * @return 缁撴灉
- */
- public int deleteArdAlarmTypeConfigByCurrentUserId();
+ public int insertArdAlarmTypeConfig(Map<String,Object> configInfoMap);
}
diff --git a/ard-work/src/main/java/com/ruoyi/alarm/config/service/impl/ArdAlarmTypeConfigServiceImpl.java b/ard-work/src/main/java/com/ruoyi/alarm/config/service/impl/ArdAlarmTypeConfigServiceImpl.java
index 1679570..313d921 100644
--- a/ard-work/src/main/java/com/ruoyi/alarm/config/service/impl/ArdAlarmTypeConfigServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/alarm/config/service/impl/ArdAlarmTypeConfigServiceImpl.java
@@ -13,6 +13,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
@@ -99,11 +100,18 @@
/**
* 鎵归噺鎶ヨ绫诲瀷鐢ㄦ埛鍏宠仈
*
- * @param commands 鎶ヨ绫诲瀷鍒楄〃
+ * @param configInfo 鎶ヨ绫诲瀷鍒楄〃
* @return 缁撴灉
*/
@Override
- public int insertArdAlarmTypeConfig(List<Integer> commands) {
+ public int insertArdAlarmTypeConfig(Map<String,Object> configInfo) {
+ String userId =(String) configInfo.get("userId");
+ ardAlarmTypeConfigMapper.deleteArdAlarmTypeConfigByCurrentUserId(userId);
+ List<Integer> commands=(List<Integer>) configInfo.get("commands");
+ if(commands.size()==0)
+ {
+ return 0;
+ }
int resNum=0;
for(Integer command :commands)
{
@@ -113,7 +121,7 @@
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType("alarm_type");
SysDictData sysDictData = dictDatas.stream().filter(s -> Objects.equals(s.getDictValue(), command.toString())).findFirst().orElse(null);
config.setAlarmType(sysDictData.getDictLabel());
- config.setUserId(SecurityUtils.getUserId());
+ config.setUserId(userId);
config.setCreateTime(DateUtils.getNowDate());
int i = ardAlarmTypeConfigMapper.insertArdAlarmTypeConfig(config);
if(i>0)
@@ -122,10 +130,5 @@
}
}
return resNum;
- }
-
- @Override
- public int deleteArdAlarmTypeConfigByCurrentUserId() {
- return ardAlarmTypeConfigMapper.deleteArdAlarmTypeConfigByCurrentUserId(SecurityUtils.getUserId());
}
}
--
Gitblit v1.9.3