1、DynamicRule的新增、更新添加对id、protectObjectId的判断;分页查询添加creator、sourceSystem查询条件;按id查询新增template_id为null的判断
2、StaticRule新增usedTaskStatus字段,多查单查返回usedTaskStatus;增、改、查、改审核状态添加id无效判断; 分页新增creator、ip查询条件 3、whiteList修改审核status,添加id无效判断
This commit is contained in:
@@ -3,6 +3,7 @@ package com.realtime.protection.configuration.entity.rule.dynamicrule;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -39,7 +40,8 @@ public class DynamicRuleObject {
|
||||
private String dynamicRuleCreateDepart;
|
||||
|
||||
//动态规则选择的防护对象ids?
|
||||
@NotNull
|
||||
@NotNull(message = "防护对象不能为NULL")
|
||||
@NotEmpty(message = "防护对象不能为空")
|
||||
@JsonProperty("protect_object_ids")
|
||||
@Schema(description = "请求时发送防护对象ID", accessMode = Schema.AccessMode.WRITE_ONLY, requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<Integer> protectObjectIds;
|
||||
|
||||
@@ -60,6 +60,10 @@ public class StaticRuleObject {
|
||||
@ExcelIgnore
|
||||
@Schema(hidden = true)
|
||||
private Integer staticRuleUsedTaskId;
|
||||
@JsonProperty("static_rule_used_task_status")
|
||||
@ExcelIgnore
|
||||
@Schema(hidden = true)
|
||||
private Integer usedTaskStatus;
|
||||
|
||||
@JsonProperty("static_rule_sip")
|
||||
@ExcelProperty("源IP地址")
|
||||
|
||||
@@ -72,11 +72,9 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
||||
log.info("修改动态规则: {}:{}",
|
||||
id, dynamicRuleObject.getDynamicRuleName());
|
||||
|
||||
dynamicRuleService.updateDynamicRuleObject(id, dynamicRuleObject);
|
||||
|
||||
return ResponseResult.ok()
|
||||
.setData("dynamic_rule_id", id)
|
||||
.setData("success", true);
|
||||
.setData("success", dynamicRuleService.updateDynamicRuleObject(id, dynamicRuleObject));
|
||||
}
|
||||
|
||||
//id查询
|
||||
@@ -85,12 +83,9 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
||||
public ResponseResult queryDynamicRuleObjectById(@PathVariable Integer id) {
|
||||
log.info("查询动态规则: {}", id);
|
||||
DynamicRuleObject dynamicRuleObject = dynamicRuleService.queryDynamicRuleById(id);
|
||||
if (dynamicRuleObject == null) {
|
||||
return ResponseResult.invalid()
|
||||
.setData("dynamic_rule", null);
|
||||
}
|
||||
//调用service查询
|
||||
return ResponseResult.ok()
|
||||
.setData("success", true)
|
||||
.setData("dynamic_rule", dynamicRuleObject);
|
||||
}
|
||||
|
||||
@@ -99,12 +94,16 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
||||
@GetMapping("/query")
|
||||
public ResponseResult queryDynamicRuleObject(@RequestParam(value = "name", required = false) String dynamicRuleName,
|
||||
@RequestParam(value = "id", required = false) Integer dynamicRuleId,
|
||||
@RequestParam(value = "source_system", required = false) String protectObjectSourceSystem,
|
||||
@RequestParam(value = "creator", required = false) String creator,
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "page_size", defaultValue = "10") Integer pageSize) {
|
||||
log.info("分页查询动态规则: {}:{}:{}:{}", dynamicRuleName, dynamicRuleId, page, pageSize);
|
||||
//调用service查询
|
||||
return ResponseResult.ok()
|
||||
.setData("dynamic_rule_list", dynamicRuleService.queryDynamicRuleObject(dynamicRuleName, dynamicRuleId, page, pageSize));
|
||||
.setData("success", true)
|
||||
.setData("dynamic_rule_list", dynamicRuleService.queryDynamicRuleObject(dynamicRuleName, dynamicRuleId,
|
||||
protectObjectSourceSystem, creator, page, pageSize));
|
||||
}
|
||||
|
||||
//详情查看?? 就是按id查询吧
|
||||
|
||||
@@ -131,15 +131,18 @@ public interface DynamicRuleControllerApi {
|
||||
parameters = {
|
||||
@Parameter(name = "name", description = "动态规则名称", example = "test"),
|
||||
@Parameter(name = "id", description = "动态规则ID", example = "2"),
|
||||
@Parameter(name = "source_system", description = "来源你系统", example = "BW系统"),
|
||||
@Parameter(name = "creator", description = "创建人名称"),
|
||||
@Parameter(name = "page", description = "页码", example = "1"),
|
||||
@Parameter(name = "page_size", description = "每页大小", example = "10")
|
||||
}
|
||||
)
|
||||
public ResponseResult queryDynamicRuleObject(
|
||||
@RequestParam(value = "name", required = false) String dynamicRuleName,
|
||||
@RequestParam(value = "id", required = false) Integer dynamicRuleId,
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "page_size", defaultValue = "10") Integer pageSize) ;
|
||||
ResponseResult queryDynamicRuleObject(@RequestParam(value = "name", required = false) String dynamicRuleName,
|
||||
@RequestParam(value = "id", required = false) Integer dynamicRuleId,
|
||||
@RequestParam(value = "source_system", required = false) String protectObjectSourceSystem,
|
||||
@RequestParam(value = "creator", required = false) String creator,
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "page_size", defaultValue = "10") Integer pageSize);
|
||||
|
||||
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public interface DynamicRuleMapper {
|
||||
void newDynamicRule(@Param("object") DynamicRuleObject dynamicRuleObject);
|
||||
|
||||
//新建动态规则与保护对象关联
|
||||
void newDynamicRulProtectObjectConcat(long dynamicRuleId, Integer protectObjectId);
|
||||
Boolean newDynamicRulProtectObjectConcat(long dynamicRuleId, Integer protectObjectId);
|
||||
|
||||
void deleteDynamicRuleObject(Integer dynamicRuleId);
|
||||
|
||||
@@ -23,15 +23,21 @@ public interface DynamicRuleMapper {
|
||||
|
||||
List<ProtectObject> queryProtectObjectByRuleId(Integer dynamicRuleId);
|
||||
|
||||
void updateDynamicRuleObject(@Param("dynamicRuleId") Integer dynamicRuleId, @Param("object") DynamicRuleObject dynamicRuleObject);
|
||||
Boolean updateDynamicRuleObject(@Param("dynamicRuleId") Integer dynamicRuleId, @Param("object") DynamicRuleObject dynamicRuleObject);
|
||||
|
||||
void newDynamicRules(List<DynamicRuleObject> dynamicRuleObjects);
|
||||
|
||||
void deleteDynamicRules(List<Integer> dynamicRuleIds);
|
||||
|
||||
List<DynamicRuleObject> queryDynamicRuleObject(String dynamicRuleName, Integer dynamicRuleId, Integer page, Integer pageSize);
|
||||
List<DynamicRuleObject> queryDynamicRuleObject(String dynamicRuleName, Integer dynamicRuleId,
|
||||
String sourceSystem, String creator,
|
||||
Integer page, Integer pageSize);
|
||||
|
||||
void deleteDynamicRuleProtectObjectConcat(Integer dynamicRuleId);
|
||||
|
||||
Template queryTemplateByRuleId(Integer dynamicRuleId);
|
||||
|
||||
boolean newDynamicRulProtectObjectsConcat(Integer dynamicRuleId, List<Integer> protectObjectIds);
|
||||
|
||||
boolean queryProtectObjectById(Integer protectObjectId);
|
||||
}
|
||||
|
||||
@@ -24,14 +24,21 @@ public class DynamicRuleService {
|
||||
|
||||
@Transactional
|
||||
public Integer newDynamicRuleObject(DynamicRuleObject dynamicRule) {
|
||||
|
||||
dynamicRuleMapper.newDynamicRule(dynamicRule);
|
||||
|
||||
Integer dynamicRuleId = dynamicRule.getDynamicRuleId();
|
||||
if (dynamicRule.getProtectObjectIds() != null) {
|
||||
dynamicRule.getProtectObjectIds().forEach(
|
||||
protectObjectId -> dynamicRuleMapper.newDynamicRulProtectObjectConcat(dynamicRuleId, protectObjectId));
|
||||
|
||||
//判断protectObject id是否有效
|
||||
boolean ProtectObjIdValid = dynamicRule.getProtectObjectIds().stream()
|
||||
.allMatch(
|
||||
protectObjectId -> dynamicRuleMapper.queryProtectObjectById(protectObjectId)
|
||||
);
|
||||
if (!ProtectObjIdValid) {
|
||||
throw new IllegalArgumentException("protect object id is invalid");
|
||||
}
|
||||
Integer dynamicRuleId = dynamicRule.getDynamicRuleId();
|
||||
dynamicRule.getProtectObjectIds().forEach(
|
||||
protectObjectId -> dynamicRuleMapper.newDynamicRulProtectObjectConcat(dynamicRuleId, protectObjectId));
|
||||
|
||||
return dynamicRuleId;
|
||||
}
|
||||
|
||||
@@ -77,12 +84,17 @@ public class DynamicRuleService {
|
||||
//查询DynamicRule
|
||||
DynamicRuleObject dynamicRuleObject = dynamicRuleMapper.queryDynamicRuleById(dynamicRuleId);
|
||||
if (dynamicRuleObject == null){
|
||||
return null;
|
||||
throw new IllegalArgumentException("dynamic rule id is invalid");
|
||||
}
|
||||
//查询DynamicRule关联的ProtectObject
|
||||
dynamicRuleObject.setProtectObjects(dynamicRuleMapper.queryProtectObjectByRuleId(dynamicRuleId));
|
||||
//查询DynamicRule关联的template详细信息
|
||||
Template template = dynamicRuleMapper.queryTemplateByRuleId(dynamicRuleId);
|
||||
if (template == null){
|
||||
//template在表中删除了,需要重新设置template(感觉这种情况不多见)
|
||||
dynamicRuleObject.setDynamicRuleSourceSystem("need reset");
|
||||
dynamicRuleObject.setDynamicRuleEventType("need reset");
|
||||
}
|
||||
dynamicRuleObject.setDynamicRuleSourceSystem(template.getSourceSystem());
|
||||
dynamicRuleObject.setDynamicRuleEventType(template.getTemplateName());
|
||||
|
||||
@@ -90,20 +102,28 @@ public class DynamicRuleService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateDynamicRuleObject(Integer dynamicRuleId, DynamicRuleObject dynamicRuleObject) {
|
||||
public boolean updateDynamicRuleObject(Integer dynamicRuleId, DynamicRuleObject dynamicRuleObject) {
|
||||
//更新DynamicRule
|
||||
dynamicRuleObject.setDynamicRuleModifyTime(LocalDateTime.now());
|
||||
dynamicRuleMapper.updateDynamicRuleObject(dynamicRuleId, dynamicRuleObject);
|
||||
if (dynamicRuleObject.getProtectObjectIds() == null || dynamicRuleObject.getProtectObjectIds().isEmpty()) {
|
||||
return;
|
||||
|
||||
Boolean idValid = dynamicRuleMapper.updateDynamicRuleObject(dynamicRuleId, dynamicRuleObject);
|
||||
if (!idValid) {
|
||||
throw new IllegalArgumentException("dynamic rule id is invalid");
|
||||
}
|
||||
//删除DynamicRule关联的ProtectObject
|
||||
dynamicRuleMapper.deleteDynamicRuleProtectObjectConcat(dynamicRuleId);
|
||||
//新增DynamicRule关联的ProtectObject
|
||||
dynamicRuleObject.getProtectObjectIds().forEach(
|
||||
protectObjectId -> dynamicRuleMapper.newDynamicRulProtectObjectConcat(dynamicRuleId, protectObjectId));
|
||||
}
|
||||
boolean ProtectObjIdValid = dynamicRuleObject.getProtectObjectIds().stream()
|
||||
.allMatch(
|
||||
protectObjectId -> dynamicRuleMapper.queryProtectObjectById(protectObjectId)
|
||||
);
|
||||
if (!ProtectObjIdValid) {
|
||||
throw new IllegalArgumentException("protect object id is invalid");
|
||||
}
|
||||
|
||||
return dynamicRuleMapper.newDynamicRulProtectObjectsConcat(dynamicRuleId, dynamicRuleObject.getProtectObjectIds());
|
||||
|
||||
}
|
||||
// 批量删除
|
||||
public Boolean deleteDynamicRuleObjects(List<Integer> dynamicRuleIds) {
|
||||
Function<DynamicRuleMapper, Function<List<Integer>, Boolean>> deleteDynamicRuleFunction =
|
||||
@@ -134,7 +154,10 @@ public class DynamicRuleService {
|
||||
|
||||
|
||||
//分页查询基础的动态规则,暂时不返回关联的保护对象
|
||||
public List<DynamicRuleObject> queryDynamicRuleObject(String dynamicRuleName, Integer dynamicRuleId, Integer page, Integer pageSize) {
|
||||
return dynamicRuleMapper.queryDynamicRuleObject(dynamicRuleName, dynamicRuleId, page, pageSize);
|
||||
public List<DynamicRuleObject> queryDynamicRuleObject(String dynamicRuleName, Integer dynamicRuleId,
|
||||
String templateSourceSystem,String creator,
|
||||
Integer page, Integer pageSize) {
|
||||
return dynamicRuleMapper.queryDynamicRuleObject(dynamicRuleName, dynamicRuleId,
|
||||
templateSourceSystem, creator, page, pageSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,9 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
log.info("新增静态规则: {}", object);
|
||||
//调用service新增
|
||||
staticRuleService.newStaticRuleObject(object);
|
||||
return ResponseResult.ok().setData("static_rule_name", object.getStaticRuleName());
|
||||
return ResponseResult.ok()
|
||||
.setData("static_rule_id", object.getStaticRuleId())
|
||||
.setData("static_rule_name", object.getStaticRuleName());
|
||||
}
|
||||
|
||||
//以Excel方式批量导入静态规则
|
||||
@@ -96,7 +98,10 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
@RequestBody @Valid StaticRuleObject object) {
|
||||
log.info("修改静态规则: {}", object);
|
||||
//调用service修改
|
||||
staticRuleService.updateStaticRule(id, object);
|
||||
Integer updateValid = staticRuleService.updateStaticRule(id, object);
|
||||
if (updateValid == 0) {
|
||||
return ResponseResult.invalid().setMessage("id is invalid");
|
||||
}
|
||||
return ResponseResult.ok();
|
||||
}
|
||||
|
||||
@@ -109,6 +114,9 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
public ResponseResult queryStaticRuleById(@PathVariable Integer id) {
|
||||
log.info("根据id查询静态规则:{}", id);
|
||||
StaticRuleObject object = staticRuleService.queryStaticRuleById(id);
|
||||
if (object == null) {
|
||||
return ResponseResult.invalid().setMessage("id is invalid");
|
||||
}
|
||||
return ResponseResult.ok().setData("static_rule", object);
|
||||
}
|
||||
|
||||
@@ -117,13 +125,18 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/query")
|
||||
public ResponseResult queryStaticRule(String static_rule_name, Integer static_rule_id,
|
||||
public ResponseResult queryStaticRule(@RequestParam(name = "name", required = false) String static_rule_name,
|
||||
@RequestParam(name = "id", required = false) Integer static_rule_id,
|
||||
@RequestParam(name = "creator", required = false) String static_rule_creator,
|
||||
@RequestParam(name = "ip", required = false) String static_rule_ip,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize
|
||||
) {
|
||||
log.info("多查询静态规则: {},{},{},{}", static_rule_name, static_rule_id, page, pageSize);
|
||||
//调用service新增
|
||||
List<StaticRuleObject> pageResult = staticRuleService.queryStaticRule(static_rule_name, static_rule_id, page, pageSize);
|
||||
List<StaticRuleObject> pageResult = staticRuleService.queryStaticRule(
|
||||
static_rule_name, static_rule_id,
|
||||
static_rule_creator, static_rule_ip, page, pageSize);
|
||||
return ResponseResult.ok().setData("static_rule_list", pageResult);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -137,15 +138,21 @@ public interface StaticRuleControllerApi {
|
||||
)
|
||||
},
|
||||
parameters = {
|
||||
@Parameter(name = "static_rule_name", description = "静态规则名称"),
|
||||
@Parameter(name = "static_rule_id", description = "静态规则id"),
|
||||
@Parameter(name = "name", description = "静态规则名称"),
|
||||
@Parameter(name = "id", description = "静态规则id"),
|
||||
@Parameter(name = "creator", description = "静态规则创建人"),
|
||||
@Parameter(name = "ip", description = "静态规则ip,匹配所有源和目的ip"),
|
||||
@Parameter(name = "page", description = "页码"),
|
||||
@Parameter(name = "pageSize", description = "每页条数")
|
||||
}
|
||||
)
|
||||
ResponseResult queryStaticRule(String static_rule_name, Integer static_rule_id,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize);
|
||||
ResponseResult queryStaticRule(@RequestParam(required = false) String static_rule_name,
|
||||
@RequestParam(required = false) Integer static_rule_id,
|
||||
@RequestParam(required = false) String static_rule_creator,
|
||||
@RequestParam(required = false) String static_rule_ip,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize
|
||||
);
|
||||
|
||||
|
||||
@Operation(
|
||||
@@ -166,6 +173,8 @@ public interface StaticRuleControllerApi {
|
||||
)
|
||||
ResponseResult deleteStaticRule(@PathVariable Integer id) ;
|
||||
|
||||
|
||||
|
||||
@Operation(
|
||||
summary = "更新静态规则审批状态",
|
||||
description = "更新静态规则审批状态,0未审核、1审核不通过、2审核通过",
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface StaticRuleMapper {
|
||||
|
||||
|
||||
//修改静态规则
|
||||
void updateStaticRule(@Param("id") Integer id, @Param("object") StaticRuleObject object);
|
||||
Integer updateStaticRule(@Param("id") Integer id, @Param("object") StaticRuleObject object);
|
||||
|
||||
//按id查询静态规则
|
||||
//@Select("select * from t_static_rule where static_rule_id = #{id}")
|
||||
@@ -27,6 +27,7 @@ public interface StaticRuleMapper {
|
||||
|
||||
//多页查询静态规则
|
||||
List<StaticRuleObject> queryStaticRule(String static_rule_name, Integer static_rule_id,
|
||||
String static_rule_create_username, String ip,
|
||||
Integer page, Integer pageSize);
|
||||
|
||||
|
||||
|
||||
@@ -73,12 +73,12 @@ public class StaticRuleService {
|
||||
return sqlSessionWrapper.startBatchSession(StaticRuleMapper.class, deleteStaticRulesFunction, staticRuleIds);
|
||||
}
|
||||
|
||||
public void updateStaticRule(Integer id, StaticRuleObject object) {
|
||||
public Integer updateStaticRule(Integer id, StaticRuleObject object) {
|
||||
//判断当前静态规则是否能够修改---是否存在任务选择的静态规则??
|
||||
//按id查询该静态规则的used_task_id字段,如果不为空,则不能修改
|
||||
object.setStaticRuleModifyTime(LocalDateTime.now());
|
||||
//修改静态规则
|
||||
staticRuleMapper.updateStaticRule(id, object);
|
||||
return staticRuleMapper.updateStaticRule(id, object);
|
||||
}
|
||||
|
||||
public StaticRuleObject queryStaticRuleById(Integer id) {
|
||||
@@ -89,9 +89,13 @@ public class StaticRuleService {
|
||||
/*
|
||||
分页查询
|
||||
*/
|
||||
public List<StaticRuleObject> queryStaticRule(String static_rule_name, Integer static_rule_id, Integer page, Integer pageSize) {
|
||||
public List<StaticRuleObject> queryStaticRule(
|
||||
String static_rule_name, Integer static_rule_id,
|
||||
String creator, String ip,
|
||||
Integer page, Integer pageSize) {
|
||||
|
||||
return staticRuleMapper.queryStaticRule(static_rule_name, static_rule_id, page, pageSize);
|
||||
return staticRuleMapper.queryStaticRule(static_rule_name, static_rule_id,
|
||||
creator, ip, page, pageSize);
|
||||
}
|
||||
|
||||
public Boolean newStaticRuleObjects(List<StaticRuleObject> staticRuleList) {
|
||||
@@ -126,6 +130,9 @@ public class StaticRuleService {
|
||||
@Transactional
|
||||
public Map<String, Object> updateAuditStatus(Integer id, Integer auditStatus) {
|
||||
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?");
|
||||
}
|
||||
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
||||
throw new IllegalArgumentException("invalid audit status");
|
||||
}
|
||||
|
||||
@@ -127,10 +127,13 @@ public class WhiteListController implements WhiteListControllerApi {
|
||||
object.setWhiteListId(id);
|
||||
Integer num = whiteListService.updateWhiteListObject(id, object);
|
||||
if (num == 0) {
|
||||
return new ResponseResult(400, "id is invalid")
|
||||
.setData("whiteobj_list", null);
|
||||
return ResponseResult.invalid("id is invalid")
|
||||
.setData("whiteobj_id", id)
|
||||
.setData("success", false);
|
||||
}
|
||||
return ResponseResult.ok();
|
||||
return ResponseResult.ok()
|
||||
.setData("whiteobj_id", id)
|
||||
.setData("success", true);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -155,15 +158,16 @@ public class WhiteListController implements WhiteListControllerApi {
|
||||
@GetMapping("/{id}/audit/{auditStatus}")
|
||||
public ResponseResult updateWhiteListObjectAuditStatus(@PathVariable Integer id,
|
||||
@PathVariable Integer auditStatus) {
|
||||
if (id <= 0 || auditStatus < 0 || auditStatus > 2) {
|
||||
return new ResponseResult(400, "id or status is invalid")
|
||||
.setData("whiteobj_id", id)
|
||||
.setData("success", false);
|
||||
}
|
||||
// if (id <= 0 || auditStatus < 0 || auditStatus > 2) {
|
||||
// return new ResponseResult(400, "id or status is invalid")
|
||||
// .setData("whiteobj_id", id)
|
||||
// .setData("success", false);
|
||||
// }
|
||||
|
||||
return ResponseResult.ok()
|
||||
.setDataMap(whiteListService.updateWhiteListObjectAuditStatus(id, auditStatus))
|
||||
.setData("whiteobj_id", id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -140,6 +140,9 @@ public class WhiteListService {
|
||||
public Map<String, Object> updateWhiteListObjectAuditStatus(Integer id, Integer auditStatus) {
|
||||
//查询目前curStatus
|
||||
Integer originalAuditStatus = whiteListMapper.queryWhiteListObjectAuditStuatusById(id);
|
||||
if (originalAuditStatus == null){
|
||||
throw new IllegalArgumentException("cannot find audit status of whitelist " + id + ", maybe whitelist doesn't exist?");
|
||||
}
|
||||
//判断是否可以修改
|
||||
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
||||
throw new IllegalArgumentException("invalid audit status");
|
||||
|
||||
Reference in New Issue
Block a user