增加ai modal(查询列表)

This commit is contained in:
cherishsince 2024-04-24 20:07:58 +08:00
parent 9e412ffec8
commit 2fde9b124d
10 changed files with 298 additions and 0 deletions

View File

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.ai.controller;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.ai.service.AiChatModalService;
import cn.iocoder.yudao.module.ai.vo.AiChatModalAddReq;
import cn.iocoder.yudao.module.ai.vo.AiChatModalListReq;
import cn.iocoder.yudao.module.ai.vo.AiChatModalListRes;
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.*;
import org.springframework.web.multipart.MultipartFile;
/**
* ai 模型
*
* @author fansili
* @time 2024/4/24 19:42
* @since 1.0
*/
@Tag(name = "A6-AI模型")
@RestController
@RequestMapping("/ai/chat")
@Slf4j
@AllArgsConstructor
public class AiChatModalController {
private final AiChatModalService aiChatModalService;
@Operation(summary = "ai模型 - 模型照片上传")
@GetMapping("/modal/list")
public PageResult<AiChatModalListRes> list(@ModelAttribute AiChatModalListReq req) {
return aiChatModalService.list(req);
}
@Operation(summary = "ai模型 - 添加")
@PutMapping("/modal")
public CommonResult add(@RequestBody @Validated AiChatModalAddReq req) {
aiChatModalService.add(req);
return CommonResult.success(null);
}
@Operation(summary = "ai模型 - 模型照片上传")
@PutMapping("/modal/{id}/updateImage")
public CommonResult updateImage(@PathVariable("id") Long id,
MultipartFile file) {
// todo yunai 文件上传这里放哪里
return CommonResult.success(null);
}
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.ai.convert;
import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatModalDO;
import cn.iocoder.yudao.module.ai.vo.AiChatModalListRes;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 聊天 对话 convert
*
* @author fansili
* @time 2024/4/18 16:39
* @since 1.0
*/
@Mapper
public interface ChatModalConvert {
ChatModalConvert INSTANCE = Mappers.getMapper(ChatModalConvert.class);
List<AiChatModalListRes> convertAiChatModalListRes(List<AiChatModalDO> list);
}

View File

@ -0,0 +1,47 @@
package cn.iocoder.yudao.module.ai.dal.dataobject;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* ai 模型
*
* @author fansili
* @time 2024/4/24 19:39
* @since 1.0
*/
@Data
@Accessors(chain = true)
public class AiChatModalDO extends BaseDO {
/**
* 编号
*/
private Long id;
/**
* 模型名字
*/
private Long modelName;
/**
* 模型类型(qianwenyiyanxinghuoopenai)
*/
private String modelType;
/**
* 模型照片
*/
private String modalImage;
/**
* 模型配置JSON
*/
private String modelConfig;
/**
* 模型图片
*/
private String modelImage;
/**
* 禁用 0正常 1禁用
*/
private Integer disable;
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.ai.mapper;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatModalDO;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* chat modal
*
* @author fansili
* @time 2024/4/24 19:41
* @since 1.0
*/
@Repository
@Mapper
public interface AiChatModalMapper extends BaseMapperX<AiChatModalDO> {
}

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.ai.service;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.ai.vo.AiChatModalAddReq;
import cn.iocoder.yudao.module.ai.vo.AiChatModalListReq;
import cn.iocoder.yudao.module.ai.vo.AiChatModalListRes;
/**
* ai modal
*
* @author fansili
* @time 2024/4/24 19:42
* @since 1.0
*/
public interface AiChatModalService {
PageResult<AiChatModalListRes> list(AiChatModalListReq req);
void add(AiChatModalAddReq req);
}

View File

@ -0,0 +1,53 @@
package cn.iocoder.yudao.module.ai.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.ai.convert.ChatModalConvert;
import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatModalDO;
import cn.iocoder.yudao.module.ai.mapper.AiChatModalMapper;
import cn.iocoder.yudao.module.ai.service.AiChatModalService;
import cn.iocoder.yudao.module.ai.vo.AiChatModalAddReq;
import cn.iocoder.yudao.module.ai.vo.AiChatModalListReq;
import cn.iocoder.yudao.module.ai.vo.AiChatModalListRes;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* ai 模型
*
* @author fansili
* @time 2024/4/24 19:42
* @since 1.0
*/
@AllArgsConstructor
@Service
@Slf4j
public class AiChatModalServiceImpl implements AiChatModalService {
private final AiChatModalMapper aiChatModalMapper;
@Override
public PageResult<AiChatModalListRes> list(AiChatModalListReq req) {
LambdaQueryWrapperX<AiChatModalDO> queryWrapperX = new LambdaQueryWrapperX<>();
// search
if (!StrUtil.isBlank(req.getSearch())) {
queryWrapperX.like(AiChatModalDO::getModelName, req.getSearch().trim());
}
// 默认排序
queryWrapperX.orderByDesc(AiChatModalDO::getId);
// 查询
PageResult<AiChatModalDO> aiChatModalDOPageResult = aiChatModalMapper.selectPage(req, queryWrapperX);
// 转换 res
List<AiChatModalListRes> resList = ChatModalConvert.INSTANCE.convertAiChatModalListRes(aiChatModalDOPageResult.getList());
return new PageResult<>(resList, aiChatModalDOPageResult.getTotal());
}
@Override
public void add(AiChatModalAddReq req) {
}
}

View File

@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.ai.vo;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* ai chat modal
*
* @author fansili
* @time 2024/4/24 19:47
* @since 1.0
*/
@Data
@Accessors(chain = true)
public class AiChatModalAddReq {
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.ai.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* modal list
*
* @author fansili
* @time 2024/4/24 19:56
* @since 1.0
*/
@Data
@Accessors(chain = true)
public class AiChatModalListReq extends PageParam {
@Schema(description = "名字搜搜")
private String search;
}

View File

@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.ai.vo;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* modal list
*
* @author fansili
* @time 2024/4/24 19:56
* @since 1.0
*/
@Data
@Accessors(chain = true)
public class AiChatModalListRes {
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.ai.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* chat message list req
*
* @author fansili
* @time 2024/4/14 16:12
* @since 1.0
*/
@Data
@Accessors(chain = true)
public class ChatMessageDeleteReq extends PageParam {
@Schema(description = "id")
@NotNull
private Long id;
@Schema(description = "聊天ID关联到特定的会话或对话")
@NotNull
private Long chatConversationId;
}