mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
【优化】调试 mj proxy 通知回调
This commit is contained in:
parent
3ab218efc6
commit
dbe23cfe8e
@ -1,10 +1,12 @@
|
||||
package cn.iocoder.yudao.module.ai.client;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.module.ai.client.vo.MidjourneyImagineReqVO;
|
||||
import cn.iocoder.yudao.module.ai.client.vo.MidjourneySubmitRespVO;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
@ -35,7 +37,15 @@ public class MidjourneyProxyClient {
|
||||
* @return
|
||||
*/
|
||||
public MidjourneySubmitRespVO imagine(@Validated @NotNull MidjourneyImagineReqVO imagineReqVO) {
|
||||
return restTemplate.postForObject(url.concat(URI_IMAGINE), imagineReqVO, MidjourneySubmitRespVO.class);
|
||||
// 创建 HttpHeaders 对象
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.set("Authorization", "Bearer sk-c3qxUCVKsPfdQiYU8440E3Fc8dE5424d9cB124A4Ee2489E3");
|
||||
// 创建 HttpEntity 对象,将 HttpHeaders 和请求体传递给它
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(JsonUtils.toJsonString(imagineReqVO), headers);
|
||||
// 发送 post 请求
|
||||
ResponseEntity<String> response = restTemplate.exchange(url.concat(URI_IMAGINE), HttpMethod.POST, requestEntity, String.class);
|
||||
return JsonUtils.parseObject(response.getBody(), MidjourneySubmitRespVO.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class MidjourneyNotifyReqVO {
|
||||
@Schema(description = "任务类型")
|
||||
private MidjourneyTaskActionEnum action;
|
||||
@Schema(description = "任务状态")
|
||||
private MidjourneyTaskStatusEnum status = MidjourneyTaskStatusEnum.NOT_START;
|
||||
private MidjourneyTaskStatusEnum status;
|
||||
|
||||
@Schema(description = "提示词")
|
||||
private String prompt;
|
||||
|
@ -15,6 +15,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -70,10 +71,10 @@ public class AiImageController {
|
||||
return success(imageService.midjourneyImagine(getLoginUserId(), req));
|
||||
}
|
||||
|
||||
// TODO @芋艿:不拦截
|
||||
@Operation(summary = "midjourney proxy - 回调通知")
|
||||
@RequestMapping("/midjourney-notify")
|
||||
public CommonResult<Boolean> midjourneyNotify(MidjourneyNotifyReqVO notifyReqVO) {
|
||||
@PostMapping("/midjourney-notify")
|
||||
@PermitAll
|
||||
public CommonResult<Boolean> midjourneyNotify( @RequestBody MidjourneyNotifyReqVO notifyReqVO) {
|
||||
return success(imageService.midjourneyNotify(getLoginUserId(), notifyReqVO));
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,6 @@ public class AiImageServiceImpl implements AiImageService {
|
||||
.setId(image.getId())
|
||||
.setStatus(imageStatus)
|
||||
.setPicUrl(filePath)
|
||||
// .setOriginalPicUrl(notifyReqVO.getImageUrl()) TODO @fan:就不存原始的图片地址啦
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
@ -76,6 +76,13 @@ server:
|
||||
enabled: true
|
||||
charset: UTF-8
|
||||
force: true
|
||||
# ai
|
||||
ai:
|
||||
midjourney-proxy:
|
||||
url: https://api.holdai.top/mj
|
||||
notifyUrl: http://7b1aada4.r26.cpolar.top/admin-api/ai/image/midjourney-notify
|
||||
|
||||
|
||||
--- #################### 定时任务相关配置 ####################
|
||||
|
||||
# Quartz 配置项,对应 QuartzProperties 配置类
|
||||
|
Loading…
Reference in New Issue
Block a user