mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	【优化】调试 mj proxy 通知回调
This commit is contained in:
		| @@ -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; | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 cherishsince
					cherishsince