Merge branch 'dev/dev_xp' into dev/dev

This commit is contained in:
2025-06-06 11:03:45 +08:00
2 changed files with 14 additions and 8 deletions

View File

@@ -14,14 +14,14 @@ import org.springframework.stereotype.Component;
public class SendRequestUtil {
@Value("${ALIYUN_API_KEY}")
private String AliYunAPIKey;
private String ALIYUN_API_KEY;
@Value("${FREEPIK_API_KEY}")
private String freepikAPIKey;
private String FREEPIK_API_KEY;
public String sendAliYunPostAsync(String apiUrl, String requestBody){
// 发送POST请求 todo 异常处理
HttpResponse execute = HttpRequest.post(apiUrl)
.header(Header.AUTHORIZATION, "Bearer " + AliYunAPIKey)
.header(Header.AUTHORIZATION, "Bearer " + ALIYUN_API_KEY)
.header("X-DashScope-Async", "enable")
.header(Header.CONTENT_TYPE, "application/json")
.body(requestBody)
@@ -42,7 +42,7 @@ public class SendRequestUtil {
// 发送POST请求 todo 异常处理
HttpResponse execute = HttpRequest.post(FREE_PIK)
.header(Header.CONTENT_TYPE, "application/json")
.header("x-freepik-api-key", freepikAPIKey)
.header("x-freepik-api-key", FREEPIK_API_KEY)
.body(requestBody)
.timeout(20000) // 设置超时时间20秒
.execute();
@@ -57,7 +57,7 @@ public class SendRequestUtil {
public String sendAliYunGet(String fullUrl){
// 发送GET请求 todo 异常处理
HttpResponse httpResponse = HttpRequest.get(fullUrl)
.header(Header.AUTHORIZATION, "Bearer " + AliYunAPIKey)
.header(Header.AUTHORIZATION, "Bearer " + ALIYUN_API_KEY)
.timeout(20000) // 设置超时时间20秒
.execute();
int status = httpResponse.getStatus();

View File

@@ -120,6 +120,13 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
@Value("${ollama.url}")
private String ollamaUrl;
@Value("${ALIYUN_API_KEY}")
private String ALIYUN_API_KEY;
@Value("${FREEPIK_API_KEY}")
private String FREEPIK_API_KEY;
@Resource
private AccountService accountService;
@@ -1360,7 +1367,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
promptExtend.put("prompt_extend", false);
ImageSynthesisParam param =
ImageSynthesisParam.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.apiKey(ALIYUN_API_KEY)
.model("wanx2.1-t2i-plus")
.prompt(prompt)
.n(1)
@@ -1460,7 +1467,6 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
private static final String TEMPLATE_ID_GEN = "https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/aa-template-generation/";
private static final String GET_ASYNC_RESULT = "https://dashscope.aliyuncs.com/api/v1/tasks/";
private static final String ANIMATE = "https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis/";
private static final String API_KEY = System.getenv("DASHSCOPE_API_KEY"); // 替换为你的实际API密钥
public String animateAnyone(PoseTransformDTO poseTransformDTO, Long accountId){
accountId = 87L;
@@ -1593,7 +1599,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
try {
// 发送GET请求查询任务状态
HttpResponse httpResponse = HttpRequest.get(GET_ASYNC_RESULT + taskId)
.header(Header.AUTHORIZATION, "Bearer " + API_KEY)
.header(Header.AUTHORIZATION, "Bearer " + ALIYUN_API_KEY)
.timeout(10000)
.execute();