TASK:Flux接入,应用于to product image和relight

This commit is contained in:
2025-06-12 16:50:27 +08:00
parent 595effa04c
commit 6e32289b98
8 changed files with 284 additions and 24 deletions

View File

@@ -9,6 +9,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Map;
@Slf4j
@Component
public class SendRequestUtil {
@@ -68,6 +70,26 @@ public class SendRequestUtil {
}
}
public String sendFluxPost(String url, String requestBodyStr){
int status;
String body;
try (HttpResponse execute = HttpRequest.post(url)
.header(Header.CONTENT_TYPE, "application/json")
.header("x-key", "d447a0ac-2291-4f1c-9a36-f7614c385989")
.body(requestBodyStr) // Hutool 会自动处理 JSON 序列化
.timeout(180000) // 设置超时(毫秒)
.execute()) {
status = execute.getStatus();
body = execute.body();
if (status == 200) {
return body;
}
}
log.warn("请求失败,状态码为 {}, body: {}", status, body);
return null;
}
public String sendPost(String url, String requestBodyStr){
int status;
String body;
@@ -87,6 +109,27 @@ public class SendRequestUtil {
return null;
}
public String sendGet(String url, Map<String, Object> params) {
int status;
String body;
try (HttpResponse execute = HttpRequest.get(url)
.form(params) // 直接传入MapHutool会正确处理
.timeout(180000)
.execute()) {
status = execute.getStatus();
body = execute.body();
if (status == 200) {
return body;
}
} catch (Exception e) {
log.error("请求发生异常: {}", e.getMessage(), e);
return null;
}
log.warn("请求失败,状态码为: {}, body: {}", status, body);
return body;
}
}