✨ 清空操作日志.
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
package com.orion.ops.module.infra.controller;
|
||||
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.ops.framework.common.validator.group.Page;
|
||||
import com.orion.ops.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.ops.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.ops.framework.security.core.utils.SecurityUtils;
|
||||
import com.orion.ops.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.ops.module.infra.define.operator.OperatorLogOperatorType;
|
||||
import com.orion.ops.module.infra.entity.request.operator.OperatorLogQueryRequest;
|
||||
import com.orion.ops.module.infra.entity.vo.LoginHistoryVO;
|
||||
import com.orion.ops.module.infra.entity.vo.OperatorLogVO;
|
||||
import com.orion.ops.module.infra.service.OperatorLogService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -47,6 +49,29 @@ public class OperatorLogController {
|
||||
return operatorLogService.getOperatorLogPage(request);
|
||||
}
|
||||
|
||||
@OperatorLog(OperatorLogOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除操作日志")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:operator-log:delete')")
|
||||
public Integer deleteOperatorLog(@RequestParam("idList") List<Long> idList) {
|
||||
return operatorLogService.deleteOperatorLog(idList);
|
||||
}
|
||||
|
||||
@PostMapping("/query-count")
|
||||
@Operation(summary = "查询操作日志数量")
|
||||
public Long getOperatorLogCount(@RequestBody OperatorLogQueryRequest request) {
|
||||
return operatorLogService.getOperatorLogCount(request);
|
||||
}
|
||||
|
||||
@OperatorLog(OperatorLogOperatorType.CLEAR)
|
||||
@PostMapping("/clear")
|
||||
@Operation(summary = "清空操作日志")
|
||||
@PreAuthorize("@ss.hasPermission('infra:operator-log:clear')")
|
||||
public Integer clearOperatorLog(@RequestBody OperatorLogQueryRequest request) {
|
||||
return operatorLogService.clearOperatorLog(request);
|
||||
}
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@GetMapping("/login-history")
|
||||
@Operation(summary = "查询用户登录日志")
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.orion.ops.module.infra.entity.request.operator.OperatorLogQueryReques
|
||||
import com.orion.ops.module.infra.entity.vo.LoginHistoryVO;
|
||||
import com.orion.ops.module.infra.entity.vo.OperatorLogVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
@@ -24,6 +25,7 @@ public interface OperatorLogConvert {
|
||||
|
||||
OperatorLogDO to(OperatorLogQueryRequest request);
|
||||
|
||||
@Mapping(target = "extra", ignore = true)
|
||||
OperatorLogVO to(OperatorLogDO domain);
|
||||
|
||||
LoginHistoryVO toLoginHistory(OperatorLogDO domain);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.orion.ops.module.infra.define.operator;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.annotation.Module;
|
||||
import com.orion.ops.framework.biz.operator.log.core.factory.InitializingOperatorTypes;
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
|
||||
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.H;
|
||||
|
||||
/**
|
||||
* 操作日志 操作日志类型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024-3-4 16:20
|
||||
*/
|
||||
@Module("infra:operator-log")
|
||||
public class OperatorLogOperatorType extends InitializingOperatorTypes {
|
||||
|
||||
public static final String DELETE = "operator-log:delete";
|
||||
|
||||
public static final String CLEAR = "operator-log:clear";
|
||||
|
||||
@Override
|
||||
public OperatorType[] types() {
|
||||
return new OperatorType[]{
|
||||
new OperatorType(H, DELETE, "删除操作日志 <sb>${count}</sb> 条"),
|
||||
new OperatorType(H, CLEAR, "清空操作日志 <sb>${count}</sb> 条"),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 操作日志 视图响应对象
|
||||
@@ -59,7 +60,7 @@ public class OperatorLogVO implements Serializable {
|
||||
private String logInfo;
|
||||
|
||||
@Schema(description = "参数")
|
||||
private String extra;
|
||||
private Map<String, Object> extra;
|
||||
|
||||
@Schema(description = "操作结果 0失败 1成功")
|
||||
private Integer result;
|
||||
|
||||
@@ -32,6 +32,30 @@ public interface OperatorLogService {
|
||||
*/
|
||||
DataGrid<OperatorLogVO> getOperatorLogPage(OperatorLogQueryRequest request);
|
||||
|
||||
/**
|
||||
* 删除操作日志
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteOperatorLog(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 查询操作日志数量
|
||||
*
|
||||
* @param request request
|
||||
* @return count
|
||||
*/
|
||||
Long getOperatorLogCount(OperatorLogQueryRequest request);
|
||||
|
||||
/**
|
||||
* 清空操作日志
|
||||
*
|
||||
* @param request request
|
||||
* @return effect
|
||||
*/
|
||||
Integer clearOperatorLog(OperatorLogQueryRequest request);
|
||||
|
||||
/**
|
||||
* 查询用户登录日志
|
||||
*
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.orion.ops.module.infra.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.Arrays1;
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorLogModel;
|
||||
import com.orion.ops.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
import com.orion.ops.module.infra.convert.OperatorLogConvert;
|
||||
import com.orion.ops.module.infra.dao.OperatorLogDAO;
|
||||
@@ -48,7 +50,38 @@ public class OperatorLogServiceImpl implements OperatorLogService {
|
||||
// 查询
|
||||
return operatorLogDAO.of(wrapper)
|
||||
.page(request)
|
||||
.dataGrid(OperatorLogConvert.MAPPER::to);
|
||||
.dataGrid(s -> {
|
||||
OperatorLogVO vo = OperatorLogConvert.MAPPER.to(s);
|
||||
vo.setExtra(JSON.parseObject(s.getExtra()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteOperatorLog(List<Long> idList) {
|
||||
log.info("OperatorLogService.deleteOperatorLog start {}", JSON.toJSONString(idList));
|
||||
int effect = operatorLogDAO.deleteBatchIds(idList);
|
||||
log.info("OperatorLogService.deleteOperatorLog finish {}", effect);
|
||||
// 设置日志参数
|
||||
OperatorLogs.add(OperatorLogs.COUNT, effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getOperatorLogCount(OperatorLogQueryRequest request) {
|
||||
return operatorLogDAO.selectCount(this.buildQueryWrapper(request));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer clearOperatorLog(OperatorLogQueryRequest request) {
|
||||
log.info("OperatorLogService.clearOperatorLog start {}", JSON.toJSONString(request));
|
||||
// 删除
|
||||
LambdaQueryWrapper<OperatorLogDO> wrapper = this.buildQueryWrapper(request);
|
||||
int effect = operatorLogDAO.delete(wrapper);
|
||||
log.info("OperatorLogService.clearOperatorLog finish {}", effect);
|
||||
// 设置日志参数
|
||||
OperatorLogs.add(OperatorLogs.COUNT, effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user