主要更新: - 修复了所有主要的代码逻辑错误 - 实现了完整的任务清理系统 - 添加了系统设置页面的任务清理管理功能 - 修复了API调用认证问题 - 优化了密码加密和验证机制 - 统一了错误处理模式 - 添加了详细的文档和测试工具 新增功能: - 任务清理管理界面 - 任务归档和清理日志 - API监控和诊断工具 - 完整的测试套件 技术改进: - 修复了Repository方法调用错误 - 统一了模型方法调用 - 改进了类型安全性 - 优化了代码结构和可维护性
53 lines
2.2 KiB
Java
53 lines
2.2 KiB
Java
import kong.unirest.HttpResponse;
|
|
import kong.unirest.Unirest;
|
|
import kong.unirest.UnirestException;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import java.util.Map;
|
|
|
|
public class TestApiConnection {
|
|
public static void main(String[] args) {
|
|
String apiBaseUrl = "http://116.62.4.26:8081";
|
|
String apiKey = "ak_5f13ec469e6047d5b8155c3cc91350e2";
|
|
|
|
System.out.println("测试API连接...");
|
|
System.out.println("API端点: " + apiBaseUrl);
|
|
System.out.println("API密钥: " + apiKey.substring(0, 10) + "...");
|
|
|
|
try {
|
|
// 测试获取模型列表
|
|
System.out.println("\n1. 测试获取模型列表...");
|
|
HttpResponse<String> modelsResponse = Unirest.get(apiBaseUrl + "/user/ai/models")
|
|
.header("Authorization", "Bearer " + apiKey)
|
|
.asString();
|
|
|
|
System.out.println("状态码: " + modelsResponse.getStatus());
|
|
System.out.println("响应内容: " + modelsResponse.getBody());
|
|
|
|
// 测试提交任务
|
|
System.out.println("\n2. 测试提交文生视频任务...");
|
|
String requestBody = "{\n" +
|
|
" \"modelName\": \"sc_sora2_text_landscape_10s_small\",\n" +
|
|
" \"prompt\": \"一只猫在飞\",\n" +
|
|
" \"aspectRatio\": \"16:9\",\n" +
|
|
" \"imageToVideo\": false\n" +
|
|
"}";
|
|
|
|
HttpResponse<String> submitResponse = Unirest.post(apiBaseUrl + "/user/ai/tasks/submit")
|
|
.header("Content-Type", "application/json")
|
|
.header("Authorization", "Bearer " + apiKey)
|
|
.body(requestBody)
|
|
.asString();
|
|
|
|
System.out.println("状态码: " + submitResponse.getStatus());
|
|
System.out.println("响应内容: " + submitResponse.getBody());
|
|
|
|
} catch (UnirestException e) {
|
|
System.err.println("API调用异常: " + e.getMessage());
|
|
e.printStackTrace();
|
|
} catch (Exception e) {
|
|
System.err.println("其他异常: " + e.getMessage());
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|