From 2fde9b124d6675c02635933d25b4b1d6ae2c73ec Mon Sep 17 00:00:00 2001 From: cherishsince Date: Wed, 24 Apr 2024 20:07:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ai=20modal=EF=BC=88=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=88=97=E8=A1=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/controller/AiChatModalController.java | 55 +++++++++++++++++++ .../module/ai/convert/ChatModalConvert.java | 24 ++++++++ .../ai/dal/dataobject/AiChatModalDO.java | 47 ++++++++++++++++ .../module/ai/mapper/AiChatModalMapper.java | 18 ++++++ .../module/ai/service/AiChatModalService.java | 20 +++++++ .../service/impl/AiChatModalServiceImpl.java | 53 ++++++++++++++++++ .../yudao/module/ai/vo/AiChatModalAddReq.java | 16 ++++++ .../module/ai/vo/AiChatModalListReq.java | 21 +++++++ .../module/ai/vo/AiChatModalListRes.java | 16 ++++++ .../module/ai/vo/ChatMessageDeleteReq.java | 28 ++++++++++ 10 files changed, 298 insertions(+) create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatModalController.java create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatModalConvert.java create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/AiChatModalDO.java create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/mapper/AiChatModalMapper.java create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatModalService.java create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatModalServiceImpl.java create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatModalAddReq.java create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatModalListReq.java create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatModalListRes.java create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatMessageDeleteReq.java diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatModalController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatModalController.java new file mode 100644 index 000000000..2258e2ee0 --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatModalController.java @@ -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 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); + } + + +} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatModalConvert.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatModalConvert.java new file mode 100644 index 000000000..9611953ac --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatModalConvert.java @@ -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 convertAiChatModalListRes(List list); +} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/AiChatModalDO.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/AiChatModalDO.java new file mode 100644 index 000000000..b4b8f4414 --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/AiChatModalDO.java @@ -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; + /** + * 模型类型(qianwen、yiyan、xinghuo、openai) + */ + private String modelType; + /** + * 模型照片 + */ + private String modalImage; + /** + * 模型配置JSON + */ + private String modelConfig; + /** + * 模型图片 + */ + private String modelImage; + /** + * 禁用 0、正常 1、禁用 + */ + private Integer disable; + +} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/mapper/AiChatModalMapper.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/mapper/AiChatModalMapper.java new file mode 100644 index 000000000..118cda294 --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/mapper/AiChatModalMapper.java @@ -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 { +} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatModalService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatModalService.java new file mode 100644 index 000000000..230b0f1b8 --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatModalService.java @@ -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 list(AiChatModalListReq req); + + void add(AiChatModalAddReq req); +} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatModalServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatModalServiceImpl.java new file mode 100644 index 000000000..60e510902 --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatModalServiceImpl.java @@ -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 list(AiChatModalListReq req) { + LambdaQueryWrapperX queryWrapperX = new LambdaQueryWrapperX<>(); + // search + if (!StrUtil.isBlank(req.getSearch())) { + queryWrapperX.like(AiChatModalDO::getModelName, req.getSearch().trim()); + } + // 默认排序 + queryWrapperX.orderByDesc(AiChatModalDO::getId); + // 查询 + PageResult aiChatModalDOPageResult = aiChatModalMapper.selectPage(req, queryWrapperX); + // 转换 res + List resList = ChatModalConvert.INSTANCE.convertAiChatModalListRes(aiChatModalDOPageResult.getList()); + return new PageResult<>(resList, aiChatModalDOPageResult.getTotal()); + } + + @Override + public void add(AiChatModalAddReq req) { + + } +} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatModalAddReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatModalAddReq.java new file mode 100644 index 000000000..1af1d8768 --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatModalAddReq.java @@ -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 { +} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatModalListReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatModalListReq.java new file mode 100644 index 000000000..6801aadb2 --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatModalListReq.java @@ -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; +} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatModalListRes.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatModalListRes.java new file mode 100644 index 000000000..aa869ed23 --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatModalListRes.java @@ -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 { +} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatMessageDeleteReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatMessageDeleteReq.java new file mode 100644 index 000000000..9b2986e81 --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatMessageDeleteReq.java @@ -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; + +}