1、规则、任务在新建、批量导入、审核、批量审核时增加通过sessionid获取内存中的用户信息,并写入数据库表相应字段
This commit is contained in:
@@ -29,7 +29,7 @@ public class StaticRuleObject {
|
||||
private Integer staticRuleId;
|
||||
|
||||
@JsonProperty("static_rule_display_id")
|
||||
@ExcelProperty("ID")
|
||||
@ExcelIgnore
|
||||
@Schema(description = "静态规则显示ID", accessMode = Schema.AccessMode.READ_ONLY)
|
||||
private String staticRuleDisplayId;
|
||||
|
||||
@@ -126,7 +126,7 @@ public class StaticRuleObject {
|
||||
@Schema(description = "协议掩码", example = "TCP")
|
||||
private String staticRuleMprotocol;
|
||||
@JsonProperty("static_rule_dns")
|
||||
@ExcelProperty("DNS")
|
||||
@ExcelProperty("域名")
|
||||
@Schema(description = "DNS", example = "www.baidu.com")
|
||||
private String staticRuleDns;
|
||||
@JsonProperty("static_rule_url")
|
||||
@@ -145,18 +145,21 @@ public class StaticRuleObject {
|
||||
// @Schema(description = "范围", example = "北京", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
// private String staticRuleRange;
|
||||
@JsonProperty("static_rule_frequency")
|
||||
@ExcelProperty("频率")
|
||||
@ExcelIgnore
|
||||
@Min(value = 1)
|
||||
@Schema(description = "频率,最低为1", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer staticRuleFrequency;
|
||||
private Integer staticRuleFrequency = 2;
|
||||
|
||||
@JsonProperty("audit_user_name")
|
||||
@ExcelIgnore
|
||||
@Schema(description = "审核用户名称", example = "user11")
|
||||
private String auditUserName;
|
||||
@JsonProperty("audit_user_id")
|
||||
@ExcelIgnore
|
||||
@Schema(description = "审核用户id", example = "11111")
|
||||
private String auditUserId;
|
||||
@JsonProperty("audit_user_depart")
|
||||
@ExcelIgnore
|
||||
@Schema(description = "审核用户部门", example = "部门1")
|
||||
private String auditUserDepart;
|
||||
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.realtime.protection.server.rule.dynamicrule;
|
||||
|
||||
import com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject;
|
||||
import com.realtime.protection.configuration.entity.user.UserFull;
|
||||
import com.realtime.protection.configuration.response.ResponseResult;
|
||||
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -25,8 +29,17 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
||||
//
|
||||
@Override
|
||||
@PostMapping("/new")
|
||||
public ResponseResult newDynamicRuleObject(@RequestBody @Valid DynamicRuleObject dynamicRuleObject) {
|
||||
log.info("新增动态规则: {}", dynamicRuleObject);
|
||||
public ResponseResult newDynamicRuleObject(@RequestBody @Valid DynamicRuleObject dynamicRuleObject,
|
||||
@Autowired HttpServletRequest request) {
|
||||
// log.info("新增动态规则: {}", dynamicRuleObject);
|
||||
//从http首部session字段获取用户信息
|
||||
HttpSession session = request.getSession();
|
||||
UserFull user = (UserFull) session.getAttribute("user");
|
||||
if (user != null) {
|
||||
dynamicRuleObject.setAuditUserName(user.name);
|
||||
dynamicRuleObject.setAuditUserId(user.uid);
|
||||
dynamicRuleObject.setAuditUserDepart(user.getOrgName());
|
||||
}
|
||||
//调用service新增
|
||||
Integer dynamicRuleObjectId = dynamicRuleService.newDynamicRuleObject(dynamicRuleObject);
|
||||
return ResponseResult.ok().
|
||||
@@ -121,7 +134,7 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
||||
.setData("success", true)
|
||||
.setData("dynamic_rule_list", dynamicRuleService.queryDynamicRuleObject(dynamicRuleName, dynamicRuleId,
|
||||
protectObjectSourceSystem, creator, auditStatus, eventType, protectLevel, templateName, page, pageSize))
|
||||
.setData("total_num",dynamicRuleService.queryDynamicRuleTotalNum(dynamicRuleName, dynamicRuleId,
|
||||
.setData("total_num", dynamicRuleService.queryDynamicRuleTotalNum(dynamicRuleName, dynamicRuleId,
|
||||
protectObjectSourceSystem, creator, auditStatus, eventType, protectLevel, templateName));
|
||||
}
|
||||
|
||||
@@ -133,14 +146,27 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/{id}/audit/{auditStatus}")
|
||||
public ResponseResult updateDynamicRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus) {
|
||||
public ResponseResult updateDynamicRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus,
|
||||
@Autowired HttpServletRequest request) {
|
||||
if (id <= 0 || auditStatus < 0 || auditStatus > 2) {
|
||||
return new ResponseResult(400, "id or status is invalid")
|
||||
.setData("dynamicRule_id", id)
|
||||
.setData("success", false);
|
||||
}
|
||||
//从http首部session字段获取用户信息
|
||||
HttpSession session = request.getSession();
|
||||
UserFull user = (UserFull) session.getAttribute("user");
|
||||
String auditUserName = null;
|
||||
Integer auditUserId = null;
|
||||
String auditUserDepart = null;
|
||||
if (user != null) {
|
||||
auditUserName= user.name;
|
||||
auditUserId = Integer.valueOf(user.uid);
|
||||
auditUserDepart = user.getOrgName();
|
||||
}
|
||||
return ResponseResult.ok()
|
||||
.addDataMap(dynamicRuleService.updateAuditStatus(id, auditStatus))
|
||||
.addDataMap(dynamicRuleService.updateAuditStatus(id, auditStatus
|
||||
,auditUserName, auditUserId, auditUserDepart))
|
||||
.setData("dynamicRule_id", id);
|
||||
}
|
||||
|
||||
@@ -149,23 +175,36 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
||||
*/
|
||||
@Override
|
||||
@PostMapping("/auditbatch")
|
||||
public ResponseResult updateDynamicRuleAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap) {
|
||||
public ResponseResult updateDynamicRuleAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap,
|
||||
@Autowired HttpServletRequest request) {
|
||||
List<Integer> errorIds = new ArrayList<>();
|
||||
for (Map.Entry<Integer, Integer> entry: idsWithAuditStatusMap.entrySet()) {
|
||||
for (Map.Entry<Integer, Integer> entry : idsWithAuditStatusMap.entrySet()) {
|
||||
Integer id = entry.getKey();
|
||||
Integer auditStatus = entry.getValue();
|
||||
if (id <= 0 || auditStatus < 0 || auditStatus > 2) {
|
||||
errorIds.add(id);
|
||||
}
|
||||
}
|
||||
if (!errorIds.isEmpty()){
|
||||
if (!errorIds.isEmpty()) {
|
||||
return new ResponseResult(400, "id or status is invalid")
|
||||
.setData("staticRule_id", errorIds)
|
||||
.setData("success", false);
|
||||
}
|
||||
//从http首部session字段获取用户信息
|
||||
HttpSession session = request.getSession();
|
||||
UserFull user = (UserFull) session.getAttribute("user");
|
||||
String auditUserName = null;
|
||||
String auditUserId = null;
|
||||
String auditUserDepart = null;
|
||||
if (user != null) {
|
||||
auditUserName= user.name;
|
||||
auditUserId = user.uid;
|
||||
auditUserDepart = user.getOrgName();
|
||||
}
|
||||
|
||||
return ResponseResult.ok()
|
||||
.setData("success", dynamicRuleService.updateAuditStatusBatch(idsWithAuditStatusMap));
|
||||
.setData("success", dynamicRuleService.updateAuditStatusBatch(idsWithAuditStatusMap,
|
||||
auditUserName, auditUserId, auditUserDepart));
|
||||
}
|
||||
|
||||
|
||||
@@ -174,10 +213,10 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/statistics")
|
||||
public ResponseResult getStaticRuleStatisticsData(){
|
||||
public ResponseResult getStaticRuleStatisticsData() {
|
||||
|
||||
return ResponseResult.ok()
|
||||
.setData("dynamic_rule_num", dynamicRuleService.queryDynamicRuleTotalNum(null,null, null,
|
||||
.setData("dynamic_rule_num", dynamicRuleService.queryDynamicRuleTotalNum(null, null, null,
|
||||
null, null, null, null, null))
|
||||
.setData("dynamic_rule_used_num", dynamicRuleService.queryAuditDynamicRuleTotalNum(
|
||||
AuditStatusEnum.getNumByState(AuditStatusEnum.USING.getState())
|
||||
@@ -189,6 +228,7 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
||||
AuditStatusEnum.getNumByState(AuditStatusEnum.PENDING.getState())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping("/auditInfo/{ids}")
|
||||
public ResponseResult updateAuditInfo(@PathVariable List<Integer> ids,
|
||||
|
||||
@@ -9,7 +9,9 @@ import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -38,7 +40,8 @@ public interface DynamicRuleControllerApi {
|
||||
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||
description = "动态规则信息")
|
||||
)
|
||||
ResponseResult newDynamicRuleObject(@RequestBody @Valid DynamicRuleObject dynamicRuleObject) ;
|
||||
ResponseResult newDynamicRuleObject(@RequestBody @Valid DynamicRuleObject dynamicRuleObject,
|
||||
@Autowired HttpServletRequest request) ;
|
||||
|
||||
@Operation(
|
||||
summary = "删除动态规则",
|
||||
@@ -380,7 +383,8 @@ public interface DynamicRuleControllerApi {
|
||||
@Parameter(name = "auditStatus", description = "要修改为的审核状态")
|
||||
}
|
||||
)
|
||||
ResponseResult updateDynamicRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus);
|
||||
ResponseResult updateDynamicRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus,
|
||||
@Autowired HttpServletRequest request);
|
||||
|
||||
@Operation(
|
||||
summary = "批量更新审批状态",
|
||||
@@ -403,7 +407,8 @@ public interface DynamicRuleControllerApi {
|
||||
)
|
||||
)
|
||||
)
|
||||
ResponseResult updateDynamicRuleAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap);
|
||||
ResponseResult updateDynamicRuleAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap,
|
||||
@Autowired HttpServletRequest request);
|
||||
|
||||
@Operation(
|
||||
summary = "数据统计",
|
||||
|
||||
@@ -57,7 +57,8 @@ public interface DynamicRuleMapper {
|
||||
|
||||
Integer queryAuditStatusById(Integer dynamicRuleId);
|
||||
|
||||
Boolean updateAuditStatusById(Integer dynamicRuleId, Integer auditStatus);
|
||||
Boolean updateAuditStatusById(Integer dynamicRuleId, Integer auditStatus,
|
||||
String auditUserName, Integer auditUserId, String auditUserDepart);
|
||||
|
||||
void updateAuditStatusByIdBatch(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idWithAuditStatusBatch);
|
||||
|
||||
@@ -66,4 +67,9 @@ public interface DynamicRuleMapper {
|
||||
Boolean updateAuditInfo(@Param("ids")List<Integer> ids, @Param("auditInfo")String auditInfo);
|
||||
|
||||
String queryAuditInfo(Integer id);
|
||||
|
||||
void updateAuditStatusWithAuditorByIdBatch(@Param("idWithAuditStatusBatch")Map<Integer, Integer> idWithAuditStatusBatch,
|
||||
@Param("auditUserName")String auditUserName,
|
||||
@Param("auditUserId")String auditUserId,
|
||||
@Param("auditUserDepart")String auditUserDepart);
|
||||
}
|
||||
|
||||
@@ -213,7 +213,8 @@ public class DynamicRuleService {
|
||||
return dynamicRuleMapper.queryAuditDynamicRuleTotalNum(auditStatus);
|
||||
}
|
||||
|
||||
public Map<String, Object> updateAuditStatus(Integer id, Integer auditStatus) {
|
||||
public Map<String, Object> updateAuditStatus(Integer id, Integer auditStatus,
|
||||
String auditUserName, Integer auditUserId, String auditUserDepart) {
|
||||
Integer originalAuditStatus = dynamicRuleMapper.queryAuditStatusById(id);
|
||||
if (originalAuditStatus == null) {
|
||||
throw new IllegalArgumentException("cannot find audit status of static rule " + id + ", maybe static rule doesn't exist?");
|
||||
@@ -221,7 +222,7 @@ public class DynamicRuleService {
|
||||
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
||||
throw new IllegalArgumentException("invalid audit status");
|
||||
}
|
||||
Boolean success = dynamicRuleMapper.updateAuditStatusById(id, auditStatus);
|
||||
Boolean success = dynamicRuleMapper.updateAuditStatusById(id, auditStatus ,auditUserName, auditUserId, auditUserDepart);
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put("success", success);
|
||||
@@ -229,6 +230,11 @@ public class DynamicRuleService {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于任务状态修改时,内部批量更新任务所属动态规则的状态,不需要修改审批人信息
|
||||
* @param idsWithAuditStatusMap
|
||||
* @return
|
||||
*/
|
||||
public Object updateAuditStatusBatch(Map<Integer, Integer> idsWithAuditStatusMap) {
|
||||
//校验id和status是否合法
|
||||
List<Integer> originalAuditStatusList = dynamicRuleMapper.queryAuditStatusByIds(idsWithAuditStatusMap);
|
||||
@@ -279,6 +285,64 @@ public class DynamicRuleService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于外部调用,更新审批用户信息
|
||||
* @param idsWithAuditStatusMap
|
||||
* @param auditUserName
|
||||
* @param auditUserId
|
||||
* @param auditUserDepart
|
||||
* @return
|
||||
*/
|
||||
public Object updateAuditStatusBatch(Map<Integer, Integer> idsWithAuditStatusMap,
|
||||
String auditUserName, String auditUserId, String auditUserDepart) {
|
||||
//校验id和status是否合法
|
||||
List<Integer> originalAuditStatusList = dynamicRuleMapper.queryAuditStatusByIds(idsWithAuditStatusMap);
|
||||
if (originalAuditStatusList == null || originalAuditStatusList.size() != idsWithAuditStatusMap.size()) {
|
||||
return new IllegalArgumentException("部分动态规则id不存在");
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
List<Integer> errorIds = new ArrayList<>();
|
||||
for(Map.Entry<Integer, Integer> entry: idsWithAuditStatusMap.entrySet()) {
|
||||
Integer id = entry.getKey();
|
||||
Integer auditStatus = entry.getValue();
|
||||
Integer originalAuditStatus = originalAuditStatusList.get(index);
|
||||
index++;
|
||||
|
||||
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
||||
errorIds.add(id);
|
||||
}
|
||||
}
|
||||
if (!errorIds.isEmpty()){
|
||||
return new IllegalArgumentException("动态规则id无法修改为对应审核状态, 错误id: " + errorIds);
|
||||
}
|
||||
|
||||
|
||||
Function<DynamicRuleMapper, Function<Map<Integer, Integer>, Boolean>> updateDynamicRuleAuditStatusFunction =
|
||||
mapper -> map -> {
|
||||
if (map == null || map.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Map<Integer, Integer> idWithAuditStatusBatch = new HashMap<>();
|
||||
for (Map.Entry<Integer, Integer> item : map.entrySet()) {
|
||||
idWithAuditStatusBatch.put(item.getKey(), item.getValue());
|
||||
if (idWithAuditStatusBatch.size() < 100) {
|
||||
continue;
|
||||
}
|
||||
//mapper指的就是外层函数输入的参数,也就是WhiteListMapper
|
||||
mapper.updateAuditStatusWithAuditorByIdBatch(idWithAuditStatusBatch, auditUserName, auditUserId, auditUserDepart);
|
||||
idWithAuditStatusBatch.clear();
|
||||
}
|
||||
if (!idWithAuditStatusBatch.isEmpty()) {
|
||||
mapper.updateAuditStatusWithAuditorByIdBatch(idWithAuditStatusBatch, auditUserName, auditUserId, auditUserDepart);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
//实现事务操作
|
||||
return sqlSessionWrapper.startBatchSession(DynamicRuleMapper.class, updateDynamicRuleAuditStatusFunction, idsWithAuditStatusMap);
|
||||
|
||||
}
|
||||
public List<Integer> queryAuditStatusByIds(Map<Integer, Integer> idsWithAuditStatusMap) {
|
||||
return dynamicRuleMapper.queryAuditStatusByIds(idsWithAuditStatusMap);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import jakarta.servlet.http.HttpSession;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -40,7 +41,7 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
@PostMapping("/new")
|
||||
@Override
|
||||
public ResponseResult newStaticRuleObject(@RequestBody @Valid StaticRuleObject object,
|
||||
HttpServletRequest request) {
|
||||
@Autowired HttpServletRequest request) {
|
||||
// log.info("新增静态规则: {}", object);
|
||||
//从http首部session字段获取用户信息
|
||||
HttpSession session = request.getSession();
|
||||
@@ -61,9 +62,15 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
@PostMapping("/upload")
|
||||
@Override
|
||||
public ResponseResult uploadFile(@NotNull(message = "uploadFile字段不能为空")
|
||||
MultipartFile uploadFile) throws IOException {
|
||||
MultipartFile uploadFile,
|
||||
@Autowired HttpServletRequest request) throws IOException {
|
||||
//从http首部session字段获取用户信息
|
||||
HttpSession session = request.getSession();
|
||||
UserFull user = (UserFull) session.getAttribute("user");
|
||||
|
||||
|
||||
EasyExcel.read(uploadFile.getInputStream(), StaticRuleObject.class,
|
||||
new StaticRuleDataListener(staticRuleService)).sheet().doRead();
|
||||
new StaticRuleDataListener(staticRuleService, user)).sheet().doRead();
|
||||
return ResponseResult.ok();
|
||||
}
|
||||
|
||||
@@ -179,14 +186,27 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/{id}/audit/{auditStatus}")
|
||||
public ResponseResult updateStaticRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus) {
|
||||
public ResponseResult updateStaticRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus,
|
||||
@Autowired HttpServletRequest request) {
|
||||
if (id <= 0 || auditStatus < 0 || auditStatus > 2) {
|
||||
return new ResponseResult(400, "id or status is invalid")
|
||||
.setData("staticRule_id", id)
|
||||
.setData("success", false);
|
||||
}
|
||||
//从http首部session字段获取用户信息
|
||||
HttpSession session = request.getSession();
|
||||
UserFull user = (UserFull) session.getAttribute("user");
|
||||
String auditUserName = null;
|
||||
Integer auditUserId = null;
|
||||
String auditUserDepart = null;
|
||||
if (user != null) {
|
||||
auditUserName= user.name;
|
||||
auditUserId = Integer.valueOf(user.uid);
|
||||
auditUserDepart = user.getOrgName();
|
||||
}
|
||||
return ResponseResult.ok()
|
||||
.addDataMap(staticRuleService.updateAuditStatus(id, auditStatus))
|
||||
.addDataMap(staticRuleService.updateAuditStatus(id, auditStatus,
|
||||
auditUserName, auditUserId, auditUserDepart))
|
||||
.setData("staticRule_id", id);
|
||||
|
||||
}
|
||||
@@ -197,7 +217,8 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
*/
|
||||
@Override
|
||||
@PostMapping("/auditbatch")
|
||||
public ResponseResult updateStaticRuleAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap) {
|
||||
public ResponseResult updateStaticRuleAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap,
|
||||
@Autowired HttpServletRequest request) {
|
||||
List<Integer> errorIds = new ArrayList<>();
|
||||
for (Map.Entry<Integer, Integer> entry: idsWithAuditStatusMap.entrySet()) {
|
||||
Integer id = entry.getKey();
|
||||
@@ -212,8 +233,21 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
.setData("success", false);
|
||||
}
|
||||
|
||||
//从http首部session字段获取用户信息
|
||||
HttpSession session = request.getSession();
|
||||
UserFull user = (UserFull) session.getAttribute("user");
|
||||
String auditUserName = null;
|
||||
Integer auditUserId = null;
|
||||
String auditUserDepart = null;
|
||||
if (user != null) {
|
||||
auditUserName= user.name;
|
||||
auditUserId = Integer.valueOf(user.uid);
|
||||
auditUserDepart = user.getOrgName();
|
||||
}
|
||||
|
||||
return ResponseResult.ok()
|
||||
.setData("success", staticRuleService.updateAuditStatusBatch(idsWithAuditStatusMap));
|
||||
.setData("success", staticRuleService.updateAuditStatusBatch(idsWithAuditStatusMap,
|
||||
auditUserName, auditUserId, auditUserDepart));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -70,7 +71,8 @@ public interface StaticRuleControllerApi {
|
||||
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||
description = "Excel文件")
|
||||
)
|
||||
ResponseResult uploadFile(@NotNull(message = "uploadFile字段不能为空") MultipartFile uploadFile) throws IOException;
|
||||
ResponseResult uploadFile(@NotNull(message = "uploadFile字段不能为空") MultipartFile uploadFile,
|
||||
@Autowired HttpServletRequest request) throws IOException;
|
||||
|
||||
@Operation(
|
||||
summary = "下载静态规则模板",
|
||||
@@ -288,7 +290,8 @@ public interface StaticRuleControllerApi {
|
||||
@Parameter(name = "auditStatus", description = "要修改为的静态规则审核状态")
|
||||
}
|
||||
)
|
||||
ResponseResult updateStaticRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus);
|
||||
ResponseResult updateStaticRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus,
|
||||
@Autowired HttpServletRequest request);
|
||||
|
||||
@PostMapping("/auditbatch")
|
||||
@Operation(
|
||||
@@ -312,7 +315,8 @@ public interface StaticRuleControllerApi {
|
||||
)
|
||||
)
|
||||
)
|
||||
ResponseResult updateStaticRuleAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap);
|
||||
ResponseResult updateStaticRuleAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap,
|
||||
@Autowired HttpServletRequest request);
|
||||
|
||||
@Operation(
|
||||
summary = "数据统计",
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.read.listener.ReadListener;
|
||||
import com.alibaba.excel.util.ListUtils;
|
||||
import com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleObject;
|
||||
import com.realtime.protection.configuration.entity.user.UserFull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
@@ -15,9 +16,11 @@ public class StaticRuleDataListener implements ReadListener<StaticRuleObject> {
|
||||
= ListUtils.newArrayListWithExpectedSize(batchCount);
|
||||
|
||||
private final StaticRuleService staticRuleService;
|
||||
private UserFull user;
|
||||
|
||||
public StaticRuleDataListener(StaticRuleService staticRuleService) {
|
||||
public StaticRuleDataListener(StaticRuleService staticRuleService, UserFull user) {
|
||||
this.staticRuleService = staticRuleService;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,6 +36,11 @@ public class StaticRuleDataListener implements ReadListener<StaticRuleObject> {
|
||||
object.getStaticRuleDip() + ",目的ip掩码:" +
|
||||
object.getStaticRuleMdip() );
|
||||
}
|
||||
if (user != null) {
|
||||
object.setStaticRuleCreateUsername(user.name);
|
||||
object.setStaticRuleCreateUserId(Integer.valueOf(user.uid));
|
||||
object.setStaticRuleCreateDepart(user.getOrgName());
|
||||
}
|
||||
cachedDataList.add(object);
|
||||
if (cachedDataList.size() > batchCount) {
|
||||
saveData();
|
||||
@@ -54,7 +62,7 @@ public class StaticRuleDataListener implements ReadListener<StaticRuleObject> {
|
||||
Boolean success = staticRuleService.newStaticRuleObjects(cachedDataList);
|
||||
log.info("存储数据库成功!");
|
||||
if (!success) {
|
||||
throw new RuntimeException("Error reading data in /proobj/new");
|
||||
throw new RuntimeException("批量导入静态规则存储数据库时出现错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,10 @@ public interface StaticRuleMapper {
|
||||
|
||||
Integer queryAuditStatusById(Integer id);
|
||||
|
||||
Boolean updateAuditStatusById(Integer id, Integer auditStatus,
|
||||
String auditUserName,
|
||||
Integer auditUserId,
|
||||
String auditUserDepart);
|
||||
Boolean updateAuditStatusById(Integer id, Integer auditStatus);
|
||||
|
||||
Integer queryStaticRuleTotalNum(String static_rule_name, Integer static_rule_id,
|
||||
@@ -51,7 +55,10 @@ public interface StaticRuleMapper {
|
||||
List<StaticRuleObject> queryStaticRuleByIds(List<Integer> ids);
|
||||
|
||||
void updateAuditStatusByIdBatch(@Param("idWithAuditStatusBatch")Map<Integer, Integer> idWithAuditStatusBatch);
|
||||
|
||||
void updateAuditStatusWithAuditorByIdBatch(@Param("idWithAuditStatusBatch")Map<Integer, Integer> idWithAuditStatusBatch,
|
||||
@Param("auditUserName")String auditUserName,
|
||||
@Param("auditUserId")Integer auditUserId,
|
||||
@Param("auditUserDepart")String auditUserDepart);
|
||||
Integer queryUsedStaticRuleTotalNum();
|
||||
|
||||
Integer queryAuditStaticRuleTotalNum(@Param("auditStatus")Integer auditStatus);
|
||||
|
||||
@@ -222,8 +222,12 @@ public class StaticRuleService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public Map<String, Object> updateAuditStatus(Integer id, Integer auditStatus) {
|
||||
public Map<String, Object> updateAuditStatus(Integer id, Integer auditStatus,
|
||||
String auditUserName,
|
||||
Integer auditUserId,
|
||||
String auditUserDepart) {
|
||||
Integer originalAuditStatus = staticRuleMapper.queryAuditStatusById(id);
|
||||
if (originalAuditStatus == null) {
|
||||
throw new IllegalArgumentException("cannot find audit status of static rule " + id + ", maybe static rule doesn't exist?");
|
||||
@@ -231,7 +235,7 @@ public class StaticRuleService {
|
||||
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
||||
throw new IllegalArgumentException("invalid audit status");
|
||||
}
|
||||
Boolean success = staticRuleMapper.updateAuditStatusById(id, auditStatus);
|
||||
Boolean success = staticRuleMapper.updateAuditStatusById(id, auditStatus, auditUserName, auditUserId, auditUserDepart);
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put("success", success);
|
||||
@@ -266,7 +270,58 @@ public class StaticRuleService {
|
||||
return staticRuleMapper.queryStaticRuleByIds(ids);
|
||||
}
|
||||
|
||||
public Boolean updateAuditStatusBatch(Map<Integer, Integer> idsWithAuditStatusMap) {
|
||||
public Boolean updateAuditStatusBatch(Map<Integer, Integer> idsWithAuditStatusMap,
|
||||
String auditUserName, Integer auditUserId, String auditUserDepart ) {
|
||||
//校验id和status是否合法
|
||||
List<Integer> originalAuditStatusList = staticRuleMapper.queryAuditStatusByIds(idsWithAuditStatusMap);
|
||||
if (originalAuditStatusList == null || originalAuditStatusList.size() != idsWithAuditStatusMap.size()) {
|
||||
throw new IllegalArgumentException("部分静态规则id不存在");
|
||||
}
|
||||
int index = 0;
|
||||
List<Integer> errorIds = new ArrayList<>();
|
||||
for(Map.Entry<Integer, Integer> entry: idsWithAuditStatusMap.entrySet()) {
|
||||
Integer id = entry.getKey();
|
||||
Integer auditStatus = entry.getValue();
|
||||
Integer originalAuditStatus = originalAuditStatusList.get(index);
|
||||
index++;
|
||||
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
||||
errorIds.add(id);
|
||||
}
|
||||
}
|
||||
if (!errorIds.isEmpty()){
|
||||
throw new IllegalArgumentException("静态规则id无法修改为对应审核状态, 错误id: " + errorIds);
|
||||
}
|
||||
|
||||
Function<StaticRuleMapper, Function<Map<Integer, Integer>, Boolean>> updateStaticRuleAuditStatusFunction =
|
||||
mapper -> map -> {
|
||||
if (map == null || map.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Map<Integer, Integer> idWithAuditStatusBatch = new HashMap<>();
|
||||
for (Map.Entry<Integer, Integer> item : map.entrySet()) {
|
||||
idWithAuditStatusBatch.put(item.getKey(), item.getValue());
|
||||
if (idWithAuditStatusBatch.size() < 100) {
|
||||
continue;
|
||||
}
|
||||
//mapper指的就是外层函数输入的参数,也就是WhiteListMapper
|
||||
mapper.updateAuditStatusWithAuditorByIdBatch(idWithAuditStatusBatch,
|
||||
auditUserName, auditUserId, auditUserDepart);
|
||||
idWithAuditStatusBatch.clear();
|
||||
}
|
||||
if (!idWithAuditStatusBatch.isEmpty()) {
|
||||
mapper.updateAuditStatusWithAuditorByIdBatch(idWithAuditStatusBatch,
|
||||
auditUserName, auditUserId, auditUserDepart);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
//实现事务操作
|
||||
return sqlSessionWrapper.startBatchSession(StaticRuleMapper.class, updateStaticRuleAuditStatusFunction, idsWithAuditStatusMap);
|
||||
}
|
||||
|
||||
|
||||
public Boolean updateAuditStatusBatch(Map<Integer, Integer> idsWithAuditStatusMap
|
||||
) {
|
||||
//校验id和status是否合法
|
||||
List<Integer> originalAuditStatusList = staticRuleMapper.queryAuditStatusByIds(idsWithAuditStatusMap);
|
||||
if (originalAuditStatusList == null || originalAuditStatusList.size() != idsWithAuditStatusMap.size()) {
|
||||
|
||||
@@ -2,16 +2,20 @@ package com.realtime.protection.server.task;
|
||||
|
||||
import com.realtime.protection.configuration.entity.task.Task;
|
||||
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
|
||||
import com.realtime.protection.configuration.entity.user.UserFull;
|
||||
import com.realtime.protection.configuration.exception.DorisStartException;
|
||||
import com.realtime.protection.configuration.response.ResponseResult;
|
||||
import com.realtime.protection.configuration.utils.enums.StateEnum;
|
||||
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
|
||||
import com.realtime.protection.server.command.CommandService;
|
||||
import com.realtime.protection.server.task.status.StateChangeService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -34,7 +38,18 @@ public class TaskController implements TaskControllerApi {
|
||||
|
||||
@Override
|
||||
@PostMapping("/new")
|
||||
public ResponseResult newTask(@RequestBody @Valid Task task) {
|
||||
public ResponseResult newTask(@RequestBody @Valid Task task,
|
||||
@Autowired HttpServletRequest request) {
|
||||
|
||||
//从http首部session字段获取用户信息
|
||||
HttpSession session = request.getSession();
|
||||
UserFull user = (UserFull) session.getAttribute("user");
|
||||
if (user != null) {
|
||||
task.setTaskCreateUsername(user.name);
|
||||
task.setTaskCreateUserId(Integer.valueOf(user.uid));
|
||||
task.setTaskCreateDepart(user.getOrgName());
|
||||
}
|
||||
|
||||
Long taskId = taskService.newTask(task);
|
||||
|
||||
if (taskId > 0) {
|
||||
@@ -113,11 +128,23 @@ public class TaskController implements TaskControllerApi {
|
||||
@Override
|
||||
@GetMapping("/{taskId}/audit/{auditStatus}")
|
||||
public ResponseResult changeTaskAuditStatus(@PathVariable @NotNull @Max(10) Integer auditStatus,
|
||||
@PathVariable @NotNull @Min(1) Long taskId) {
|
||||
|
||||
@PathVariable @NotNull @Min(1) Long taskId,
|
||||
@Autowired HttpServletRequest request) {
|
||||
//从http首部session字段获取用户信息
|
||||
HttpSession session = request.getSession();
|
||||
UserFull user = (UserFull) session.getAttribute("user");
|
||||
String auditUserName = null;
|
||||
String auditUserId = null;
|
||||
String auditUserDepart = null;
|
||||
if (user != null) {
|
||||
auditUserName= user.name;
|
||||
auditUserId = user.uid;
|
||||
auditUserDepart = user.getOrgName();
|
||||
}
|
||||
return ResponseResult.ok()
|
||||
.setData("task_id", taskId)
|
||||
.setData("success", taskService.changeTaskAuditStatus(taskId, auditStatus))
|
||||
.setData("success", taskService.changeTaskAuditStatus(taskId, auditStatus,
|
||||
auditUserName, auditUserId, auditUserDepart))
|
||||
.setData("audit_status", taskService.queryTaskAuditStatus(taskId));
|
||||
}
|
||||
|
||||
@@ -172,7 +199,8 @@ public class TaskController implements TaskControllerApi {
|
||||
*/
|
||||
@Override
|
||||
@PostMapping("/auditbatch")
|
||||
public ResponseResult updateTaskAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap) {
|
||||
public ResponseResult updateTaskAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap,
|
||||
@Autowired HttpServletRequest request) {
|
||||
List<Integer> errorIds = new ArrayList<>();
|
||||
for (Map.Entry<Integer, Integer> entry: idsWithAuditStatusMap.entrySet()) {
|
||||
Integer id = entry.getKey();
|
||||
@@ -186,9 +214,21 @@ public class TaskController implements TaskControllerApi {
|
||||
.setData("tasks_id", errorIds)
|
||||
.setData("success", false);
|
||||
}
|
||||
//从http首部session字段获取用户信息
|
||||
HttpSession session = request.getSession();
|
||||
UserFull user = (UserFull) session.getAttribute("user");
|
||||
String auditUserName = null;
|
||||
String auditUserId = null;
|
||||
String auditUserDepart = null;
|
||||
if (user != null) {
|
||||
auditUserName= user.name;
|
||||
auditUserId = user.uid;
|
||||
auditUserDepart = user.getOrgName();
|
||||
}
|
||||
|
||||
return ResponseResult.ok()
|
||||
.setData("success", taskService.updateAuditStatusBatch(idsWithAuditStatusMap));
|
||||
.setData("success", taskService.updateAuditStatusBatch(idsWithAuditStatusMap,
|
||||
auditUserName, auditUserId, auditUserDepart));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,10 +11,12 @@ import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -59,7 +61,7 @@ public interface TaskControllerApi {
|
||||
},
|
||||
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "任务信息")
|
||||
)
|
||||
ResponseResult newTask(@RequestBody @Valid Task task);
|
||||
ResponseResult newTask(@RequestBody @Valid Task task,@Autowired HttpServletRequest request);
|
||||
|
||||
// API推送Endpoint
|
||||
@PostMapping("/api/new")
|
||||
@@ -349,7 +351,8 @@ public interface TaskControllerApi {
|
||||
}
|
||||
)
|
||||
ResponseResult changeTaskAuditStatus(@PathVariable @NotNull @Max(10) Integer auditStatus,
|
||||
@PathVariable @NotNull @Min(1) Long taskId);
|
||||
@PathVariable @NotNull @Min(1) Long taskId,
|
||||
@Autowired HttpServletRequest request);
|
||||
|
||||
@DeleteMapping("/{taskId}/delete")
|
||||
@Operation(
|
||||
@@ -555,7 +558,8 @@ public interface TaskControllerApi {
|
||||
)
|
||||
)
|
||||
@PostMapping("/auditbatch")
|
||||
ResponseResult updateTaskAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap);
|
||||
ResponseResult updateTaskAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap,
|
||||
@Autowired HttpServletRequest request);
|
||||
|
||||
@Operation(
|
||||
summary = "数据统计",
|
||||
|
||||
@@ -38,6 +38,11 @@ public interface TaskMapper {
|
||||
|
||||
void clearTaskConnectedDynamicRule(@Param("task_id") Long taskId);
|
||||
|
||||
void changeTaskAuditStatusWithAudior(@Param("task_id") Long taskId, @Param("audit_status") Integer auditStatus,
|
||||
@Param("auditUserName")String auditUserName,
|
||||
@Param("auditUserId")String auditUserId,
|
||||
@Param("auditUserDepart")String auditUserDepart);
|
||||
|
||||
void changeTaskAuditStatus(@Param("task_id") Long taskId, @Param("audit_status") Integer auditStatus);
|
||||
|
||||
Boolean deleteTask(@Param("task_id") Long taskId);
|
||||
@@ -78,4 +83,9 @@ public interface TaskMapper {
|
||||
Boolean updateAuditInfo(@Param("ids")List<Integer> ids, @Param("auditInfo")String auditInfo);
|
||||
|
||||
String queryAuditInfo(Integer id);
|
||||
|
||||
void updateAuditStatusWithAuditorByIdBatch(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idWithAuditStatusBatch,
|
||||
@Param("auditUserName")String auditUserName,
|
||||
@Param("auditUserId")String auditUserId,
|
||||
@Param("auditUserDepart")String auditUserDepart);
|
||||
}
|
||||
|
||||
@@ -276,6 +276,20 @@ public class TaskService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Boolean changeTaskAuditStatus(Long taskId, Integer taskAuditStatus,
|
||||
String auditUserName, String auditUserId, String auditUserDepart) {
|
||||
Integer originalAuditStatus = taskMapper.queryTaskAuditStatus(taskId);
|
||||
if (originalAuditStatus == null) {
|
||||
throw new IllegalArgumentException("无法找到任务ID为" + taskId + "的任务,也许任务不存在?");
|
||||
}
|
||||
|
||||
if (AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(taskAuditStatus))
|
||||
taskMapper.changeTaskAuditStatusWithAudior(taskId, taskAuditStatus, auditUserName, auditUserId, auditUserDepart);
|
||||
else return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@Transactional
|
||||
public Boolean changeTaskAuditStatus(Long taskId, Integer taskAuditStatus) {
|
||||
Integer originalAuditStatus = taskMapper.queryTaskAuditStatus(taskId);
|
||||
@@ -394,6 +408,57 @@ public class TaskService {
|
||||
return sqlSessionWrapper.startBatchSession(TaskMapper.class, updateTaskAuditStatusFunction, idsWithAuditStatusMap);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Boolean updateAuditStatusBatch(Map<Integer, Integer> idsWithAuditStatusMap,
|
||||
String auditUserName, String auditUserId, String auditUserDepart) {
|
||||
//校验id和status是否合法
|
||||
List<Integer> originalAuditStatusList = taskMapper.queryAuditStatusByIds(idsWithAuditStatusMap);
|
||||
if (originalAuditStatusList == null || originalAuditStatusList.size() != idsWithAuditStatusMap.size()) {
|
||||
throw new IllegalArgumentException("任务id部分不存在");
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
List<Integer> errorIds = new ArrayList<>();
|
||||
for(Map.Entry<Integer, Integer> entry: idsWithAuditStatusMap.entrySet()) {
|
||||
Integer id = entry.getKey();
|
||||
Integer auditStatus = entry.getValue();
|
||||
Integer originalAuditStatus = originalAuditStatusList.get(index);
|
||||
index++;
|
||||
|
||||
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
||||
errorIds.add(id);
|
||||
}
|
||||
}
|
||||
if (!errorIds.isEmpty()){
|
||||
throw new IllegalArgumentException("动态规则id无法修改为对应审核状态, errorIds: " + errorIds);
|
||||
}
|
||||
|
||||
Function<TaskMapper, Function<Map<Integer, Integer>, Boolean>> updateTaskAuditStatusFunction =
|
||||
mapper -> map -> {
|
||||
if (map == null || map.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Map<Integer, Integer> idWithAuditStatusBatch = new HashMap<>();
|
||||
for (Map.Entry<Integer, Integer> item : map.entrySet()) {
|
||||
idWithAuditStatusBatch.put(item.getKey(), item.getValue());
|
||||
if (idWithAuditStatusBatch.size() < 100) {
|
||||
continue;
|
||||
}
|
||||
//mapper指的就是外层函数输入的参数,也就是WhiteListMapper
|
||||
mapper.updateAuditStatusWithAuditorByIdBatch(idWithAuditStatusBatch, auditUserName, auditUserId, auditUserDepart);
|
||||
idWithAuditStatusBatch.clear();
|
||||
}
|
||||
if (!idWithAuditStatusBatch.isEmpty()) {
|
||||
mapper.updateAuditStatusWithAuditorByIdBatch(idWithAuditStatusBatch, auditUserName, auditUserId, auditUserDepart);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
//实现事务操作
|
||||
return sqlSessionWrapper.startBatchSession(TaskMapper.class, updateTaskAuditStatusFunction, idsWithAuditStatusMap);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Integer queryAuditTaskTotalNum(Integer auditState) {
|
||||
|
||||
@@ -102,14 +102,19 @@
|
||||
</update>
|
||||
<update id="updateAuditStatusById">
|
||||
update t_dynamic_rule
|
||||
set audit_status = #{auditStatus}
|
||||
set audit_status = #{auditStatus},
|
||||
audit_user_id = #{auditUserId},
|
||||
audit_user_name = #{auditUserName},
|
||||
audit_user_depart = #{auditUserDepart},
|
||||
modify_time = NOW()
|
||||
where dynamic_rule_id = #{dynamicRuleId}
|
||||
</update>
|
||||
|
||||
<!-- 用于批量更新审核状态 -->
|
||||
<update id="updateAuditStatusByIdBatch">
|
||||
update t_dynamic_rule
|
||||
set audit_status = CASE dynamic_rule_id
|
||||
set modify_time = NOW(),
|
||||
audit_status = CASE dynamic_rule_id
|
||||
<foreach collection="idWithAuditStatusBatch" index="id" item="auditStatus" separator=" ">
|
||||
WHEN #{id} THEN #{auditStatus}
|
||||
</foreach>
|
||||
@@ -128,6 +133,23 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="updateAuditStatusWithAuditorByIdBatch">
|
||||
update t_dynamic_rule
|
||||
set audit_user_id = #{auditUserId},
|
||||
audit_user_name = #{auditUserName},
|
||||
audit_user_depart = #{auditUserDepart},
|
||||
modify_time = NOW(),
|
||||
audit_status = CASE dynamic_rule_id
|
||||
<foreach collection="idWithAuditStatusBatch" index="id" item="auditStatus" separator=" ">
|
||||
WHEN #{id} THEN #{auditStatus}
|
||||
</foreach>
|
||||
ELSE audit_status
|
||||
END
|
||||
WHERE dynamic_rule_id IN
|
||||
<foreach collection="idWithAuditStatusBatch" index="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
|
||||
<resultMap id="dynamicRuleMap"
|
||||
@@ -161,6 +183,9 @@
|
||||
<result column="strategy_template_source_system" property="dynamicRuleSourceSystem"/>
|
||||
<result column="audit_status" property="auditStatus"/>
|
||||
<result column="dynamic_rule_display_id" property="dynamicRuleDisplayId"/>
|
||||
<result column="audit_user_name" property="auditUserName"/>
|
||||
<result column="audit_user_id" property="auditUserId"/>
|
||||
<result column="audit_user_depart" property="auditUserDepart"/>
|
||||
|
||||
</resultMap>
|
||||
|
||||
|
||||
@@ -81,11 +81,17 @@
|
||||
</set>
|
||||
where static_rule_id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateAuditStatusById">
|
||||
update t_static_rule
|
||||
set static_rule_audit_status = #{auditStatus}
|
||||
set static_rule_modify_time = NOW(),
|
||||
static_rule_audit_status = #{auditStatus},
|
||||
audit_user_id = #{auditUserId},
|
||||
audit_user_name = #{auditUserName},
|
||||
audit_user_depart = #{auditUserDepart}
|
||||
where static_rule_id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateAuditStatusByIdBatch">
|
||||
update t_static_rule
|
||||
set static_rule_modify_time = NOW(),
|
||||
@@ -110,6 +116,23 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="updateAuditStatusWithAuditorByIdBatch">
|
||||
update t_static_rule
|
||||
set static_rule_modify_time = NOW(),
|
||||
audit_user_id = #{auditUserId},
|
||||
audit_user_name = #{auditUserName},
|
||||
audit_user_depart = #{auditUserDepart},
|
||||
static_rule_audit_status = CASE static_rule_id
|
||||
<foreach collection="idWithAuditStatusBatch" index="id" item="auditStatus" separator=" ">
|
||||
WHEN #{id} THEN #{auditStatus}
|
||||
</foreach>
|
||||
ELSE static_rule_audit_status
|
||||
END
|
||||
WHERE static_rule_id IN
|
||||
<foreach collection="idWithAuditStatusBatch" index="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteStaticRules">
|
||||
delete from t_static_rule
|
||||
@@ -130,6 +153,9 @@
|
||||
<result column="static_rule_audit_status" property="auditStatus"/>
|
||||
<result column="static_rule_create_user_id" property="staticRuleCreateUserId"/>
|
||||
<result column="static_rule_modify_time" property="staticRuleModifyTime"/>
|
||||
<result column="audit_user_name" property="auditUserName"/>
|
||||
<result column="audit_user_id" property="auditUserId"/>
|
||||
<result column="audit_user_depart" property="auditUserDepart"/>
|
||||
|
||||
<result column="static_rule_sip_d" property="staticRuleSip"/>
|
||||
<result column="static_rule_msip_d" property="staticRuleMsip"/>
|
||||
|
||||
@@ -218,6 +218,33 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="changeTaskAuditStatusWithAudior">
|
||||
UPDATE t_task
|
||||
SET task_status = #{state},
|
||||
task_modify_time = NOW(),
|
||||
task_audit_username = #{auditUserName},
|
||||
task_audit_userid = #{auditUserId},
|
||||
task_audit_depart = #{auditUserDepart}
|
||||
|
||||
WHERE task_id = #{task_id}
|
||||
</update>
|
||||
<update id="updateAuditStatusWithAuditorByIdBatch">
|
||||
update t_task
|
||||
set task_modify_time = NOW(),
|
||||
task_audit_username = #{auditUserName},
|
||||
task_audit_userid = #{auditUserId},
|
||||
task_audit_depart = #{auditUserDepart},
|
||||
task_audit_status = CASE task_id
|
||||
<foreach collection="idWithAuditStatusBatch" index="id" item="auditStatus" separator=" ">
|
||||
WHEN #{id} THEN #{auditStatus}
|
||||
</foreach>
|
||||
ELSE task_audit_status
|
||||
END
|
||||
WHERE task_id IN
|
||||
<foreach collection="idWithAuditStatusBatch" index="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteTask">
|
||||
DELETE
|
||||
|
||||
@@ -77,6 +77,7 @@ public class AlertMessageTest {
|
||||
task.setTaskCreateUserId(1);
|
||||
task.setTaskCreateUsername("xxx");
|
||||
task.setTaskCreateDepart("xxx");
|
||||
task.setTaskRange("北京");
|
||||
task.setDynamicRuleIds(List.of(new Integer[]{dynamicRuleId}));
|
||||
Long taskId = taskService.newTask(task);
|
||||
System.out.println(taskId);
|
||||
|
||||
Reference in New Issue
Block a user