Commit b6096b76d28d2d47596194b85c39835a822e40af
1 parent
e8cf40a8
【增加】ai image 生成记录删除
Showing
4 changed files
with
21 additions
and
4 deletions
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java
| @@ -59,12 +59,14 @@ public class AiImageController { | @@ -59,12 +59,14 @@ public class AiImageController { | ||
| 59 | @Operation(summary = "取消 midjourney 绘画", description = "取消 midjourney 绘画") | 59 | @Operation(summary = "取消 midjourney 绘画", description = "取消 midjourney 绘画") |
| 60 | @PostMapping("/cancel-midjourney") | 60 | @PostMapping("/cancel-midjourney") |
| 61 | public CommonResult<Void> cancelMidjourney(@RequestParam("id") Long id) { | 61 | public CommonResult<Void> cancelMidjourney(@RequestParam("id") Long id) { |
| 62 | + // @范 这里实现mj取消逻辑 | ||
| 62 | return success(null); | 63 | return success(null); |
| 63 | } | 64 | } |
| 64 | 65 | ||
| 65 | @Operation(summary = "删除绘画记录", description = "") | 66 | @Operation(summary = "删除绘画记录", description = "") |
| 66 | @DeleteMapping("/delete") | 67 | @DeleteMapping("/delete") |
| 67 | public CommonResult<Void> delete(@RequestParam("id") Long id) { | 68 | public CommonResult<Void> delete(@RequestParam("id") Long id) { |
| 69 | + aiImageService.delete(id); | ||
| 68 | return success(null); | 70 | return success(null); |
| 69 | } | 71 | } |
| 70 | } | 72 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImageMidjourneyOperateReqVO.java
| @@ -19,7 +19,7 @@ public class AiImageMidjourneyOperateReqVO { | @@ -19,7 +19,7 @@ public class AiImageMidjourneyOperateReqVO { | ||
| 19 | 19 | ||
| 20 | @NotNull(message = "图片编号不能为空") | 20 | @NotNull(message = "图片编号不能为空") |
| 21 | @Schema(description = "编号") | 21 | @Schema(description = "编号") |
| 22 | - private String id; | 22 | + private Long id; |
| 23 | 23 | ||
| 24 | @NotNull(message = "消息编号不能为空") | 24 | @NotNull(message = "消息编号不能为空") |
| 25 | @Schema(description = "消息编号") | 25 | @Schema(description = "消息编号") |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiImageService.java
| @@ -44,4 +44,11 @@ public interface AiImageService { | @@ -44,4 +44,11 @@ public interface AiImageService { | ||
| 44 | */ | 44 | */ |
| 45 | void midjourneyOperate(AiImageMidjourneyOperateReqVO req); | 45 | void midjourneyOperate(AiImageMidjourneyOperateReqVO req); |
| 46 | 46 | ||
| 47 | + /** | ||
| 48 | + * 删除 - image 记录 | ||
| 49 | + * | ||
| 50 | + * @param id | ||
| 51 | + */ | ||
| 52 | + void delete(Long id); | ||
| 53 | + | ||
| 47 | } | 54 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiImageServiceImpl.java
| @@ -137,7 +137,7 @@ public class AiImageServiceImpl implements AiImageService { | @@ -137,7 +137,7 @@ public class AiImageServiceImpl implements AiImageService { | ||
| 137 | @Override | 137 | @Override |
| 138 | public void midjourneyOperate(AiImageMidjourneyOperateReqVO req) { | 138 | public void midjourneyOperate(AiImageMidjourneyOperateReqVO req) { |
| 139 | // 校验是否存在 | 139 | // 校验是否存在 |
| 140 | - AiImageDO aiImageDO = validateExists(req); | 140 | + AiImageDO aiImageDO = validateExists(req.getId()); |
| 141 | // 获取 midjourneyOperations | 141 | // 获取 midjourneyOperations |
| 142 | List<AiImageMidjourneyOperationsVO> midjourneyOperations = getMidjourneyOperations(aiImageDO); | 142 | List<AiImageMidjourneyOperationsVO> midjourneyOperations = getMidjourneyOperations(aiImageDO); |
| 143 | // 校验 OperateId 是否存在 | 143 | // 校验 OperateId 是否存在 |
| @@ -158,6 +158,14 @@ public class AiImageServiceImpl implements AiImageService { | @@ -158,6 +158,14 @@ public class AiImageServiceImpl implements AiImageService { | ||
| 158 | ); | 158 | ); |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | + @Override | ||
| 162 | + public void delete(Long id) { | ||
| 163 | + // 校验记录是否存在 | ||
| 164 | + AiImageDO aiImageDO = validateExists(id); | ||
| 165 | + // 删除记录 | ||
| 166 | + aiImageMapper.deleteById(id); | ||
| 167 | + } | ||
| 168 | + | ||
| 161 | private void validateMessageId(String mjMessageId, String messageId) { | 169 | private void validateMessageId(String mjMessageId, String messageId) { |
| 162 | if (!mjMessageId.equals(messageId)) { | 170 | if (!mjMessageId.equals(messageId)) { |
| 163 | throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_MIDJOURNEY_MESSAGE_ID_INCORRECT); | 171 | throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_MIDJOURNEY_MESSAGE_ID_INCORRECT); |
| @@ -181,8 +189,8 @@ public class AiImageServiceImpl implements AiImageService { | @@ -181,8 +189,8 @@ public class AiImageServiceImpl implements AiImageService { | ||
| 181 | return JsonUtils.parseArray(aiImageDO.getMjOperations(), AiImageMidjourneyOperationsVO.class); | 189 | return JsonUtils.parseArray(aiImageDO.getMjOperations(), AiImageMidjourneyOperationsVO.class); |
| 182 | } | 190 | } |
| 183 | 191 | ||
| 184 | - private AiImageDO validateExists(AiImageMidjourneyOperateReqVO req) { | ||
| 185 | - AiImageDO aiImageDO = aiImageMapper.selectById(req.getId()); | 192 | + private AiImageDO validateExists(Long id) { |
| 193 | + AiImageDO aiImageDO = aiImageMapper.selectById(id); | ||
| 186 | if (aiImageDO == null) { | 194 | if (aiImageDO == null) { |
| 187 | throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_MIDJOURNEY_IMAGINE_FAIL); | 195 | throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_MIDJOURNEY_IMAGINE_FAIL); |
| 188 | } | 196 | } |