Commit e4eadd8c9906843981bc7b5987ebb6a3260b1eb0
1 parent
77f3226d
增加 modal 更新
Showing
5 changed files
with
33 additions
and
0 deletions
yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/ErrorCodeConstants.java
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatModalController.java
| @@ -51,5 +51,12 @@ public class AiChatModalController { | @@ -51,5 +51,12 @@ public class AiChatModalController { | ||
| 51 | return CommonResult.success(null); | 51 | return CommonResult.success(null); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | + @Operation(summary = "ai模型 - 修改") | ||
| 55 | + @PostMapping("/modal/{id}") | ||
| 56 | + public CommonResult update(@PathVariable Long id, | ||
| 57 | + @RequestBody @Validated AiChatModalAddReq req) { | ||
| 58 | + aiChatModalService.update(id, req); | ||
| 59 | + return CommonResult.success(null); | ||
| 60 | + } | ||
| 54 | 61 | ||
| 55 | } | 62 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatModalService.java
| @@ -17,4 +17,6 @@ public interface AiChatModalService { | @@ -17,4 +17,6 @@ public interface AiChatModalService { | ||
| 17 | PageResult<AiChatModalListRes> list(AiChatModalListReq req); | 17 | PageResult<AiChatModalListRes> list(AiChatModalListReq req); |
| 18 | 18 | ||
| 19 | void add(AiChatModalAddReq req); | 19 | void add(AiChatModalAddReq req); |
| 20 | + | ||
| 21 | + void update(Long id, AiChatModalAddReq req); | ||
| 20 | } | 22 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatModalServiceImpl.java
| 1 | package cn.iocoder.yudao.module.ai.service.impl; | 1 | package cn.iocoder.yudao.module.ai.service.impl; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.StrUtil; | 3 | import cn.hutool.core.util.StrUtil; |
| 4 | +import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | +import cn.iocoder.yudao.module.ai.ErrorCodeConstants; | ||
| 6 | import cn.iocoder.yudao.module.ai.convert.ChatModalConvert; | 8 | import cn.iocoder.yudao.module.ai.convert.ChatModalConvert; |
| 7 | import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatModalDO; | 9 | import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatModalDO; |
| 8 | import cn.iocoder.yudao.module.ai.enums.AiChatModalDisableEnum; | 10 | import cn.iocoder.yudao.module.ai.enums.AiChatModalDisableEnum; |
| @@ -56,4 +58,22 @@ public class AiChatModalServiceImpl implements AiChatModalService { | @@ -56,4 +58,22 @@ public class AiChatModalServiceImpl implements AiChatModalService { | ||
| 56 | // 保存数据库 | 58 | // 保存数据库 |
| 57 | aiChatModalMapper.insert(insertChatModalDO); | 59 | aiChatModalMapper.insert(insertChatModalDO); |
| 58 | } | 60 | } |
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public void update(Long id, AiChatModalAddReq req) { | ||
| 64 | + // 校验模型是否存在 | ||
| 65 | + validateChatModalExists(id); | ||
| 66 | + // 转换 updateChatModalDO | ||
| 67 | + AiChatModalDO updateChatModalDO = ChatModalConvert.INSTANCE.convertAiChatModalDO(req); | ||
| 68 | + updateChatModalDO.setId(id); | ||
| 69 | + // 更新数据库 | ||
| 70 | + aiChatModalMapper.updateById(updateChatModalDO); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + private void validateChatModalExists(Long id) { | ||
| 74 | + AiChatModalDO aiChatModalDO = aiChatModalMapper.selectById(id); | ||
| 75 | + if (aiChatModalDO == null) { | ||
| 76 | + throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_MODAL_NOT_EXIST); | ||
| 77 | + } | ||
| 78 | + } | ||
| 59 | } | 79 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatModalListReq.java