【调整】modal 修改为 model
This commit is contained in:
parent
893d394a0a
commit
46b5f17bbc
|
@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.ai.controller.admin.model;
|
|||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModalAddReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModalListReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModalListRespVO;
|
||||
import cn.iocoder.yudao.module.ai.service.AiChatModalService;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModelAddReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModelListReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModelListRespVO;
|
||||
import cn.iocoder.yudao.module.ai.service.AiChatModelService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -24,38 +24,38 @@ import org.springframework.web.bind.annotation.*;
|
|||
*/
|
||||
@Tag(name = "A6-AI模型")
|
||||
@RestController
|
||||
@RequestMapping("/ai/chat/modal")
|
||||
@RequestMapping("/ai/chat/model")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class AiChatModalController {
|
||||
public class AiChatModelController {
|
||||
|
||||
private final AiChatModalService aiChatModalService;
|
||||
private final AiChatModelService aiChatModelService;
|
||||
|
||||
@Operation(summary = "ai模型 - 模型列表")
|
||||
@GetMapping("/list")
|
||||
public PageResult<AiChatModalListRespVO> list(@ModelAttribute AiChatModalListReqVO req) {
|
||||
return aiChatModalService.list(req);
|
||||
public PageResult<AiChatModelListRespVO> list(@ModelAttribute AiChatModelListReqVO req) {
|
||||
return aiChatModelService.list(req);
|
||||
}
|
||||
|
||||
@Operation(summary = "ai模型 - 添加")
|
||||
@PutMapping("/add")
|
||||
public CommonResult<Void> add(@RequestBody @Validated AiChatModalAddReqVO req) {
|
||||
aiChatModalService.add(req);
|
||||
public CommonResult<Void> add(@RequestBody @Validated AiChatModelAddReqVO req) {
|
||||
aiChatModelService.add(req);
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "ai模型 - 修改")
|
||||
@PostMapping("/update")
|
||||
public CommonResult<Void> update(@RequestParam("id") Long id,
|
||||
@RequestBody @Validated AiChatModalAddReqVO req) {
|
||||
aiChatModalService.update(id, req);
|
||||
@RequestBody @Validated AiChatModelAddReqVO req) {
|
||||
aiChatModelService.update(id, req);
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "ai模型 - 删除")
|
||||
@DeleteMapping("/delete")
|
||||
public CommonResult<Void> delete(@RequestParam("id") Long id) {
|
||||
aiChatModalService.delete(id);
|
||||
aiChatModelService.delete(id);
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
}
|
|
@ -15,10 +15,9 @@ import lombok.experimental.Accessors;
|
|||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AiChatModalAddReqVO {
|
||||
public class AiChatModelAddReqVO {
|
||||
|
||||
@Schema(description = "API 秘钥编号")
|
||||
@Size(max = 32, message = "API 秘钥编号最大32个字符")
|
||||
@NotNull(message = "API 秘钥编号不能为空!")
|
||||
private Long keyId;
|
||||
|
|
@ -14,7 +14,7 @@ import lombok.experimental.Accessors;
|
|||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AiChatModalListReqVO extends PageParam {
|
||||
public class AiChatModelListReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "名字搜搜")
|
||||
private String search;
|
|
@ -13,7 +13,7 @@ import lombok.experimental.Accessors;
|
|||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AiChatModalListRespVO {
|
||||
public class AiChatModelListRespVO {
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
|
@ -1,9 +1,9 @@
|
|||
package cn.iocoder.yudao.module.ai.convert;
|
||||
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModalAddReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModalListRespVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModelAddReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModelListRespVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModalRespVO;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiChatModalDO;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiChatModelDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
|
@ -17,9 +17,9 @@ import java.util.List;
|
|||
* @since 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface AiChatModalConvert {
|
||||
public interface AiChatModelConvert {
|
||||
|
||||
AiChatModalConvert INSTANCE = Mappers.getMapper(AiChatModalConvert.class);
|
||||
AiChatModelConvert INSTANCE = Mappers.getMapper(AiChatModelConvert.class);
|
||||
|
||||
/**
|
||||
* 转换 - AiChatModalListRes
|
||||
|
@ -27,7 +27,7 @@ public interface AiChatModalConvert {
|
|||
* @param list
|
||||
* @return
|
||||
*/
|
||||
List<AiChatModalListRespVO> convertAiChatModalListRes(List<AiChatModalDO> list);
|
||||
List<AiChatModelListRespVO> convertAiChatModalListRes(List<AiChatModelDO> list);
|
||||
|
||||
/**
|
||||
* 转换 - AiChatModalDO
|
||||
|
@ -35,7 +35,7 @@ public interface AiChatModalConvert {
|
|||
* @param req
|
||||
* @return
|
||||
*/
|
||||
AiChatModalDO convertAiChatModalDO(AiChatModalAddReqVO req);
|
||||
AiChatModelDO convertAiChatModalDO(AiChatModelAddReqVO req);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -44,6 +44,6 @@ public interface AiChatModalConvert {
|
|||
* @param aiChatModalDO
|
||||
* @return
|
||||
*/
|
||||
AiChatModalRespVO convertAiChatModalRes(AiChatModalDO aiChatModalDO);
|
||||
AiChatModalRespVO convertAiChatModalRes(AiChatModelDO aiChatModalDO);
|
||||
|
||||
}
|
|
@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.annotation.KeySequence;
|
|||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* AI 聊天模型 DO
|
||||
|
@ -22,7 +21,7 @@ import lombok.experimental.Accessors;
|
|||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AiChatModalDO extends BaseDO {
|
||||
public class AiChatModelDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
|
@ -76,6 +75,6 @@ public class AiChatModalDO extends BaseDO {
|
|||
/**
|
||||
* 上下文的最大 Message 数量
|
||||
*/
|
||||
private Integer maxContexts;
|
||||
private Integer i;
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiChatModalDO;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiChatModelDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
@ -18,17 +18,17 @@ import org.springframework.stereotype.Repository;
|
|||
*/
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface AiChatModalMapper extends BaseMapperX<AiChatModalDO> {
|
||||
public interface AiChatModelMapper extends BaseMapperX<AiChatModelDO> {
|
||||
|
||||
/**
|
||||
* 查询 - 第一个modal
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default AiChatModalDO selectFirstModal() {
|
||||
PageResult<AiChatModalDO> pageResult = selectPage(new PageParam().setPageNo(1).setPageSize(1),
|
||||
new LambdaQueryWrapperX<AiChatModalDO>()
|
||||
.orderByAsc(AiChatModalDO::getSort)
|
||||
default AiChatModelDO selectFirstModal() {
|
||||
PageResult<AiChatModelDO> pageResult = selectPage(new PageParam().setPageNo(1).setPageSize(1),
|
||||
new LambdaQueryWrapperX<AiChatModelDO>()
|
||||
.orderByAsc(AiChatModelDO::getSort)
|
||||
);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return null;
|
|
@ -1,11 +1,11 @@
|
|||
package cn.iocoder.yudao.module.ai.service;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModalAddReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModalListReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModalListRespVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModelAddReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModelListReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModelListRespVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModalRespVO;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiChatModalDO;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiChatModelDO;
|
||||
|
||||
/**
|
||||
* ai modal
|
||||
|
@ -14,7 +14,7 @@ import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiChatModalDO;
|
|||
* @time 2024/4/24 19:42
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface AiChatModalService {
|
||||
public interface AiChatModelService {
|
||||
|
||||
/**
|
||||
* ai modal - 列表
|
||||
|
@ -22,14 +22,14 @@ public interface AiChatModalService {
|
|||
* @param req
|
||||
* @return
|
||||
*/
|
||||
PageResult<AiChatModalListRespVO> list(AiChatModalListReqVO req);
|
||||
PageResult<AiChatModelListRespVO> list(AiChatModelListReqVO req);
|
||||
|
||||
/**
|
||||
* ai modal - 添加
|
||||
*
|
||||
* @param req
|
||||
*/
|
||||
void add(AiChatModalAddReqVO req);
|
||||
void add(AiChatModelAddReqVO req);
|
||||
|
||||
/**
|
||||
* ai modal - 更新
|
||||
|
@ -37,7 +37,7 @@ public interface AiChatModalService {
|
|||
* @param id
|
||||
* @param req
|
||||
*/
|
||||
void update(Long id, AiChatModalAddReqVO req);
|
||||
void update(Long id, AiChatModelAddReqVO req);
|
||||
|
||||
/**
|
||||
* ai modal - 删除
|
||||
|
@ -60,7 +60,7 @@ public interface AiChatModalService {
|
|||
* @param id
|
||||
* @return
|
||||
*/
|
||||
AiChatModalDO validateExists(Long id);
|
||||
AiChatModelDO validateExists(Long id);
|
||||
|
||||
/**
|
||||
* 校验 - 校验是否可用
|
|
@ -8,15 +8,15 @@ 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.controller.admin.model.vo.model.AiChatModalAddReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModalListReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModalListRespVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModelAddReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModelListReqVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModelListRespVO;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiChatModalRespVO;
|
||||
import cn.iocoder.yudao.module.ai.convert.AiChatModalConvert;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiChatModalDO;
|
||||
import cn.iocoder.yudao.module.ai.dal.mysql.AiChatModalMapper;
|
||||
import cn.iocoder.yudao.module.ai.convert.AiChatModelConvert;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiChatModelDO;
|
||||
import cn.iocoder.yudao.module.ai.dal.mysql.AiChatModelMapper;
|
||||
import cn.iocoder.yudao.module.ai.dal.vo.AiChatModalConfigVO;
|
||||
import cn.iocoder.yudao.module.ai.service.AiChatModalService;
|
||||
import cn.iocoder.yudao.module.ai.service.AiChatModelService;
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -35,51 +35,51 @@ import java.util.Set;
|
|||
@AllArgsConstructor
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AiChatModalServiceImpl implements AiChatModalService {
|
||||
public class AiChatModalServiceImpl implements AiChatModelService {
|
||||
|
||||
private final AiChatModalMapper aiChatModalMapper;
|
||||
private final AiChatModelMapper aiChatModelMapper;
|
||||
|
||||
@Override
|
||||
public PageResult<AiChatModalListRespVO> list(AiChatModalListReqVO req) {
|
||||
LambdaQueryWrapperX<AiChatModalDO> queryWrapperX = new LambdaQueryWrapperX<>();
|
||||
public PageResult<AiChatModelListRespVO> list(AiChatModelListReqVO req) {
|
||||
LambdaQueryWrapperX<AiChatModelDO> queryWrapperX = new LambdaQueryWrapperX<>();
|
||||
// 查询的都是未禁用的模型
|
||||
queryWrapperX.eq(AiChatModalDO::getStatus, CommonStatusEnum.ENABLE.getStatus());
|
||||
queryWrapperX.eq(AiChatModelDO::getStatus, CommonStatusEnum.ENABLE.getStatus());
|
||||
// search
|
||||
if (!StrUtil.isBlank(req.getSearch())) {
|
||||
queryWrapperX.like(AiChatModalDO::getName, req.getSearch().trim());
|
||||
queryWrapperX.like(AiChatModelDO::getName, req.getSearch().trim());
|
||||
}
|
||||
// 默认排序
|
||||
queryWrapperX.orderByAsc(AiChatModalDO::getSort);
|
||||
queryWrapperX.orderByAsc(AiChatModelDO::getSort);
|
||||
// 查询
|
||||
PageResult<AiChatModalDO> aiChatModalDOPageResult = aiChatModalMapper.selectPage(req, queryWrapperX);
|
||||
PageResult<AiChatModelDO> aiChatModalDOPageResult = aiChatModelMapper.selectPage(req, queryWrapperX);
|
||||
// 转换 res
|
||||
List<AiChatModalListRespVO> resList = AiChatModalConvert.INSTANCE.convertAiChatModalListRes(aiChatModalDOPageResult.getList());
|
||||
List<AiChatModelListRespVO> resList = AiChatModelConvert.INSTANCE.convertAiChatModalListRes(aiChatModalDOPageResult.getList());
|
||||
return new PageResult<>(resList, aiChatModalDOPageResult.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(AiChatModalAddReqVO req) {
|
||||
public void add(AiChatModelAddReqVO req) {
|
||||
// 校验 platform、type
|
||||
validatePlatform(req.getPlatform());
|
||||
// 转换 do
|
||||
AiChatModalDO insertChatModalDO = AiChatModalConvert.INSTANCE.convertAiChatModalDO(req);
|
||||
AiChatModelDO insertChatModalDO = AiChatModelConvert.INSTANCE.convertAiChatModalDO(req);
|
||||
// 设置默认属性
|
||||
insertChatModalDO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
// 保存数据库
|
||||
aiChatModalMapper.insert(insertChatModalDO);
|
||||
aiChatModelMapper.insert(insertChatModalDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Long id, AiChatModalAddReqVO req) {
|
||||
public void update(Long id, AiChatModelAddReqVO req) {
|
||||
// 校验 platform
|
||||
validatePlatform(req.getPlatform());
|
||||
// 校验模型是否存在
|
||||
validateExists(id);
|
||||
// 转换 updateChatModalDO
|
||||
AiChatModalDO updateChatModalDO = AiChatModalConvert.INSTANCE.convertAiChatModalDO(req);
|
||||
AiChatModelDO updateChatModalDO = AiChatModelConvert.INSTANCE.convertAiChatModalDO(req);
|
||||
updateChatModalDO.setId(id);
|
||||
// 更新数据库
|
||||
aiChatModalMapper.updateById(updateChatModalDO);
|
||||
aiChatModelMapper.updateById(updateChatModalDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,14 +87,14 @@ public class AiChatModalServiceImpl implements AiChatModalService {
|
|||
// 检查 modal 是否存在
|
||||
validateExists(id);
|
||||
// 删除 delete
|
||||
aiChatModalMapper.deleteById(id);
|
||||
aiChatModelMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AiChatModalRespVO getChatModalOfValidate(Long modalId) {
|
||||
// 检查 modal 是否存在
|
||||
AiChatModalDO aiChatModalDO = validateExists(modalId);
|
||||
return AiChatModalConvert.INSTANCE.convertAiChatModalRes(aiChatModalDO);
|
||||
AiChatModelDO aiChatModalDO = validateExists(modalId);
|
||||
return AiChatModelConvert.INSTANCE.convertAiChatModalRes(aiChatModalDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -105,8 +105,8 @@ public class AiChatModalServiceImpl implements AiChatModalService {
|
|||
}
|
||||
}
|
||||
|
||||
public AiChatModalDO validateExists(Long id) {
|
||||
AiChatModalDO aiChatModalDO = aiChatModalMapper.selectById(id);
|
||||
public AiChatModelDO validateExists(Long id) {
|
||||
AiChatModelDO aiChatModalDO = aiChatModelMapper.selectById(id);
|
||||
if (aiChatModalDO == null) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_MODAL_NOT_EXIST);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue