fix:任务及文件操作日志记录&文件Tag传参改造
This commit is contained in:
@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.sdm.common.entity.req.data.TagReq;
|
||||
import com.sdm.common.entity.resp.BaseResp;
|
||||
import com.sdm.common.entity.resp.project.SimulationRunResp;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -147,6 +148,10 @@ public class FileMetadataInfoResp extends BaseResp implements Serializable {
|
||||
|
||||
private String taskId;
|
||||
|
||||
private String runId;
|
||||
|
||||
private TagReq tagReq;
|
||||
|
||||
@Schema(description= "流程模板id")
|
||||
private String flowTemplate;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@@ -33,4 +34,20 @@ public class SysLogFeignClientImpl implements ISysLogFeignClient {
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse batchSaveLog(List<SysLogDTO> req) {
|
||||
SdmResponse response=null ;
|
||||
try {
|
||||
response = sysLogFeignClient.batchSaveLog(req);
|
||||
if(response==null || !response.isSuccess()){
|
||||
log.error("batchSaveLog failed response:{}", JSONObject.toJSONString(Optional.ofNullable(response)));
|
||||
return SdmResponse.failed("批量记录日志失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("batchSaveLog error response:{}", JSONObject.toJSONString(Optional.ofNullable(response)));
|
||||
return SdmResponse.failed("批量记录日志异常");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,15 @@ import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@FeignClient(name = "system",contextId = "systemLogClient")
|
||||
public interface ISysLogFeignClient {
|
||||
|
||||
@PostMapping("/systemLog/saveLog")
|
||||
SdmResponse saveLog(@RequestBody SysLogDTO req);
|
||||
|
||||
@PostMapping("/systemLog/batchSaveLog")
|
||||
SdmResponse batchSaveLog(@RequestBody List<SysLogDTO> req);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,26 @@ public @interface SysLog {
|
||||
*/
|
||||
String value() default "";
|
||||
|
||||
/**
|
||||
* 所属模块 如任务/流程
|
||||
*/
|
||||
String module() default "";
|
||||
|
||||
/**
|
||||
* 操作类型 如增删改
|
||||
*/
|
||||
String operateType() default "";
|
||||
|
||||
/**
|
||||
* 业务id 如任务的taskId
|
||||
*/
|
||||
String businessId() default "";
|
||||
|
||||
/**
|
||||
* 业务涉及文件id
|
||||
*/
|
||||
String fileId() default "";
|
||||
|
||||
/**
|
||||
* spel 表达式
|
||||
* @return 日志描述
|
||||
|
||||
@@ -49,15 +49,25 @@ public class SysLogAspect {
|
||||
String strMethodName = point.getSignature().getName();
|
||||
log.debug("[类名]:{},[方法]:{}", strClassName, strMethodName);
|
||||
|
||||
String value = sysLog.value();
|
||||
// 日志描述
|
||||
String title = sysLog.value();
|
||||
// 所属模块
|
||||
String module = sysLog.module();
|
||||
// 操作类型
|
||||
String operateType = sysLog.operateType();
|
||||
// 业务id
|
||||
String businessId = sysLog.businessId();
|
||||
|
||||
SysLogDTO logVo = SysLogUtils.getSysLog();
|
||||
logVo.setTitle(value);
|
||||
// 获取请求body参数
|
||||
logVo.setTitle(title);
|
||||
logVo.setModule(module);
|
||||
logVo.setOperateType(operateType);
|
||||
logVo.setBusinessId(businessId);
|
||||
|
||||
if (StrUtil.isBlank(logVo.getParams())) {
|
||||
logVo.setBody(point.getArgs());
|
||||
}
|
||||
// 发送异步日志事件
|
||||
|
||||
Long startTime = System.currentTimeMillis();
|
||||
Object obj;
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.sdm.common.log.constants;
|
||||
|
||||
public class ModuleConstants {
|
||||
|
||||
public static final String TASK = "task";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.sdm.common.log.constants;
|
||||
|
||||
public class OperateTypeConstants {
|
||||
|
||||
public static final String UPDATE = "update";
|
||||
public static final String ADD = "add";
|
||||
public static final String DELETE = "delete";
|
||||
|
||||
public static final String UPLOAD = "upload";
|
||||
public static final String DOWNLOAD = "download";
|
||||
public static final String PREVIEW = "preview";
|
||||
|
||||
}
|
||||
@@ -51,26 +51,11 @@ public class SysLogDTO {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 操作IP地址
|
||||
*/
|
||||
private String remoteAddr;
|
||||
|
||||
/**
|
||||
* 用户代理
|
||||
*/
|
||||
private String userAgent;
|
||||
|
||||
/**
|
||||
* 请求URI
|
||||
*/
|
||||
private String requestUri;
|
||||
|
||||
/**
|
||||
* 操作方式
|
||||
*/
|
||||
private String method;
|
||||
|
||||
/**
|
||||
* 操作提交的数据
|
||||
*/
|
||||
@@ -107,4 +92,13 @@ public class SysLogDTO {
|
||||
@Schema(description = "每页显示数量")
|
||||
private Integer size;
|
||||
|
||||
// 所属模块
|
||||
private String module;
|
||||
// 操作类型
|
||||
private String operateType;
|
||||
// 业务id
|
||||
private String businessId;
|
||||
// 文件id
|
||||
private Long fileId;
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ser.FilterProvider;
|
||||
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
|
||||
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
|
||||
import com.sdm.common.feign.impl.system.SysLogFeignClientImpl;
|
||||
import com.sdm.common.feign.inter.system.ISysLogFeignClient;
|
||||
import com.sdm.common.log.config.SysLogProperties;
|
||||
import com.sdm.common.log.dto.SysLogDTO;
|
||||
@@ -61,7 +62,7 @@ public class SysLogListener implements InitializingBean {
|
||||
*/
|
||||
private final static ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
private final ISysLogFeignClient sysLogFeignClient;
|
||||
private final SysLogFeignClientImpl sysLogFeignClient;
|
||||
|
||||
private final SysLogProperties logProperties;
|
||||
|
||||
|
||||
@@ -44,24 +44,17 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 系统日志工具类
|
||||
*
|
||||
* @author L.cm
|
||||
*/
|
||||
|
||||
@UtilityClass
|
||||
@Slf4j
|
||||
public class SysLogUtils {
|
||||
|
||||
public SysLogDTO getSysLog() {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) Objects
|
||||
.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||
.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||
SysLogDTO sysLog = new SysLogDTO();
|
||||
sysLog.setLogType(LogTypeEnum.NORMAL.getType());
|
||||
sysLog.setRequestUri(URLUtil.getPath(request.getRequestURI()));
|
||||
sysLog.setMethod(request.getMethod());
|
||||
sysLog.setRemoteAddr(JakartaServletUtil.getClientIP(request));
|
||||
sysLog.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT));
|
||||
sysLog.setCreateBy(String.valueOf(ThreadLocalContext.getUserId()));
|
||||
try {
|
||||
// 获取服务名称
|
||||
|
||||
Reference in New Issue
Block a user