1。流程报告生成优化
2.登录认证优化
This commit is contained in:
6
.idea/sqldialects.xml
generated
Normal file
6
.idea/sqldialects.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/sql/spdmbaseline/base.sql" dialect="GenericSQL" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -112,6 +112,11 @@ public Result<TaskVO> getTask(@PathVariable @Min(1) Long taskId) {
|
||||
5.**controller层返回值指定具体类型,禁止直接用JSONObject**
|
||||
|
||||
|
||||
```angular2html
|
||||
repomix --include "**/src/main/java/**/*.java,**/src/main/resources/**/*.yml,**/pom.xml" --style xml
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,46 +1,25 @@
|
||||
package com.sdm.approve.filter;
|
||||
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
//import com.sdm.approve.service.UserService;
|
||||
import jakarta.servlet.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import com.sdm.common.filter.BaseAuthFilter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
public class AuthFilter implements Filter {
|
||||
// @Resource
|
||||
// private UserService userService;
|
||||
public class AuthFilter extends BaseAuthFilter {
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
Filter.super.init(filterConfig);
|
||||
log.info("----------- AuthFilter init ----------");
|
||||
protected boolean shouldCheckWhitelist() {
|
||||
return false; // approve模块不使用白名单
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
if (servletRequest instanceof HttpServletRequest) {
|
||||
HttpServletRequest req = (HttpServletRequest) servletRequest;
|
||||
if(!ThreadLocalContext.verifyRequest(req))
|
||||
{
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // 401
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"code\":401,\"message\":\"未登录或认证信息缺失\"}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
Filter.super.destroy();
|
||||
log.info("----------- AuthFilter destroy ----------");
|
||||
super.doFilter(servletRequest, servletResponse, filterChain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +1,19 @@
|
||||
package com.sdm.capability.filter;
|
||||
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
//import com.sdm.ability.service.UserService;
|
||||
import com.sdm.common.config.WhitelistProperties;
|
||||
import jakarta.servlet.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import com.sdm.common.filter.BaseAuthFilter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class AuthFilter implements Filter {
|
||||
@Autowired
|
||||
private WhitelistProperties whitelistProperties;
|
||||
|
||||
private List<String> excludedPaths;
|
||||
private final AntPathMatcher pathMatcher = new AntPathMatcher();
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
Filter.super.init(filterConfig);
|
||||
// 从初始化参数中读取白名单
|
||||
excludedPaths = whitelistProperties.getPaths();
|
||||
log.info("----------- AuthFilter init ----------");
|
||||
}
|
||||
public class AuthFilter extends BaseAuthFilter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
if (servletRequest instanceof HttpServletRequest) {
|
||||
HttpServletRequest req = (HttpServletRequest) servletRequest;
|
||||
String path = req.getRequestURI().substring(req.getContextPath().length());
|
||||
// 检查当前请求是否在白名单中
|
||||
for (String excludedPath : excludedPaths) {
|
||||
if (pathMatcher.match(excludedPath, path)) {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!ThreadLocalContext.verifyRequest(req))
|
||||
{
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // 401
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"code\":401,\"message\":\"未登录或认证信息缺失\"}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
@Override
|
||||
public void destroy() {
|
||||
Filter.super.destroy();
|
||||
log.info("----------- AuthFilter destroy ----------");
|
||||
super.doFilter(servletRequest, servletResponse, filterChain);
|
||||
}
|
||||
}
|
||||
|
||||
19766
common/repomix-output.xml
Normal file
19766
common/repomix-output.xml
Normal file
File diff suppressed because it is too large
Load Diff
118
common/src/main/java/com/sdm/common/filter/BaseAuthFilter.java
Normal file
118
common/src/main/java/com/sdm/common/filter/BaseAuthFilter.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package com.sdm.common.filter;
|
||||
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.config.WhitelistProperties;
|
||||
import jakarta.servlet.Filter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.FilterConfig;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public abstract class BaseAuthFilter implements Filter {
|
||||
|
||||
@Autowired
|
||||
protected WhitelistProperties whitelistProperties;
|
||||
|
||||
protected List<String> excludedPaths;
|
||||
protected final AntPathMatcher pathMatcher = new AntPathMatcher();
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
Filter.super.init(filterConfig);
|
||||
// 从初始化参数中读取白名单
|
||||
if (whitelistProperties != null) {
|
||||
excludedPaths = whitelistProperties.getPaths();
|
||||
}
|
||||
log.info("----------- BaseAuthFilter init ----------");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
if (servletRequest instanceof HttpServletRequest) {
|
||||
HttpServletRequest req = (HttpServletRequest) servletRequest;
|
||||
|
||||
|
||||
// 1尝试从Header中加载用户信息到ThreadLocal (无论是否在白名单,都尝试加载)
|
||||
boolean hasContext = ThreadLocalContext.verifyRequest(req);
|
||||
|
||||
// 检查是否在白名单中(如果子类需要此功能)
|
||||
if (shouldCheckWhitelist() && isWhitelisted(req)) {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
|
||||
// 执行认证检查
|
||||
if (!shouldSkipAuthentication(req) && !hasContext) {
|
||||
handleUnauthenticatedRequest(servletResponse);
|
||||
return;
|
||||
}
|
||||
|
||||
// 允许子类添加额外的处理逻辑
|
||||
processAuthenticatedRequest(req, servletResponse);
|
||||
}
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否应该跳过认证检查
|
||||
* 子类可以覆盖此方法来实现特定逻辑
|
||||
*/
|
||||
protected boolean shouldSkipAuthentication(HttpServletRequest request) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否应该检查白名单
|
||||
* 子类可以覆盖此方法来控制是否启用白名单功能
|
||||
*/
|
||||
protected boolean shouldCheckWhitelist() {
|
||||
return excludedPaths != null && !excludedPaths.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查请求路径是否在白名单中
|
||||
*/
|
||||
protected boolean isWhitelisted(HttpServletRequest request) {
|
||||
String path = request.getRequestURI().substring(request.getContextPath().length());
|
||||
for (String excludedPath : excludedPaths) {
|
||||
if (pathMatcher.match(excludedPath, path)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理未认证的请求
|
||||
*/
|
||||
protected void handleUnauthenticatedRequest(ServletResponse servletResponse) throws IOException {
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // 401
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"code\":401,\"message\":\"未登录或认证信息缺失\"}");
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理已认证的请求
|
||||
* 子类可以覆盖此方法来添加额外的处理逻辑
|
||||
*/
|
||||
protected void processAuthenticatedRequest(HttpServletRequest request, ServletResponse servletResponse) throws IOException, ServletException {
|
||||
// 默认不执行任何操作,供子类重写
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
Filter.super.destroy();
|
||||
log.info("----------- BaseAuthFilter destroy ----------");
|
||||
}
|
||||
}
|
||||
17372
data/repomix-output.xml
Normal file
17372
data/repomix-output.xml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,60 +1,19 @@
|
||||
package com.sdm.data.filter;
|
||||
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.config.WhitelistProperties;
|
||||
import jakarta.servlet.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import com.sdm.common.filter.BaseAuthFilter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class AuthFilter implements Filter {
|
||||
@Autowired
|
||||
private WhitelistProperties whitelistProperties;
|
||||
|
||||
private List<String> excludedPaths;
|
||||
private final AntPathMatcher pathMatcher = new AntPathMatcher();
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
Filter.super.init(filterConfig);
|
||||
// 从初始化参数中读取白名单
|
||||
excludedPaths = whitelistProperties.getPaths();
|
||||
log.info("----------- AuthFilter init ----------");
|
||||
}
|
||||
public class AuthFilter extends BaseAuthFilter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
if (servletRequest instanceof HttpServletRequest) {
|
||||
HttpServletRequest req = (HttpServletRequest) servletRequest;
|
||||
String path = req.getRequestURI().substring(req.getContextPath().length());
|
||||
// 检查当前请求是否在白名单中
|
||||
for (String excludedPath : excludedPaths) {
|
||||
if (pathMatcher.match(excludedPath, path)) {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!ThreadLocalContext.verifyRequest(req))
|
||||
{
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // 401
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"code\":401,\"message\":\"未登录或认证信息缺失\"}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
Filter.super.destroy();
|
||||
log.info("----------- AuthFilter destroy ----------");
|
||||
super.doFilter(servletRequest, servletResponse, filterChain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,10 @@ public class UpdateFileReq {
|
||||
@Schema(description = "关联项目id")
|
||||
private String projectId;
|
||||
|
||||
// 原有的字段暂时保留或改名
|
||||
@Schema(description = "关联工况库信息(JSON字符串)")
|
||||
private String simulationPoolInfoListStr;
|
||||
|
||||
@Schema(description = "关联工况库信息")
|
||||
private List<SimulationPoolInfo> simulationPoolInfoList;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.sdm.data.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -1323,7 +1324,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
}
|
||||
|
||||
|
||||
String originalName = req.getFileName();
|
||||
String originalName = ObjectUtils.isNotEmpty(req.getFileName())?req.getFileName():req.getFile().getOriginalFilename();
|
||||
String versionSuffix = "_V1";
|
||||
String modifiedFileName;
|
||||
|
||||
@@ -1347,7 +1348,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
minioService.uploadFile(req.getFile(), fileMinioObjectKey, null);
|
||||
|
||||
// 创建目录元数据并保存到数据库
|
||||
FileMetadataInfo fileInfo = createFileMetadata(fileMinioObjectKey, req.getFileName(), req.getFileType(),
|
||||
FileMetadataInfo fileInfo = createFileMetadata(fileMinioObjectKey, originalName, req.getFileType(),
|
||||
req.getProjectId(), req.getAnalysisDirectionId(), req.getRemarks(), dirMetadataInfo.getId(), req.getFile().getSize()
|
||||
);
|
||||
// 只有知识库的文件需要审核
|
||||
@@ -1520,6 +1521,15 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@PermissionCheckAspect.FilePermissionCheck(value = FilePermissionEnum.UPLOAD, fileIdExpression = "#req.id")
|
||||
public SdmResponse updateFile(UpdateFileReq req) {
|
||||
if (StringUtils.hasText(req.getSimulationPoolInfoListStr())) {
|
||||
try {
|
||||
List<SimulationPoolInfo> list = JSON.parseArray(req.getSimulationPoolInfoListStr(), SimulationPoolInfo.class);
|
||||
req.setSimulationPoolInfoList(list);
|
||||
} catch (Exception e) {
|
||||
return SdmResponse.failed("参数格式错误");
|
||||
}
|
||||
}
|
||||
|
||||
FileMetadataInfo fileMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getId, req.getId()).one();
|
||||
if (fileMetadataInfo == null) {
|
||||
return SdmResponse.failed("文件不存在");
|
||||
|
||||
@@ -126,6 +126,7 @@ security:
|
||||
- /data/flowableUpFileToLocal
|
||||
- /data/flowableUpFileToLocalMerge
|
||||
- /data/getFileBaseInfo
|
||||
- /data/uploadFiles
|
||||
|
||||
data:
|
||||
storage-monitor:
|
||||
|
||||
@@ -131,6 +131,7 @@ security:
|
||||
- /data/flowableUpFileToLocal
|
||||
- /data/flowableUpFileToLocalMerge
|
||||
- /data/getFileBaseInfo
|
||||
- /data/uploadFiles
|
||||
|
||||
data:
|
||||
storage-monitor:
|
||||
|
||||
@@ -126,6 +126,7 @@ security:
|
||||
- /data/flowableUpFileToLocal
|
||||
- /data/flowableUpFileToLocalMerge
|
||||
- /data/getFileBaseInfo
|
||||
- /data/uploadFiles
|
||||
|
||||
data:
|
||||
storage-monitor:
|
||||
|
||||
4251
flowable/repomix-output.xml
Normal file
4251
flowable/repomix-output.xml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@ package com.sdm.flowable.delegate.handler;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.flowable.executeConfig.ExportWordScriptExecuteConfig;
|
||||
import com.sdm.common.entity.req.data.GetFileBaseInfoReq;
|
||||
import com.sdm.common.entity.req.data.UploadFilesReq;
|
||||
@@ -61,8 +62,14 @@ public class ExportWordScriptHandler implements ExecutionHandler<Map<String, Obj
|
||||
|
||||
// 获取当前流程实例参数
|
||||
String runId = (String) execution.getVariable("runId");
|
||||
Long userId = (Long) execution.getVariable("userId");
|
||||
String userName = (String) execution.getVariable("userName");
|
||||
Long tenantId = (Long) execution.getVariable("tenantId");
|
||||
ThreadLocalContext.setUserId(userId);
|
||||
ThreadLocalContext.setUserName(userName);
|
||||
ThreadLocalContext.setTenantId(tenantId);
|
||||
String processDefinitionId = execution.getProcessDefinitionId();
|
||||
log.info("ExportWordScriptHandler 开始执行 runId:{},processDefinitionId:{}, beforeNodeId:{}, currentNodeId:{},fileRegularStr:{}", runId,processDefinitionId, beforeNodeId, currentNodeId,fileRegularStr);
|
||||
log.info("ExportWordScriptHandler 开始执行 runId:{},userId:{},userName:{},tenantId:{},processDefinitionId:{}, beforeNodeId:{}, currentNodeId:{},fileRegularStr:{}", runId,userId,userName,tenantId,processDefinitionId, beforeNodeId, currentNodeId,fileRegularStr);
|
||||
|
||||
ProjecInfoReq projecInfoReq = buildprojectInfoReq(params);
|
||||
log.info("ExportWordScriptHandler的请求参数 projectInfoReq:{}", projecInfoReq);
|
||||
@@ -187,7 +194,11 @@ public class ExportWordScriptHandler implements ExecutionHandler<Map<String, Obj
|
||||
log.info("上传文件参数:{}", req);
|
||||
// 调用上传文件的方法
|
||||
// 注意:这里应该处理返回值
|
||||
dataFeignClient.uploadFiles(req);
|
||||
SdmResponse sdmResponse = dataFeignClient.uploadFiles(req);
|
||||
if (!sdmResponse.isSuccess()) {
|
||||
log.error("上传文件失败: {}", sdmResponse.getMessage());
|
||||
throw new RuntimeException("上传文件失败:");
|
||||
}
|
||||
log.info("结果文件已上传到MinIO: {}", resultFilePath);
|
||||
} catch (Exception e) {
|
||||
log.error("上传结果文件到MinIO失败: {}", resultFilePath, e);
|
||||
|
||||
@@ -1,60 +1,19 @@
|
||||
package com.sdm.pbs.filter;
|
||||
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.config.WhitelistProperties;
|
||||
import jakarta.servlet.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import com.sdm.common.filter.BaseAuthFilter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class AuthFilter implements Filter {
|
||||
|
||||
@Autowired
|
||||
private WhitelistProperties whitelistProperties;
|
||||
private List<String> excludedPaths;
|
||||
private final AntPathMatcher pathMatcher = new AntPathMatcher();
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
Filter.super.init(filterConfig);
|
||||
// 从初始化参数中读取白名单
|
||||
excludedPaths = whitelistProperties.getPaths();
|
||||
log.info("----------- AuthFilter init ----------");
|
||||
}
|
||||
public class AuthFilter extends BaseAuthFilter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
if (servletRequest instanceof HttpServletRequest) {
|
||||
HttpServletRequest req = (HttpServletRequest) servletRequest;
|
||||
String path = req.getRequestURI().substring(req.getContextPath().length());
|
||||
// 检查当前请求是否在白名单中
|
||||
for (String excludedPath : excludedPaths) {
|
||||
if (pathMatcher.match(excludedPath, path)) {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!ThreadLocalContext.verifyRequest(req))
|
||||
{
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // 401
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"code\":401,\"message\":\"未登录或认证信息缺失\"}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
Filter.super.destroy();
|
||||
log.info("----------- AuthFilter destroy ----------");
|
||||
super.doFilter(servletRequest, servletResponse, filterChain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,25 @@
|
||||
package com.sdm.performance.filter;
|
||||
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
//import com.sdm.performance.service.UserService;
|
||||
import jakarta.servlet.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import com.sdm.common.filter.BaseAuthFilter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
public class AuthFilter implements Filter {
|
||||
// @Resource
|
||||
// private UserService userService;
|
||||
public class AuthFilter extends BaseAuthFilter {
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
Filter.super.init(filterConfig);
|
||||
log.info("----------- AuthFilter init ----------");
|
||||
protected boolean shouldCheckWhitelist() {
|
||||
return false; // performance模块不使用白名单
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
if (servletRequest instanceof HttpServletRequest) {
|
||||
HttpServletRequest req = (HttpServletRequest) servletRequest;
|
||||
if(!ThreadLocalContext.verifyRequest(req))
|
||||
{
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // 401
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"code\":401,\"message\":\"未登录或认证信息缺失\"}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
Filter.super.destroy();
|
||||
log.info("----------- AuthFilter destroy ----------");
|
||||
super.doFilter(servletRequest, servletResponse, filterChain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +1,19 @@
|
||||
package com.sdm.project.filter;
|
||||
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.config.WhitelistProperties;
|
||||
import jakarta.servlet.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import com.sdm.common.filter.BaseAuthFilter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class AuthFilter implements Filter {
|
||||
@Autowired
|
||||
private WhitelistProperties whitelistProperties;
|
||||
|
||||
private List<String> excludedPaths;
|
||||
private final AntPathMatcher pathMatcher = new AntPathMatcher();
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
Filter.super.init(filterConfig);
|
||||
// 从初始化参数中读取白名单
|
||||
excludedPaths = whitelistProperties.getPaths();
|
||||
log.info("----------- AuthFilter init ----------");
|
||||
}
|
||||
public class AuthFilter extends BaseAuthFilter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
if (servletRequest instanceof HttpServletRequest) {
|
||||
HttpServletRequest req = (HttpServletRequest) servletRequest;
|
||||
String path = req.getRequestURI().substring(req.getContextPath().length());
|
||||
// 检查当前请求是否在白名单中
|
||||
for (String excludedPath : excludedPaths) {
|
||||
if (pathMatcher.match(excludedPath, path)) {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!ThreadLocalContext.verifyRequest(req))
|
||||
{
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // 401
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"code\":401,\"message\":\"未登录或认证信息缺失\"}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
Filter.super.destroy();
|
||||
log.info("----------- AuthFilter destroy ----------");
|
||||
super.doFilter(servletRequest, servletResponse, filterChain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1391,6 +1391,9 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
SimulationRun simulationRun = this.lambdaQuery().eq(SimulationRun::getUuid,runId ).one();
|
||||
Map<String, Object> variables = new HashMap<>();
|
||||
variables.put("runId", runId);
|
||||
variables.put("userId",ThreadLocalContext.getUserId());
|
||||
variables.put("userName", ThreadLocalContext.getUserName());
|
||||
variables.put("tenantId", ThreadLocalContext.getTenantId());
|
||||
// 启动流程实例 多次执行会生成多个流程实例id,更新算例run表、同时更新flowable流程参数的流程实例id
|
||||
SdmResponse<ProcessInstanceResp> sdmResponse = flowableFeignClient.startByProcessDefinitionId(simulationRun.getProcessDefinitionId(), variables);
|
||||
if (sdmResponse.getData() != null) {
|
||||
|
||||
37
sql/flowable/base
Normal file
37
sql/flowable/base
Normal file
@@ -0,0 +1,37 @@
|
||||
CREATE DATABASE `flowable` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
|
||||
|
||||
|
||||
-- flowable.async_task_record definition
|
||||
|
||||
CREATE TABLE `async_task_record` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID,自增',
|
||||
`async_task_id` varchar(64) NOT NULL COMMENT '异步任务唯一标识,全局唯一,用于定位单个异步任务',
|
||||
`process_instance_id` varchar(64) DEFAULT NULL COMMENT '流程实例ID,关联工作流引擎的流程实例(如Camunda的processInstanceId)',
|
||||
`execution_id` varchar(64) DEFAULT NULL COMMENT '流程执行ID,关联工作流引擎的执行实例(如Camunda的executionId)',
|
||||
`receive_task_id` varchar(64) DEFAULT NULL COMMENT '接收任务ID,关联工作流中接收任务节点的ID(用于异步回调触发流程继续)',
|
||||
`handler_type` varchar(64) DEFAULT NULL COMMENT '业务处理器类型,标识任务对应的业务处理逻辑,例如:HPC(高性能计算)/OCR(图文识别)/AI(智能分析)',
|
||||
`request_json` text COMMENT '任务请求参数,JSON格式字符串,存储触发异步任务时的入参信息',
|
||||
`result_json` text COMMENT '任务执行结果,JSON格式字符串,存储异步任务完成后的返回数据(成功/失败均记录)',
|
||||
`status` varchar(32) DEFAULT 'INIT' COMMENT '任务状态:INIT(初始化)/RUNNING(执行中)/SUCCESS(执行成功)/FAIL(执行失败)',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '任务创建时间,默认当前时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '任务更新时间,数据变更时自动更新为当前时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `async_task_id` (`async_task_id`),
|
||||
KEY `idx_async_task_id` (`async_task_id`) COMMENT '异步任务ID索引,加速任务唯一标识的查询'
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='异步任务执行记录表';
|
||||
|
||||
|
||||
-- flowable.process_node_param definition
|
||||
|
||||
CREATE TABLE `process_node_param` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`processDefinitionId` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '流程定义ID',
|
||||
`processInstanceId` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '流程实例ID',
|
||||
`nodeId` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '节点ID',
|
||||
`runId` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '流程绑定的算例uuid',
|
||||
`paramJson` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '输入参数JSON',
|
||||
`createTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updateTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_processInstanceId_nodeId` (`runId`,`processDefinitionId`,`processInstanceId`,`nodeId`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=81 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='流程节点输入参数表';
|
||||
1406
sql/spdmbaseline/base.sql
Normal file
1406
sql/spdmbaseline/base.sql
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,61 +1,21 @@
|
||||
package com.sdm.system.filter;
|
||||
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.config.WhitelistProperties;
|
||||
import jakarta.servlet.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import com.sdm.common.filter.BaseAuthFilter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class AuthFilter implements Filter {
|
||||
@Autowired
|
||||
private WhitelistProperties whitelistProperties;
|
||||
|
||||
private List<String> excludedPaths;
|
||||
private final AntPathMatcher pathMatcher = new AntPathMatcher();
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
Filter.super.init(filterConfig);
|
||||
// 从初始化参数中读取白名单
|
||||
excludedPaths = whitelistProperties.getPaths();
|
||||
log.info("----------- AuthFilter init ----------");
|
||||
}
|
||||
public class AuthFilter extends BaseAuthFilter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
if (servletRequest instanceof HttpServletRequest) {
|
||||
HttpServletRequest req = (HttpServletRequest) servletRequest;
|
||||
String path = req.getRequestURI().substring(req.getContextPath().length());
|
||||
// 检查当前请求是否在白名单中
|
||||
for (String excludedPath : excludedPaths) {
|
||||
if (pathMatcher.match(excludedPath, path)) {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!ThreadLocalContext.verifyRequest(req))
|
||||
{
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // 401
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"code\":401,\"message\":\"未登录或认证信息缺失\"}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
Filter.super.destroy();
|
||||
log.info("----------- AuthFilter destroy ----------");
|
||||
super.doFilter(servletRequest, servletResponse, filterChain);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,62 +1,19 @@
|
||||
package com.sdm.task.filter;
|
||||
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.config.WhitelistProperties;
|
||||
import jakarta.servlet.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import com.sdm.common.filter.BaseAuthFilter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class AuthFilter implements Filter {
|
||||
|
||||
@Autowired
|
||||
private WhitelistProperties whitelistProperties;
|
||||
|
||||
private List<String> excludedPaths;
|
||||
private final AntPathMatcher pathMatcher = new AntPathMatcher();
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
Filter.super.init(filterConfig);
|
||||
// 从初始化参数中读取白名单
|
||||
excludedPaths = whitelistProperties.getPaths();
|
||||
log.info("----------- AuthFilter init ----------");
|
||||
}
|
||||
public class AuthFilter extends BaseAuthFilter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
if (servletRequest instanceof HttpServletRequest) {
|
||||
HttpServletRequest req = (HttpServletRequest) servletRequest;
|
||||
String path = req.getRequestURI().substring(req.getContextPath().length());
|
||||
// 检查当前请求是否在白名单中
|
||||
for (String excludedPath : excludedPaths) {
|
||||
if (pathMatcher.match(excludedPath, path)) {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!ThreadLocalContext.verifyRequest(req))
|
||||
{
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // 401
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"code\":401,\"message\":\"未登录或认证信息缺失\"}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
Filter.super.destroy();
|
||||
log.info("----------- AuthFilter destroy ----------");
|
||||
super.doFilter(servletRequest, servletResponse, filterChain);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user