【定义】定义 midjourney 相关功能操作api

This commit is contained in:
cherishsince 2024-05-07 18:17:17 +08:00
parent 6e3f34b0db
commit 1a7446b914
6 changed files with 81 additions and 15 deletions

View File

@ -3,17 +3,14 @@ package cn.iocoder.yudao.module.ai.controller.admin.image;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDallDrawingReqVO;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDallDrawingRespVO;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageMidjourneyReq;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageMidjourneyReqVO;
import cn.iocoder.yudao.module.ai.service.AiImageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -40,10 +37,34 @@ public class AiImageController {
return aiImageService.dallDrawing(req);
}
@Operation(summary = "midjourney", description = "midjourney图片绘画流程1、提交任务 2、获取完成的任务 3、选择对应功能 4、获取最终结果")
@Operation(summary = "midjourney绘画", description = "midjourney图片绘画流程1、提交任务 2、获取完成的任务 3、选择对应功能 4、获取最终结果")
@PostMapping("/midjourney")
public CommonResult<Void> midjourney(@Validated @RequestBody AiImageMidjourneyReq req) {
public CommonResult<Void> midjourney(@Validated @RequestBody AiImageMidjourneyReqVO req) {
aiImageService.midjourney(req);
return success(null);
}
@Operation(summary = "midjourney绘画操作", description = "一般有选择图片、放大、换一批...")
@PostMapping("/midjourney-operate")
public CommonResult<Void> midjourneyOperate(@Validated @RequestBody AiImageMidjourneyReqVO req) {
return success(null);
}
@Operation(summary = "获取midjourney绘画列表", description = "获取 Midjourney 绘画列表")
@GetMapping("/get-midjourney-list")
public CommonResult<Void> getMidjourneyList(@Validated @RequestBody AiImageMidjourneyReqVO req) {
return success(null);
}
@Operation(summary = "取消 midjourney 绘画", description = "取消 midjourney 绘画")
@PostMapping("/cancel-midjourney")
public CommonResult<Void> cancelMidjourney(@RequestParam("id") Long id) {
return success(null);
}
@Operation(summary = "删除绘画记录", description = "")
@DeleteMapping("/delete")
public CommonResult<Void> delete(@RequestParam("id") Long id) {
return success(null);
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.ai.controller.admin.image.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
@ -13,9 +14,6 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class AiImageMidjourneyReq {
@Schema(description = "提示词")
private String prompt;
public class AiImageMidjourneyListReqVO extends PageParam {
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.ai.controller.admin.image.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* midjourney req
*
* @author fansili
* @time 2024/4/28 17:42
* @since 1.0
*/
@Data
@Accessors(chain = true)
public class AiImageMidjourneyListRespVO extends PageParam {
}

View File

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.ai.controller.admin.image.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* midjourney req
*
* @author fansili
* @time 2024/4/28 17:42
* @since 1.0
*/
@Data
@Accessors(chain = true)
public class AiImageMidjourneyReqVO {
@Schema(description = "提示词")
private String prompt;
@Schema(description = "绘画比例 1:1、3:4、4:3、9:16、16:9")
private String size;
@Schema(description = "风格")
private String style;
@Schema(description = "参考图")
private String referImage;
}

View File

@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.ai.service;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDallDrawingReqVO;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDallDrawingRespVO;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageMidjourneyReq;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageMidjourneyReqVO;
/**
* ai 作图
@ -26,5 +26,5 @@ public interface AiImageService {
* @param req
* @return
*/
void midjourney(AiImageMidjourneyReq req);
void midjourney(AiImageMidjourneyReqVO req);
}

View File

@ -16,7 +16,7 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.ai.ErrorCodeConstants;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDallDrawingReqVO;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDallDrawingRespVO;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageMidjourneyReq;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageMidjourneyReqVO;
import cn.iocoder.yudao.module.ai.convert.AiImageConvert;
import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO;
import cn.iocoder.yudao.module.ai.dal.mysql.AiImageMapper;
@ -96,7 +96,7 @@ public class AiImageServiceImpl implements AiImageService {
@Override
@Transactional(rollbackFor = Exception.class)
public void midjourney(AiImageMidjourneyReq req) {
public void midjourney(AiImageMidjourneyReqVO req) {
// 保存数据库
AiImageDO aiImageDO = doSave(req.getPrompt(), null, "midjoureny",
null, AiChatDrawingStatusEnum.SUBMIT, null);