修改mybatis版本启动报错,swagger注解问题
This commit is contained in:
@@ -23,9 +23,7 @@ public class AiServiceClient {
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
restClient = RestClient.builder()
|
||||
.baseUrl(baseUrl)
|
||||
.build();
|
||||
restClient = RestClient.builder().baseUrl(baseUrl).build();
|
||||
}
|
||||
|
||||
// DTO classes
|
||||
@@ -42,7 +40,7 @@ public class AiServiceClient {
|
||||
|
||||
@Data
|
||||
public static class ExtractionResponse {
|
||||
private List<Map<String, Object>> items; // triple/quadruple items
|
||||
private List<Map<String, Object>> items; // triple/quadruple items
|
||||
private String rawOutput;
|
||||
}
|
||||
|
||||
@@ -52,7 +50,7 @@ public class AiServiceClient {
|
||||
private Long sourceId;
|
||||
private String filePath;
|
||||
private String bucket;
|
||||
private Map<String, Object> params; // frameInterval, mode etc.
|
||||
private Map<String, Object> params; // frameInterval, mode etc.
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -63,7 +61,7 @@ public class AiServiceClient {
|
||||
@Data
|
||||
@Builder
|
||||
public static class FinetuneRequest {
|
||||
private String datasetPath; // RustFS path to JSONL file
|
||||
private String datasetPath; // RustFS path to JSONL file
|
||||
private String model;
|
||||
private Long batchId;
|
||||
}
|
||||
@@ -77,73 +75,42 @@ public class AiServiceClient {
|
||||
@Data
|
||||
public static class FinetuneStatusResponse {
|
||||
private String jobId;
|
||||
private String status; // PENDING/RUNNING/COMPLETED/FAILED
|
||||
private Integer progress; // 0-100
|
||||
private String status; // PENDING/RUNNING/COMPLETED/FAILED
|
||||
private Integer progress; // 0-100
|
||||
private String errorMessage;
|
||||
}
|
||||
|
||||
// The 8 endpoints:
|
||||
|
||||
public ExtractionResponse extractText(ExtractionRequest request) {
|
||||
return restClient.post()
|
||||
.uri("/extract/text")
|
||||
.body(request)
|
||||
.retrieve()
|
||||
.body(ExtractionResponse.class);
|
||||
return restClient.post().uri("/extract/text").body(request).retrieve().body(ExtractionResponse.class);
|
||||
}
|
||||
|
||||
public ExtractionResponse extractImage(ExtractionRequest request) {
|
||||
return restClient.post()
|
||||
.uri("/extract/image")
|
||||
.body(request)
|
||||
.retrieve()
|
||||
.body(ExtractionResponse.class);
|
||||
return restClient.post().uri("/extract/image").body(request).retrieve().body(ExtractionResponse.class);
|
||||
}
|
||||
|
||||
public void extractFrames(VideoProcessRequest request) {
|
||||
restClient.post()
|
||||
.uri("/video/extract-frames")
|
||||
.body(request)
|
||||
.retrieve()
|
||||
.toBodilessEntity();
|
||||
restClient.post().uri("/video/extract-frames").body(request).retrieve().toBodilessEntity();
|
||||
}
|
||||
|
||||
public void videoToText(VideoProcessRequest request) {
|
||||
restClient.post()
|
||||
.uri("/video/to-text")
|
||||
.body(request)
|
||||
.retrieve()
|
||||
.toBodilessEntity();
|
||||
restClient.post().uri("/video/to-text").body(request).retrieve().toBodilessEntity();
|
||||
}
|
||||
|
||||
public QaGenResponse genTextQa(ExtractionRequest request) {
|
||||
return restClient.post()
|
||||
.uri("/qa/gen-text")
|
||||
.body(request)
|
||||
.retrieve()
|
||||
.body(QaGenResponse.class);
|
||||
return restClient.post().uri("/qa/gen-text").body(request).retrieve().body(QaGenResponse.class);
|
||||
}
|
||||
|
||||
public QaGenResponse genImageQa(ExtractionRequest request) {
|
||||
return restClient.post()
|
||||
.uri("/qa/gen-image")
|
||||
.body(request)
|
||||
.retrieve()
|
||||
.body(QaGenResponse.class);
|
||||
return restClient.post().uri("/qa/gen-image").body(request).retrieve().body(QaGenResponse.class);
|
||||
}
|
||||
|
||||
public FinetuneResponse startFinetune(FinetuneRequest request) {
|
||||
return restClient.post()
|
||||
.uri("/finetune/start")
|
||||
.body(request)
|
||||
.retrieve()
|
||||
.body(FinetuneResponse.class);
|
||||
return restClient.post().uri("/finetune/start").body(request).retrieve().body(FinetuneResponse.class);
|
||||
}
|
||||
|
||||
public FinetuneStatusResponse getFinetuneStatus(String jobId) {
|
||||
return restClient.get()
|
||||
.uri("/finetune/status/{jobId}", jobId)
|
||||
.retrieve()
|
||||
.body(FinetuneStatusResponse.class);
|
||||
return restClient.get().uri("/finetune/status/{jobId}", jobId).retrieve().body(FinetuneStatusResponse.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ public class CompanyContext {
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
COMPANY_ID.remove(); // Use remove() not set(null) to prevent memory leaks
|
||||
COMPANY_ID.remove(); // Use remove() not set(null) to prevent memory leaks
|
||||
}
|
||||
|
||||
private CompanyContext() { // Prevent instantiation
|
||||
private CompanyContext() { // Prevent instantiation
|
||||
throw new UnsupportedOperationException("Utility class");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.util.ThreadContext;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
@@ -38,6 +39,24 @@ public class TokenFilter extends OncePerRequestFilter {
|
||||
private final RedisService redisService;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@Value("${shiro.auth.enabled:true}")
|
||||
private boolean authEnabled;
|
||||
|
||||
@Value("${shiro.auth.mock-company-id:1}")
|
||||
private Long mockCompanyId;
|
||||
|
||||
@Value("${shiro.auth.mock-user-id:1}")
|
||||
private Long mockUserId;
|
||||
|
||||
@Value("${shiro.auth.mock-role:ADMIN}")
|
||||
private String mockRole;
|
||||
|
||||
@Value("${shiro.auth.mock-username:mock}")
|
||||
private String mockUsername;
|
||||
|
||||
@Value("${token.ttl-seconds:7200}")
|
||||
private long tokenTtlSeconds;
|
||||
|
||||
/**
|
||||
* 公开端点跳过过滤:非 /api/ 前缀路径,以及登录接口本身。
|
||||
*/
|
||||
@@ -46,13 +65,25 @@ public class TokenFilter extends OncePerRequestFilter {
|
||||
String path = request.getServletPath();
|
||||
return !path.startsWith("/api/")
|
||||
|| path.equals("/api/auth/login")
|
||||
|| path.equals("/api/video/callback"); // AI 服务内部回调,不走用户 Token 认证
|
||||
|| path.equals("/api/video/callback")
|
||||
|| path.startsWith("/swagger-ui")
|
||||
|| path.startsWith("/v3/api-docs"); // AI 服务内部回调,不走用户 Token 认证
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
|
||||
FilterChain filterChain) throws ServletException, IOException {
|
||||
try {
|
||||
if (!authEnabled) {
|
||||
TokenPrincipal principal = new TokenPrincipal(
|
||||
mockUserId, mockRole, mockCompanyId, mockUsername, "mock-token");
|
||||
CompanyContext.set(mockCompanyId);
|
||||
SecurityUtils.getSubject().login(new BearerToken("mock-token", principal));
|
||||
request.setAttribute("__token_principal__", principal);
|
||||
filterChain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
String authHeader = request.getHeader("Authorization");
|
||||
if (authHeader == null || !authHeader.startsWith("Bearer ")) {
|
||||
writeUnauthorized(response, "缺少或无效的认证令牌");
|
||||
@@ -79,6 +110,8 @@ public class TokenFilter extends OncePerRequestFilter {
|
||||
TokenPrincipal principal = new TokenPrincipal(userId, role, companyId, username, token);
|
||||
SecurityUtils.getSubject().login(new BearerToken(token, principal));
|
||||
request.setAttribute("__token_principal__", principal);
|
||||
redisService.expire(RedisKeyManager.tokenKey(token), tokenTtlSeconds);
|
||||
redisService.expire(RedisKeyManager.userSessionsKey(userId), tokenTtlSeconds);
|
||||
|
||||
filterChain.doFilter(request, response);
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user