🔨 数据清理时添加条数限制.
This commit is contained in:
@@ -4,7 +4,9 @@ import com.orion.lang.define.wrapper.IPageRequest;
|
||||
import com.orion.visor.framework.common.validator.group.Page;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
|
||||
/**
|
||||
* 公共页码请求
|
||||
@@ -17,11 +19,13 @@ import org.hibernate.validator.constraints.Range;
|
||||
@Schema(description = "公共页码请求")
|
||||
public class PageRequest implements IPageRequest {
|
||||
|
||||
@Range(min = 1, max = 10000, groups = Page.class)
|
||||
@Min(value = 1, groups = Page.class)
|
||||
@Max(value = 10000, groups = Page.class)
|
||||
@Schema(description = "页码")
|
||||
private int page;
|
||||
|
||||
@Range(min = 1, max = 200, groups = Page.class)
|
||||
@Min(value = 1, groups = Page.class)
|
||||
@Max(value = 200, groups = Page.class)
|
||||
@Schema(description = "大小")
|
||||
private int limit;
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.orion.visor.framework.common.utils;
|
||||
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
|
||||
/**
|
||||
* sql 工具类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/8/26 16:03
|
||||
*/
|
||||
public class SqlUtils {
|
||||
|
||||
private SqlUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* limit n
|
||||
*
|
||||
* @param limit limit
|
||||
* @return limit
|
||||
*/
|
||||
public static String limit(Integer limit) {
|
||||
return Const.LIMIT + Const.SPACE + limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* limit offset limit
|
||||
*
|
||||
* @param offset offset
|
||||
* @param limit limit
|
||||
* @return limit
|
||||
*/
|
||||
public static String limit(int offset, Integer limit) {
|
||||
return Const.LIMIT + Const.SPACE + offset + Const.COMMA + limit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.orion.visor.framework.common.validator.group;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 批量验证分组
|
||||
*
|
||||
@@ -9,5 +7,5 @@ import javax.validation.groups.Default;
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/1 19:13
|
||||
*/
|
||||
public interface Batch extends Default {
|
||||
public interface Batch {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.orion.visor.framework.common.validator.group;
|
||||
|
||||
/**
|
||||
* 清理验证分组
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/1 19:13
|
||||
*/
|
||||
public interface Clear {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.orion.visor.framework.common.validator.group;
|
||||
|
||||
/**
|
||||
* 导出验证分组
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/1 19:13
|
||||
*/
|
||||
public interface Export {
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.orion.visor.framework.common.validator.group;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 分页验证分组
|
||||
*
|
||||
@@ -9,5 +7,5 @@ import javax.validation.groups.Default;
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/1 19:13
|
||||
*/
|
||||
public interface Id extends Default {
|
||||
public interface Id {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.orion.visor.framework.common.validator.group;
|
||||
|
||||
/**
|
||||
* 导出验证分组
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/1 19:13
|
||||
*/
|
||||
public interface Import {
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.orion.visor.framework.common.validator.group;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 分页验证分组
|
||||
*
|
||||
@@ -9,5 +7,5 @@ import javax.validation.groups.Default;
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/1 19:13
|
||||
*/
|
||||
public interface Page extends Default {
|
||||
public interface Page {
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.lang.utils.reflect.Classes;
|
||||
import com.orion.spring.SpringHolder;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.utils.SqlUtils;
|
||||
import com.orion.visor.framework.mybatis.core.domain.BaseDO;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -111,11 +112,11 @@ public class DataQuery<T> {
|
||||
}
|
||||
|
||||
public DataQuery<T> limit(int limit) {
|
||||
return this.last(Const.LIMIT + Const.SPACE + limit);
|
||||
return this.last(SqlUtils.limit(limit));
|
||||
}
|
||||
|
||||
public DataQuery<T> limit(int offset, int limit) {
|
||||
return this.last(Const.LIMIT + Const.SPACE + offset + Const.COMMA + limit);
|
||||
return this.last(SqlUtils.limit(offset, limit));
|
||||
}
|
||||
|
||||
public DataQuery<T> only() {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.orion.visor.module.asset.controller;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.framework.common.validator.group.Clear;
|
||||
import com.orion.visor.framework.common.validator.group.Page;
|
||||
import com.orion.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
@@ -136,7 +137,7 @@ public class ExecCommandLogController {
|
||||
@PostMapping("/clear")
|
||||
@Operation(summary = "清空批量执行日志")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-command-log:management:clear')")
|
||||
public Integer clearExecCommandLog(@RequestBody ExecLogQueryRequest request) {
|
||||
public Integer clearExecCommandLog(@Validated(Clear.class) @RequestBody ExecLogQueryRequest request) {
|
||||
request.setSource(SOURCE);
|
||||
return execLogService.clearExecLog(request);
|
||||
}
|
||||
@@ -178,4 +179,3 @@ public class ExecCommandLogController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.orion.visor.module.asset.controller;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.framework.common.validator.group.Clear;
|
||||
import com.orion.visor.framework.common.validator.group.Page;
|
||||
import com.orion.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
@@ -125,7 +126,7 @@ public class ExecJobLogController {
|
||||
@PostMapping("/clear")
|
||||
@Operation(summary = "清空计划任务日志")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-job-log:management:clear')")
|
||||
public Integer clearExecJobLog(@RequestBody ExecLogQueryRequest request) {
|
||||
public Integer clearExecJobLog(@Validated(Clear.class) @RequestBody ExecLogQueryRequest request) {
|
||||
request.setSource(SOURCE);
|
||||
return execLogService.clearExecLog(request);
|
||||
}
|
||||
@@ -167,4 +168,3 @@ public class ExecJobLogController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.orion.visor.module.asset.controller;
|
||||
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.visor.framework.common.validator.group.Clear;
|
||||
import com.orion.visor.framework.common.validator.group.Id;
|
||||
import com.orion.visor.framework.common.validator.group.Page;
|
||||
import com.orion.visor.framework.log.core.annotation.IgnoreLog;
|
||||
@@ -84,7 +85,7 @@ public class HostConnectLogController {
|
||||
@PostMapping("/clear")
|
||||
@Operation(summary = "清空主机连接日志")
|
||||
@PreAuthorize("@ss.hasPermission('asset:host-connect-log:management:clear')")
|
||||
public Integer clearHostConnectLog(@RequestBody HostConnectLogQueryRequest request) {
|
||||
public Integer clearHostConnectLog(@Validated(Clear.class) @RequestBody HostConnectLogQueryRequest request) {
|
||||
return hostConnectLogService.clearHostConnectLog(request);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.orion.visor.module.asset.controller;
|
||||
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.visor.framework.common.validator.group.Clear;
|
||||
import com.orion.visor.framework.common.validator.group.Page;
|
||||
import com.orion.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
@@ -123,7 +124,7 @@ public class UploadTaskController {
|
||||
@PostMapping("/clear")
|
||||
@Operation(summary = "清空上传任务")
|
||||
@PreAuthorize("@ss.hasPermission('asset:upload-task:management:clear')")
|
||||
public Integer clearUploadTask(@RequestBody UploadTaskQueryRequest request) {
|
||||
public Integer clearUploadTask(@Validated(Clear.class) @RequestBody UploadTaskQueryRequest request) {
|
||||
return uploadTaskService.clearUploadTask(request);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package com.orion.visor.module.asset.entity.request.exec;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.entity.PageRequest;
|
||||
import com.orion.visor.framework.common.validator.group.Clear;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -62,4 +67,16 @@ public class ExecLogQueryRequest extends PageRequest {
|
||||
@Schema(description = "状态")
|
||||
private List<String> statusList;
|
||||
|
||||
@NotNull(groups = Clear.class)
|
||||
@Min(value = 1, groups = Clear.class)
|
||||
@Max(value = 1000, groups = Clear.class)
|
||||
@Schema(description = "清理数量限制")
|
||||
private Integer clearLimit;
|
||||
|
||||
public void setClearLimit(Integer clearLimit) {
|
||||
this.clearLimit = clearLimit;
|
||||
this.setPage(Const.N_1);
|
||||
this.setLimit(clearLimit);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
package com.orion.visor.module.asset.entity.request.host;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.entity.PageRequest;
|
||||
import com.orion.visor.framework.common.validator.group.Clear;
|
||||
import com.orion.visor.framework.common.validator.group.Id;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -24,6 +30,7 @@ import java.util.List;
|
||||
@Schema(name = "HostConnectLogQueryRequest", description = "主机连接日志 查询请求对象")
|
||||
public class HostConnectLogQueryRequest extends PageRequest {
|
||||
|
||||
@NotNull(groups = Id.class)
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@@ -63,4 +70,16 @@ public class HostConnectLogQueryRequest extends PageRequest {
|
||||
@Schema(description = "状态")
|
||||
private List<String> statusList;
|
||||
|
||||
@NotNull(groups = Clear.class)
|
||||
@Min(value = 1, groups = Clear.class)
|
||||
@Max(value = 2000, groups = Clear.class)
|
||||
@Schema(description = "清理数量限制")
|
||||
private Integer clearLimit;
|
||||
|
||||
public void setClearLimit(Integer clearLimit) {
|
||||
this.clearLimit = clearLimit;
|
||||
this.setPage(Const.N_1);
|
||||
this.setLimit(clearLimit);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
@@ -45,7 +46,8 @@ public class HostCreateRequest implements Serializable {
|
||||
@Schema(description = "主机地址")
|
||||
private String address;
|
||||
|
||||
@Range(min = 1, max = 65535)
|
||||
@Min(value = 1)
|
||||
@Max(value = 65535)
|
||||
@Schema(description = "主机端口")
|
||||
private Integer port;
|
||||
|
||||
|
||||
@@ -5,11 +5,8 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@@ -46,7 +43,9 @@ public class HostUpdateRequest implements Serializable {
|
||||
@Schema(description = "主机地址")
|
||||
private String address;
|
||||
|
||||
@Range(min = 1, max = 65535)
|
||||
@NotNull
|
||||
@Min(value = 1)
|
||||
@Max(value = 65535)
|
||||
@Schema(description = "主机端口")
|
||||
private Integer port;
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package com.orion.visor.module.asset.entity.request.upload;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.entity.PageRequest;
|
||||
import com.orion.visor.framework.common.validator.group.Clear;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -44,4 +49,16 @@ public class UploadTaskQueryRequest extends PageRequest {
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date[] createTimeRange;
|
||||
|
||||
@NotNull(groups = Clear.class)
|
||||
@Min(value = 1, groups = Clear.class)
|
||||
@Max(value = 2000, groups = Clear.class)
|
||||
@Schema(description = "清理数量限制")
|
||||
private Integer clearLimit;
|
||||
|
||||
public void setClearLimit(Integer clearLimit) {
|
||||
this.clearLimit = clearLimit;
|
||||
this.setPage(Const.N_1);
|
||||
this.setLimit(clearLimit);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,11 +6,8 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 主机 SSH 配置
|
||||
@@ -64,7 +61,8 @@ public class HostSshConfigModel implements GenericsDataModel, UpdatePasswordActi
|
||||
* 连接超时时间
|
||||
*/
|
||||
@NotNull
|
||||
@Range(min = 0, max = 100000)
|
||||
@Min(value = 1)
|
||||
@Max(value = 100000)
|
||||
private Integer connectTimeout;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.constant.FileConst;
|
||||
import com.orion.visor.framework.common.enums.EndpointDefine;
|
||||
import com.orion.visor.framework.common.file.FileClient;
|
||||
import com.orion.visor.framework.common.utils.SqlUtils;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.framework.redis.core.utils.RedisStrings;
|
||||
import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
||||
@@ -227,7 +228,8 @@ public class ExecLogServiceImpl implements ExecLogService {
|
||||
log.info("ExecLogService.clearExecLog start {}", JSON.toJSONString(request));
|
||||
// 查询
|
||||
LambdaQueryWrapper<ExecLogDO> wrapper = this.buildQueryWrapper(request)
|
||||
.select(ExecLogDO::getId);
|
||||
.select(ExecLogDO::getId)
|
||||
.last(SqlUtils.limit(request.getClearLimit()));
|
||||
List<Long> idList = execLogDAO.selectList(wrapper)
|
||||
.stream()
|
||||
.map(ExecLogDO::getId)
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.utils.SqlUtils;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
||||
import com.orion.visor.module.asset.convert.HostConnectLogConvert;
|
||||
@@ -26,6 +27,7 @@ import com.orion.visor.module.asset.service.HostConnectLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
@@ -167,13 +169,14 @@ public class HostConnectLogServiceImpl implements HostConnectLogService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteHostConnectLog(List<Long> idList) {
|
||||
log.info("HostConnectLogService.deleteHostConnectLog start {}", JSON.toJSONString(idList));
|
||||
if (Lists.isEmpty(idList)) {
|
||||
OperatorLogs.add(OperatorLogs.COUNT, Const.N_0);
|
||||
return Const.N_0;
|
||||
}
|
||||
// 删除
|
||||
// 删除日志表
|
||||
int effect = hostConnectLogDAO.deleteBatchIds(idList);
|
||||
log.info("HostConnectLogService.deleteHostConnectLog finish {}", effect);
|
||||
// 设置日志参数
|
||||
@@ -187,11 +190,13 @@ public class HostConnectLogServiceImpl implements HostConnectLogService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer clearHostConnectLog(HostConnectLogQueryRequest request) {
|
||||
log.info("HostConnectLogService.clearHostConnectLog start {}", JSON.toJSONString(request));
|
||||
// 查询
|
||||
LambdaQueryWrapper<HostConnectLogDO> wrapper = this.buildQueryWrapper(request)
|
||||
.select(HostConnectLogDO::getId);
|
||||
.select(HostConnectLogDO::getId)
|
||||
.last(SqlUtils.limit(request.getClearLimit()));
|
||||
List<HostConnectLogDO> list = hostConnectLogDAO.selectList(wrapper);
|
||||
if (list.isEmpty()) {
|
||||
log.info("HostConnectLogService.clearHostConnectLog empty");
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.enums.EndpointDefine;
|
||||
import com.orion.visor.framework.common.file.FileClient;
|
||||
import com.orion.visor.framework.common.security.LoginUser;
|
||||
import com.orion.visor.framework.common.utils.SqlUtils;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.framework.mybatis.core.query.Conditions;
|
||||
import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
||||
@@ -226,7 +227,8 @@ public class UploadTaskServiceImpl implements UploadTaskService {
|
||||
public Integer clearUploadTask(UploadTaskQueryRequest request) {
|
||||
// 查询id
|
||||
LambdaQueryWrapper<UploadTaskDO> wrapper = this.buildQueryWrapper(request)
|
||||
.select(UploadTaskDO::getId);
|
||||
.select(UploadTaskDO::getId)
|
||||
.last(SqlUtils.limit(request.getClearLimit()));
|
||||
List<Long> idList = uploadTaskDAO.of(wrapper)
|
||||
.list(UploadTaskDO::getId);
|
||||
// 删除
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.orion.visor.module.infra.controller;
|
||||
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.visor.framework.common.validator.group.Clear;
|
||||
import com.orion.visor.framework.common.validator.group.Page;
|
||||
import com.orion.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
@@ -67,7 +68,7 @@ public class OperatorLogController {
|
||||
@PostMapping("/clear")
|
||||
@Operation(summary = "清空操作日志")
|
||||
@PreAuthorize("@ss.hasPermission('infra:operator-log:management:clear')")
|
||||
public Integer clearOperatorLog(@RequestBody OperatorLogQueryRequest request) {
|
||||
public Integer clearOperatorLog(@Validated(Clear.class) @RequestBody OperatorLogQueryRequest request) {
|
||||
return operatorLogService.clearOperatorLog(request);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,9 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
@@ -30,7 +31,8 @@ public class CronNextRequest implements Serializable {
|
||||
private String expression;
|
||||
|
||||
@NotNull
|
||||
@Range(min = 1, max = 100)
|
||||
@Min(value = 1)
|
||||
@Max(value = 100)
|
||||
@Schema(description = "次数")
|
||||
private Integer times;
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package com.orion.visor.module.infra.entity.request.operator;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.entity.PageRequest;
|
||||
import com.orion.visor.framework.common.validator.group.Clear;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -48,4 +53,16 @@ public class OperatorLogQueryRequest extends PageRequest {
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date[] startTimeRange;
|
||||
|
||||
@NotNull(groups = Clear.class)
|
||||
@Min(value = 1, groups = Clear.class)
|
||||
@Max(value = 2000, groups = Clear.class)
|
||||
@Schema(description = "清理数量限制")
|
||||
private Integer clearLimit;
|
||||
|
||||
public void setClearLimit(Integer clearLimit) {
|
||||
this.clearLimit = clearLimit;
|
||||
this.setPage(Const.N_1);
|
||||
this.setLimit(clearLimit);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.orion.lang.utils.Valid;
|
||||
import com.orion.visor.framework.biz.operator.log.core.model.OperatorLogModel;
|
||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.utils.SqlUtils;
|
||||
import com.orion.visor.module.infra.convert.OperatorLogConvert;
|
||||
import com.orion.visor.module.infra.dao.OperatorLogDAO;
|
||||
import com.orion.visor.module.infra.define.operator.AuthenticationOperatorType;
|
||||
@@ -72,8 +73,10 @@ public class OperatorLogServiceImpl implements OperatorLogService {
|
||||
@Override
|
||||
public Integer clearOperatorLog(OperatorLogQueryRequest request) {
|
||||
log.info("OperatorLogService.clearOperatorLog start {}", JSON.toJSONString(request));
|
||||
// 删除
|
||||
// 删除参数
|
||||
LambdaQueryWrapper<OperatorLogDO> wrapper = this.buildQueryWrapper(request);
|
||||
wrapper.last(SqlUtils.limit(request.getClearLimit()));
|
||||
// 删除
|
||||
int effect = operatorLogDAO.delete(wrapper);
|
||||
log.info("OperatorLogService.clearOperatorLog finish {}", effect);
|
||||
// 设置日志参数
|
||||
|
||||
@@ -15,6 +15,7 @@ export interface HostConnectLogQueryRequest extends Pagination {
|
||||
token?: string;
|
||||
status?: string;
|
||||
startTimeRange?: string[];
|
||||
clearLimit?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface ExecLogQueryRequest extends Pagination {
|
||||
command?: string;
|
||||
status?: string;
|
||||
startTimeRange?: string[];
|
||||
clearLimit?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,6 +40,7 @@ export interface UploadTaskQueryRequest extends Pagination {
|
||||
description?: string;
|
||||
status?: string;
|
||||
createTimeRange?: string[];
|
||||
clearLimit?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface OperatorLogQueryRequest extends Pagination {
|
||||
riskLevel?: string;
|
||||
result?: number;
|
||||
startTimeRange?: string[];
|
||||
clearLimit?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -222,7 +222,7 @@
|
||||
// 下载计划任务日志
|
||||
fileGetter = downloadExecJobLogFile(id);
|
||||
}
|
||||
// 瞎子啊
|
||||
// 下载
|
||||
const data = await fileGetter;
|
||||
downloadFile(data);
|
||||
};
|
||||
|
||||
@@ -55,6 +55,15 @@
|
||||
:options="toOptions(connectTypeKey)"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 清理数量 -->
|
||||
<a-form-item field="clearLimit" label="清理数量">
|
||||
<a-input-number v-model="formModel.clearLimit"
|
||||
:min="1"
|
||||
:max="clearLimit"
|
||||
:placeholder="`请输入最大清理数量 最大: ${clearLimit}`"
|
||||
hide-button
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
@@ -71,7 +80,7 @@
|
||||
import { ref } from 'vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import useVisible from '@/hooks/visible';
|
||||
import { connectStatusKey, connectTypeKey } from '../types/const';
|
||||
import { connectStatusKey, connectTypeKey, clearLimit } from '../types/const';
|
||||
import { getHostConnectLogCount, clearHostConnectLog } from '@/api/asset/host-connect-log';
|
||||
import { Message, Modal } from '@arco-design/web-vue';
|
||||
import { useDictStore } from '@/store';
|
||||
@@ -92,6 +101,7 @@
|
||||
type: undefined,
|
||||
status: undefined,
|
||||
startTimeRange: undefined,
|
||||
clearLimit,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -112,6 +122,10 @@
|
||||
|
||||
// 确定
|
||||
const handlerOk = async () => {
|
||||
if (!formModel.value.clearLimit) {
|
||||
Message.error('请输入清理数量');
|
||||
return false;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
// 获取总数量
|
||||
@@ -134,7 +148,7 @@
|
||||
const doClear = (count: number) => {
|
||||
Modal.confirm({
|
||||
title: '删除清空',
|
||||
content: `确定要删除 ${count} 条数据吗? 确定后将立即删除且无法恢复!`,
|
||||
content: `确定要删除 ${Math.min(count, formModel.value.clearLimit || 0)} 条数据吗? 确定后将立即删除且无法恢复!`,
|
||||
onOk: async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
|
||||
@@ -12,6 +12,9 @@ export const HostConnectStatus = {
|
||||
FORCE_OFFLINE: 'FORCE_OFFLINE',
|
||||
};
|
||||
|
||||
// 清理数量
|
||||
export const clearLimit = 2000;
|
||||
|
||||
// 主机连接状态 字典项
|
||||
export const connectStatusKey = 'hostConnectStatus';
|
||||
|
||||
|
||||
@@ -48,6 +48,15 @@
|
||||
:options="toOptions(execStatusKey)"
|
||||
placeholder="请选择执行状态" />
|
||||
</a-form-item>
|
||||
<!-- 清理数量 -->
|
||||
<a-form-item field="clearLimit" label="清理数量">
|
||||
<a-input-number v-model="formModel.clearLimit"
|
||||
:min="1"
|
||||
:max="clearLimit"
|
||||
:placeholder="`请输入最大清理数量 最大: ${clearLimit}`"
|
||||
hide-button
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
@@ -68,6 +77,7 @@
|
||||
import { getExecCommandLogCount, clearExecCommandLog } from '@/api/exec/exec-command-log';
|
||||
import { Message, Modal } from '@arco-design/web-vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import { clearLimit } from '../types/const';
|
||||
import UserSelector from '@/components/user/user/selector/index.vue';
|
||||
|
||||
const emits = defineEmits(['clear']);
|
||||
@@ -86,7 +96,8 @@
|
||||
description: undefined,
|
||||
command: undefined,
|
||||
status: undefined,
|
||||
startTimeRange: undefined
|
||||
startTimeRange: undefined,
|
||||
clearLimit,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -105,6 +116,10 @@
|
||||
|
||||
// 确定
|
||||
const handlerOk = async () => {
|
||||
if (!formModel.value.clearLimit) {
|
||||
Message.error('请输入清理数量');
|
||||
return false;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
// 获取总数量
|
||||
@@ -127,7 +142,7 @@
|
||||
const doClear = (count: number) => {
|
||||
Modal.confirm({
|
||||
title: '删除清空',
|
||||
content: `确定要删除 ${count} 条数据吗? 确定后将立即删除且无法恢复!`,
|
||||
content: `确定要删除 ${Math.min(count, formModel.value.clearLimit || 0)} 条数据吗? 确定后将立即删除且无法恢复!`,
|
||||
onOk: async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
// 清理数量
|
||||
export const clearLimit = 1000;
|
||||
|
||||
@@ -49,6 +49,15 @@
|
||||
placeholder="请选择状态"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 清理数量 -->
|
||||
<a-form-item field="clearLimit" label="清理数量">
|
||||
<a-input-number v-model="formModel.clearLimit"
|
||||
:min="1"
|
||||
:max="clearLimit"
|
||||
:placeholder="`请输入最大清理数量 最大: ${clearLimit}`"
|
||||
hide-button
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
@@ -65,7 +74,7 @@
|
||||
import { ref } from 'vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import useVisible from '@/hooks/visible';
|
||||
import { uploadTaskStatusKey } from '../types/const';
|
||||
import { clearLimit, uploadTaskStatusKey } from '../types/const';
|
||||
import { getUploadTaskCount, clearUploadTask } from '@/api/exec/upload-task';
|
||||
import { Message, Modal } from '@arco-design/web-vue';
|
||||
import { useDictStore } from '@/store';
|
||||
@@ -105,6 +114,10 @@
|
||||
|
||||
// 确定
|
||||
const handlerOk = async () => {
|
||||
if (!formModel.value.clearLimit) {
|
||||
Message.error('请输入清理数量');
|
||||
return false;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
// 获取总数量
|
||||
@@ -127,7 +140,7 @@
|
||||
const doClear = (count: number) => {
|
||||
Modal.confirm({
|
||||
title: '删除清空',
|
||||
content: `确定要删除 ${count} 条数据吗? 确定后将立即删除且无法恢复!`,
|
||||
content: `确定要删除 ${Math.min(count, formModel.value.clearLimit || 0)} 条数据吗? 确定后将立即删除且无法恢复!`,
|
||||
onOk: async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
|
||||
@@ -26,6 +26,9 @@ export const UploadTaskFileStatus = {
|
||||
CANCELED: 'CANCELED',
|
||||
};
|
||||
|
||||
// 清理数量
|
||||
export const clearLimit = 2000;
|
||||
|
||||
// 上传任务状态 字典项
|
||||
export const uploadTaskStatusKey = 'uploadTaskStatus';
|
||||
|
||||
|
||||
@@ -43,6 +43,15 @@
|
||||
:options="toOptions(execStatusKey)"
|
||||
placeholder="请选择执行状态" />
|
||||
</a-form-item>
|
||||
<!-- 清理数量 -->
|
||||
<a-form-item field="clearLimit" label="清理数量">
|
||||
<a-input-number v-model="formModel.clearLimit"
|
||||
:min="1"
|
||||
:max="clearLimit"
|
||||
:placeholder="`请输入最大清理数量 最大: ${clearLimit}`"
|
||||
hide-button
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
@@ -63,6 +72,7 @@
|
||||
import { getExecJobLogCount, clearExecJobLog } from '@/api/job/exec-job-log';
|
||||
import { Message, Modal } from '@arco-design/web-vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import { clearLimit } from '../types/const';
|
||||
import ExecJobSelector from '@/components/exec/job/selector/index.vue';
|
||||
|
||||
const emits = defineEmits(['clear']);
|
||||
@@ -81,7 +91,8 @@
|
||||
description: undefined,
|
||||
command: undefined,
|
||||
status: undefined,
|
||||
startTimeRange: undefined
|
||||
startTimeRange: undefined,
|
||||
clearLimit,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -100,6 +111,10 @@
|
||||
|
||||
// 确定
|
||||
const handlerOk = async () => {
|
||||
if (!formModel.value.clearLimit) {
|
||||
Message.error('请输入清理数量');
|
||||
return false;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
// 获取总数量
|
||||
@@ -122,7 +137,7 @@
|
||||
const doClear = (count: number) => {
|
||||
Modal.confirm({
|
||||
title: '删除清空',
|
||||
content: `确定要删除 ${count} 条数据吗? 确定后将立即删除且无法恢复!`,
|
||||
content: `确定要删除 ${Math.min(count, formModel.value.clearLimit || 0)} 条数据吗? 确定后将立即删除且无法恢复!`,
|
||||
onOk: async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
// 清理数量
|
||||
export const clearLimit = 1000;
|
||||
|
||||
@@ -61,6 +61,15 @@
|
||||
placeholder="请选择执行结果"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 清理数量 -->
|
||||
<a-form-item field="clearLimit" label="清理数量">
|
||||
<a-input-number v-model="formModel.clearLimit"
|
||||
:min="1"
|
||||
:max="clearLimit"
|
||||
:placeholder="`请输入最大清理数量 最大: ${clearLimit}`"
|
||||
hide-button
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
@@ -81,7 +90,7 @@
|
||||
import { getOperatorLogCount, clearOperatorLog } from '@/api/user/operator-log';
|
||||
import { Message, Modal } from '@arco-design/web-vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import { operatorLogModuleKey, operatorLogResultKey, operatorLogTypeKey, operatorRiskLevelKey } from '@/views/user/operator-log/types/const';
|
||||
import { operatorLogModuleKey, operatorLogResultKey, operatorLogTypeKey, operatorRiskLevelKey, clearLimit } from '../types/const';
|
||||
import { labelFilter } from '@/types/form';
|
||||
import UserSelector from '@/components/user/user/selector/index.vue';
|
||||
|
||||
@@ -96,6 +105,7 @@
|
||||
riskLevel: undefined,
|
||||
result: undefined,
|
||||
startTimeRange: undefined,
|
||||
clearLimit,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -136,6 +146,10 @@
|
||||
|
||||
// 确定
|
||||
const handlerOk = async () => {
|
||||
if (!formModel.value.clearLimit) {
|
||||
Message.error('请输入清理数量');
|
||||
return false;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
// 获取总数量
|
||||
@@ -158,7 +172,7 @@
|
||||
const doClear = (count: number) => {
|
||||
Modal.confirm({
|
||||
title: '删除清空',
|
||||
content: `确定要删除 ${count} 条数据吗? 确定后将立即删除且无法恢复!`,
|
||||
content: `确定要删除 ${Math.min(count, formModel.value.clearLimit || 0)} 条数据吗? 确定后将立即删除且无法恢复!`,
|
||||
onOk: async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
|
||||
@@ -27,6 +27,9 @@ export const getLogDetail = (record: OperatorLogQueryResponse): Record<string, a
|
||||
}
|
||||
};
|
||||
|
||||
// 清理数量
|
||||
export const clearLimit = 2000;
|
||||
|
||||
// 操作日志模块 字典项
|
||||
export const operatorLogModuleKey = 'operatorLogModule';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user