Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
package com.sdm.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义跳过Filter鉴权的注解
|
||||||
|
* 标记此注解的Controller方法将跳过Filter的权限校验
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface IgnoreAuth {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.sdm.common.filter;
|
package com.sdm.common.filter;
|
||||||
|
|
||||||
|
import com.sdm.common.annotation.IgnoreAuth;
|
||||||
import com.sdm.common.common.ThreadLocalContext;
|
import com.sdm.common.common.ThreadLocalContext;
|
||||||
import com.sdm.common.config.WhitelistProperties;
|
import com.sdm.common.config.WhitelistProperties;
|
||||||
import jakarta.servlet.Filter;
|
import jakarta.servlet.Filter;
|
||||||
@@ -11,8 +12,13 @@ import jakarta.servlet.ServletResponse;
|
|||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.util.AntPathMatcher;
|
import org.springframework.util.AntPathMatcher;
|
||||||
|
import org.springframework.web.method.HandlerMethod;
|
||||||
|
import org.springframework.web.servlet.HandlerExecutionChain;
|
||||||
|
import org.springframework.web.servlet.HandlerMapping;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -23,6 +29,10 @@ public abstract class BaseAuthFilter implements Filter {
|
|||||||
@Autowired
|
@Autowired
|
||||||
protected WhitelistProperties whitelistProperties;
|
protected WhitelistProperties whitelistProperties;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("requestMappingHandlerMapping")
|
||||||
|
private HandlerMapping handlerMapping;
|
||||||
|
|
||||||
protected List<String> excludedPaths;
|
protected List<String> excludedPaths;
|
||||||
protected final AntPathMatcher pathMatcher = new AntPathMatcher();
|
protected final AntPathMatcher pathMatcher = new AntPathMatcher();
|
||||||
|
|
||||||
@@ -50,7 +60,7 @@ public abstract class BaseAuthFilter implements Filter {
|
|||||||
filterChain.doFilter(servletRequest, servletResponse);
|
filterChain.doFilter(servletRequest, servletResponse);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 执行认证检查
|
// 执行认证检查
|
||||||
if (!shouldSkipAuthentication(req) && !hasContext) {
|
if (!shouldSkipAuthentication(req) && !hasContext) {
|
||||||
handleUnauthenticatedRequest(servletResponse);
|
handleUnauthenticatedRequest(servletResponse);
|
||||||
@@ -68,6 +78,36 @@ public abstract class BaseAuthFilter implements Filter {
|
|||||||
* 子类可以覆盖此方法来实现特定逻辑
|
* 子类可以覆盖此方法来实现特定逻辑
|
||||||
*/
|
*/
|
||||||
protected boolean shouldSkipAuthentication(HttpServletRequest request) {
|
protected boolean shouldSkipAuthentication(HttpServletRequest request) {
|
||||||
|
// 1. 通过HandlerMapping获取当前请求对应的处理器(HandlerMethod)
|
||||||
|
Object handler = null;
|
||||||
|
try {
|
||||||
|
HandlerExecutionChain handlerExecutionChain = handlerMapping.getHandler(request);
|
||||||
|
if (ObjectUtils.isEmpty(handlerExecutionChain)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
handler = handlerExecutionChain.getHandler();
|
||||||
|
if (ObjectUtils.isEmpty(handler)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("shouldSkipAuthentication异常:{}",e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 2. 判断处理器是否为HandlerMethod(仅Controller方法会是HandlerMethod,静态资源等不是)
|
||||||
|
if (!(handler instanceof HandlerMethod)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
||||||
|
// 3. 先判断Controller方法上是否带有@IgnoreAuth注解(方法注解优先级高于类注解)
|
||||||
|
if (handlerMethod.hasMethodAnnotation(IgnoreAuth.class)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 4. 再判断Controller类上是否带有@IgnoreAuth注解
|
||||||
|
Class<?> controllerClass = handlerMethod.getBeanType();
|
||||||
|
if (controllerClass.isAnnotationPresent(IgnoreAuth.class)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 5. 既无方法注解,也无类注解,不跳过Filter
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.sdm.data.controller;
|
package com.sdm.data.controller;
|
||||||
|
|
||||||
|
import com.sdm.common.annotation.IgnoreAuth;
|
||||||
import com.sdm.common.common.SdmResponse;
|
import com.sdm.common.common.SdmResponse;
|
||||||
import com.sdm.common.entity.req.data.*;
|
import com.sdm.common.entity.req.data.*;
|
||||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||||
@@ -478,6 +479,7 @@ public class DataFileController implements IDataFeignClient {
|
|||||||
@CrossOrigin(origins = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.OPTIONS})
|
@CrossOrigin(origins = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.OPTIONS})
|
||||||
@PostMapping("/onlyOfficeCallback")
|
@PostMapping("/onlyOfficeCallback")
|
||||||
@Operation(summary = "only office 回调", description = "only office 回调")
|
@Operation(summary = "only office 回调", description = "only office 回调")
|
||||||
|
@IgnoreAuth
|
||||||
public ResponseEntity onlyOfficeCallback(@RequestBody CallbackData callbackData) {
|
public ResponseEntity onlyOfficeCallback(@RequestBody CallbackData callbackData) {
|
||||||
return IDataFileService.onlyOfficeCallback(callbackData);
|
return IDataFileService.onlyOfficeCallback(callbackData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,4 +247,14 @@ public class SimulationTaskController implements ISimulationTaskFeignClient {
|
|||||||
return taskService.getProjectDifficultStatistics(req);
|
return taskService.getProjectDifficultStatistics(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务及相关数据
|
||||||
|
*/
|
||||||
|
@SysLog("删除任务及相关数据")
|
||||||
|
@PostMapping("/deleteTask")
|
||||||
|
@Operation(summary = "删除任务及相关数据", description = "删除任务及相关数据")
|
||||||
|
public SdmResponse deleteTask(@RequestBody @Validated SpdmDeleteTaskReq req) {
|
||||||
|
return taskService.deleteTask(req);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.sdm.project.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.sdm.common.entity.req.project.SimulationPerformance;
|
||||||
|
import com.sdm.project.model.entity.SimulationPerformanceExtra;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author author
|
||||||
|
* @since 2025-11-03
|
||||||
|
*/
|
||||||
|
public interface SimulationPerformanceExtraMapper extends BaseMapper<SimulationPerformanceExtra> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package com.sdm.project.model.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author author
|
||||||
|
* @since 2025-09-16
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("simulation_performance_extra")
|
||||||
|
@ApiModel(value="SimulationPerformanceExtra对象", description="")
|
||||||
|
public class SimulationPerformanceExtra implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@TableField("uuid")
|
||||||
|
private String uuid;
|
||||||
|
|
||||||
|
@TableField("performanceId")
|
||||||
|
private String performanceId;
|
||||||
|
|
||||||
|
@TableField("taskId")
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
@TableField("nodeId")
|
||||||
|
private String nodeId;
|
||||||
|
|
||||||
|
@TableField("poolName")
|
||||||
|
private String poolName;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField("propertyName")
|
||||||
|
private String propertyName;
|
||||||
|
|
||||||
|
@TableField("propertyValue")
|
||||||
|
private String propertyValue;
|
||||||
|
|
||||||
|
@TableField("valueType")
|
||||||
|
private String valueType;
|
||||||
|
|
||||||
|
@TableField("propertyClass")
|
||||||
|
private String propertyClass;
|
||||||
|
|
||||||
|
@TableField("creator")
|
||||||
|
@ApiModelProperty(value = "创建人")
|
||||||
|
private Long creator;
|
||||||
|
|
||||||
|
@TableField("create_time")
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
@TableField("updater")
|
||||||
|
@ApiModelProperty(value = "更新人")
|
||||||
|
private Long updater;
|
||||||
|
|
||||||
|
@TableField("update_time")
|
||||||
|
@ApiModelProperty(value = "更新时间")
|
||||||
|
private String updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.sdm.project.model.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务及相关数据请求参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "删除任务及相关数据请求参数")
|
||||||
|
public class SpdmDeleteTaskReq {
|
||||||
|
|
||||||
|
@Schema(description = "任务id集合")
|
||||||
|
@NotEmpty
|
||||||
|
private List<String> taskIdList;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.sdm.project.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.sdm.common.entity.req.project.SimulationPerformance;
|
||||||
|
import com.sdm.project.model.entity.SimulationPerformanceExtra;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author author
|
||||||
|
* @since 2025-11-03
|
||||||
|
*/
|
||||||
|
public interface ISimulationPerformanceExtraService extends IService<SimulationPerformanceExtra> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -76,4 +76,7 @@ public interface ITaskService {
|
|||||||
SdmResponse<List<JSONObject>> getTaskDifficultStatistics();
|
SdmResponse<List<JSONObject>> getTaskDifficultStatistics();
|
||||||
|
|
||||||
SdmResponse<List<ProjectDifficultStatisticsResp>> getProjectDifficultStatistics(ProjectDifficultCompleteStatisticsReq req);
|
SdmResponse<List<ProjectDifficultStatisticsResp>> getProjectDifficultStatistics(ProjectDifficultCompleteStatisticsReq req);
|
||||||
|
|
||||||
|
SdmResponse deleteTask(SpdmDeleteTaskReq req);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.sdm.project.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.sdm.common.entity.req.project.SimulationPerformance;
|
||||||
|
import com.sdm.project.dao.SimulationPerformanceExtraMapper;
|
||||||
|
import com.sdm.project.dao.SimulationPerformanceMapper;
|
||||||
|
import com.sdm.project.model.entity.SimulationPerformanceExtra;
|
||||||
|
import com.sdm.project.service.ISimulationPerformanceExtraService;
|
||||||
|
import com.sdm.project.service.ISimulationPerformanceService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author author
|
||||||
|
* @since 2025-11-03
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SimulationPerformanceExtraServiceImpl extends ServiceImpl<SimulationPerformanceExtraMapper, SimulationPerformanceExtra> implements ISimulationPerformanceExtraService {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import com.sdm.common.entity.enums.DirTypeEnum;
|
|||||||
import com.sdm.common.entity.enums.FilePermissionEnum;
|
import com.sdm.common.entity.enums.FilePermissionEnum;
|
||||||
import com.sdm.common.entity.enums.NodeTypeEnum;
|
import com.sdm.common.entity.enums.NodeTypeEnum;
|
||||||
import com.sdm.common.entity.req.data.CreateDirReq;
|
import com.sdm.common.entity.req.data.CreateDirReq;
|
||||||
|
import com.sdm.common.entity.req.data.DelDirReq;
|
||||||
import com.sdm.common.entity.req.data.QueryFileReq;
|
import com.sdm.common.entity.req.data.QueryFileReq;
|
||||||
import com.sdm.common.entity.req.data.UpdatePermissionReq;
|
import com.sdm.common.entity.req.data.UpdatePermissionReq;
|
||||||
import com.sdm.common.entity.req.project.SimulationPerformance;
|
import com.sdm.common.entity.req.project.SimulationPerformance;
|
||||||
@@ -110,6 +111,9 @@ public class TaskServiceImpl implements ITaskService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SimulationFlowFeignClientImpl flowFeignClient;
|
private SimulationFlowFeignClientImpl flowFeignClient;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISimulationPerformanceExtraService simulationPerformanceExtraService;
|
||||||
|
|
||||||
private static final String NODE_NAME_KEY = "nodeName";
|
private static final String NODE_NAME_KEY = "nodeName";
|
||||||
|
|
||||||
private static final String NODE_CODE_KEY = "nodeCode";
|
private static final String NODE_CODE_KEY = "nodeCode";
|
||||||
@@ -2655,4 +2659,42 @@ public class TaskServiceImpl implements ITaskService {
|
|||||||
return SdmResponse.success(projectDifficultStatisticsRespList.stream().sorted(Comparator.comparingInt(ProjectDifficultStatisticsResp::getDifficult)).toList());
|
return SdmResponse.success(projectDifficultStatisticsRespList.stream().sorted(Comparator.comparingInt(ProjectDifficultStatisticsResp::getDifficult)).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除文件夹
|
||||||
|
public void deleteDirNew(List<String> uuidList) {
|
||||||
|
for (String uuid : uuidList) {
|
||||||
|
DelDirReq req = new DelDirReq();
|
||||||
|
req.setDelUuid(uuid);
|
||||||
|
log.info("调用删除文件夹的参数为:{}", req);
|
||||||
|
SdmResponse response = dataClientFeignClient.delDir(req);
|
||||||
|
log.info("调用删除文件夹的返回值为:{}", response);
|
||||||
|
if (response.getCode() != ResultCode.SUCCESS.getCode()) {
|
||||||
|
throw new RuntimeException(response.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@Override
|
||||||
|
public SdmResponse deleteTask(SpdmDeleteTaskReq req) {
|
||||||
|
List<String> taskIdList = req.getTaskIdList();
|
||||||
|
// 删除任务相关数据
|
||||||
|
simulationTaskService.lambdaUpdate().in(SimulationTask::getUuid, taskIdList).remove();
|
||||||
|
simulationTaskMemberService.lambdaUpdate().in(SimulationTaskMember::getTaskId, taskIdList).remove();
|
||||||
|
simulationTaskExtraService.lambdaUpdate().in(SimulationTaskExtra::getTaskId, taskIdList).remove();
|
||||||
|
simulationTaskAttentionService.lambdaUpdate().in(SimulationTaskAttention::getTaskId, taskIdList).remove();
|
||||||
|
// 删除指标相关数据
|
||||||
|
List<SimulationPerformance> performanceList = simulationPerformanceService.lambdaQuery().in(SimulationPerformance::getTaskId, taskIdList).list();
|
||||||
|
if (CollectionUtils.isNotEmpty(performanceList)) {
|
||||||
|
simulationPerformanceService.lambdaUpdate().in(SimulationPerformance::getTaskId, taskIdList).remove();
|
||||||
|
simulationPerformanceExtraService.lambdaUpdate().in(SimulationPerformanceExtra::getPerformanceId, performanceList.stream().map(SimulationPerformance::getUuid).toList()).remove();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
deleteDirNew(taskIdList);
|
||||||
|
}catch (Exception e) {
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
return SdmResponse.failed("删除任务失败,原因为:" + e.getMessage());
|
||||||
|
}
|
||||||
|
return SdmResponse.success("删除任务成功");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user