mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
增加 modal 更新
This commit is contained in:
parent
77f3226d27
commit
e4eadd8c99
@ -28,4 +28,7 @@ public interface ErrorCodeConstants {
|
||||
|
||||
|
||||
|
||||
ErrorCode AI_MODAL_NOT_EXIST = new ErrorCode(1_022_000_060, "ai模型不存在!");
|
||||
|
||||
|
||||
}
|
||||
|
@ -51,5 +51,12 @@ public class AiChatModalController {
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "ai模型 - 修改")
|
||||
@PostMapping("/modal/{id}")
|
||||
public CommonResult update(@PathVariable Long id,
|
||||
@RequestBody @Validated AiChatModalAddReq req) {
|
||||
aiChatModalService.update(id, req);
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,4 +17,6 @@ public interface AiChatModalService {
|
||||
PageResult<AiChatModalListRes> list(AiChatModalListReq req);
|
||||
|
||||
void add(AiChatModalAddReq req);
|
||||
|
||||
void update(Long id, AiChatModalAddReq req);
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package cn.iocoder.yudao.module.ai.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.ai.ErrorCodeConstants;
|
||||
import cn.iocoder.yudao.module.ai.convert.ChatModalConvert;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatModalDO;
|
||||
import cn.iocoder.yudao.module.ai.enums.AiChatModalDisableEnum;
|
||||
@ -56,4 +58,22 @@ public class AiChatModalServiceImpl implements AiChatModalService {
|
||||
// 保存数据库
|
||||
aiChatModalMapper.insert(insertChatModalDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Long id, AiChatModalAddReq req) {
|
||||
// 校验模型是否存在
|
||||
validateChatModalExists(id);
|
||||
// 转换 updateChatModalDO
|
||||
AiChatModalDO updateChatModalDO = ChatModalConvert.INSTANCE.convertAiChatModalDO(req);
|
||||
updateChatModalDO.setId(id);
|
||||
// 更新数据库
|
||||
aiChatModalMapper.updateById(updateChatModalDO);
|
||||
}
|
||||
|
||||
private void validateChatModalExists(Long id) {
|
||||
AiChatModalDO aiChatModalDO = aiChatModalMapper.selectById(id);
|
||||
if (aiChatModalDO == null) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_MODAL_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,4 +18,5 @@ public class AiChatModalListReq extends PageParam {
|
||||
|
||||
@Schema(description = "名字搜搜")
|
||||
private String search;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user