feat(更新日志):

更新日志

1. 移除个人微信模块
2. 移除直播模块
3. 移除gpts模块
4. 移除应用商店模块
5. 移除套餐管理模块
6. 移除兑换管理模块

## 微信相关
小程序相关功能迁移至企业版
微信公众号/微信机器人迁移至企业版
微信支付迁移至企业版

## 功能模块
智能体模块迁移至企业版
插件管理改为MCP应用并迁移至企业版

知识库:
excel解析迁移至企业版
pdf图片解析迁移至企业版
milvus qdrant扩展 迁移至企业版
This commit is contained in:
ageerle
2025-05-24 16:18:18 +08:00
parent 287a0b3d70
commit 373424bd01
185 changed files with 348 additions and 9421 deletions

View File

@@ -1,105 +0,0 @@
package org.ruoyi.chat.controller.chat;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.ruoyi.common.excel.utils.ExcelUtil;
import org.ruoyi.common.idempotent.annotation.RepeatSubmit;
import org.ruoyi.core.page.TableDataInfo;
import org.ruoyi.common.web.core.BaseController;
import org.ruoyi.domain.bo.ChatAgentManageBo;
import org.ruoyi.domain.vo.ChatAgentManageVo;
import org.ruoyi.service.IChatAgentManageService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.ruoyi.common.log.annotation.Log;
import org.ruoyi.core.page.PageQuery;
import org.ruoyi.common.core.domain.R;
import org.ruoyi.common.core.validate.AddGroup;
import org.ruoyi.common.core.validate.EditGroup;
import org.ruoyi.common.log.enums.BusinessType;
/**
* 智能体管理
*
* @author ageerle
* @date 2025-04-08
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/agentManage")
public class ChatAgentManageController extends BaseController {
private final IChatAgentManageService chatAgentManageService;
/**
* 查询智能体管理列表
*/
@SaCheckPermission("system:agentManage:list")
@GetMapping("/list")
public TableDataInfo<ChatAgentManageVo> list(ChatAgentManageBo bo, PageQuery pageQuery) {
return chatAgentManageService.queryPageList(bo, pageQuery);
}
/**
* 导出智能体管理列表
*/
@SaCheckPermission("system:agentManage:export")
@Log(title = "智能体管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(ChatAgentManageBo bo, HttpServletResponse response) {
List<ChatAgentManageVo> list = chatAgentManageService.queryList(bo);
ExcelUtil.exportExcel(list, "智能体管理", ChatAgentManageVo.class, response);
}
/**
* 获取智能体管理详细信息
*
* @param id 主键
*/
@SaCheckPermission("system:agentManage:query")
@GetMapping("/{id}")
public R<ChatAgentManageVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(chatAgentManageService.queryById(id));
}
/**
* 新增智能体管理
*/
@SaCheckPermission("system:agentManage:add")
@Log(title = "智能体管理", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody ChatAgentManageBo bo) {
return toAjax(chatAgentManageService.insertByBo(bo));
}
/**
* 修改智能体管理
*/
@SaCheckPermission("system:agentManage:edit")
@Log(title = "智能体管理", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ChatAgentManageBo bo) {
return toAjax(chatAgentManageService.updateByBo(bo));
}
/**
* 删除智能体管理
*
* @param ids 主键串
*/
@SaCheckPermission("system:agentManage:remove")
@Log(title = "智能体管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(chatAgentManageService.deleteWithValidByIds(List.of(ids), true));
}
}

View File

@@ -1,105 +0,0 @@
package org.ruoyi.chat.controller.chat;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.ruoyi.common.excel.utils.ExcelUtil;
import org.ruoyi.common.idempotent.annotation.RepeatSubmit;
import org.ruoyi.core.page.TableDataInfo;
import org.ruoyi.domain.bo.ChatAppStoreBo;
import org.ruoyi.domain.vo.ChatAppStoreVo;
import org.ruoyi.service.IChatAppStoreService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.ruoyi.common.log.annotation.Log;
import org.ruoyi.common.web.core.BaseController;
import org.ruoyi.core.page.PageQuery;
import org.ruoyi.common.core.domain.R;
import org.ruoyi.common.core.validate.AddGroup;
import org.ruoyi.common.core.validate.EditGroup;
import org.ruoyi.common.log.enums.BusinessType;
/**
* 应用商店
*
* @author ageerle
* @date 2025-04-08
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/appStore")
public class ChatAppStoreController extends BaseController {
private final IChatAppStoreService chatAppStoreService;
/**
* 查询应用商店列表
*/
@SaCheckPermission("system:appStore:list")
@GetMapping("/list")
public TableDataInfo<ChatAppStoreVo> list(ChatAppStoreBo bo, PageQuery pageQuery) {
return chatAppStoreService.queryPageList(bo, pageQuery);
}
/**
* 导出应用商店列表
*/
@SaCheckPermission("system:appStore:export")
@Log(title = "应用商店", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(ChatAppStoreBo bo, HttpServletResponse response) {
List<ChatAppStoreVo> list = chatAppStoreService.queryList(bo);
ExcelUtil.exportExcel(list, "应用商店", ChatAppStoreVo.class, response);
}
/**
* 获取应用商店详细信息
*
* @param id 主键
*/
@SaCheckPermission("system:appStore:query")
@GetMapping("/{id}")
public R<ChatAppStoreVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(chatAppStoreService.queryById(id));
}
/**
* 新增应用商店
*/
@SaCheckPermission("system:appStore:add")
@Log(title = "应用商店", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody ChatAppStoreBo bo) {
return toAjax(chatAppStoreService.insertByBo(bo));
}
/**
* 修改应用商店
*/
@SaCheckPermission("system:appStore:edit")
@Log(title = "应用商店", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ChatAppStoreBo bo) {
return toAjax(chatAppStoreService.updateByBo(bo));
}
/**
* 删除应用商店
*
* @param ids 主键串
*/
@SaCheckPermission("system:appStore:remove")
@Log(title = "应用商店", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(chatAppStoreService.deleteWithValidByIds(List.of(ids), true));
}
}

View File

@@ -10,15 +10,6 @@ import org.ruoyi.common.chat.request.ChatRequest;
import org.ruoyi.common.chat.entity.Tts.TextToSpeech;
import org.ruoyi.common.chat.entity.files.UploadFileResponse;
import org.ruoyi.common.chat.entity.whisper.WhisperResponse;
import org.ruoyi.common.core.domain.R;
import org.ruoyi.common.core.domain.model.LoginUser;
import org.ruoyi.common.core.exception.base.BaseException;
import org.ruoyi.core.page.PageQuery;
import org.ruoyi.core.page.TableDataInfo;
import org.ruoyi.common.satoken.utils.LoginHelper;
import org.ruoyi.domain.bo.ChatMessageBo;
import org.ruoyi.domain.vo.ChatMessageVo;
import org.ruoyi.service.IChatMessageService;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
@@ -41,8 +32,6 @@ public class ChatController {
private final ISseService sseService;
private final IChatMessageService chatMessageService;
/**
* 聊天接口
*/
@@ -84,21 +73,4 @@ public class ChatController {
return sseService.textToSpeed(textToSpeech);
}
/**
* 聊天记录
*/
@PostMapping("/chatList")
@ResponseBody
public R<TableDataInfo<ChatMessageVo>> list(@RequestBody @Valid ChatMessageBo chatRequest, @RequestBody PageQuery pageQuery) {
// 默认查询当前登录用户消息记录
LoginUser loginUser = LoginHelper.getLoginUser();
if (loginUser == null) {
throw new BaseException("用户未登录!");
}
chatRequest.setUserId(loginUser.getUserId());
TableDataInfo<ChatMessageVo> chatMessageVoTableDataInfo = chatMessageService.queryPageList(chatRequest, pageQuery);
return R.ok(chatMessageVoTableDataInfo);
}
}

View File

@@ -1,104 +0,0 @@
package org.ruoyi.chat.controller.chat;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.ruoyi.common.excel.utils.ExcelUtil;
import org.ruoyi.common.idempotent.annotation.RepeatSubmit;
import org.ruoyi.core.page.TableDataInfo;
import org.ruoyi.domain.bo.ChatGptsBo;
import org.ruoyi.domain.vo.ChatGptsVo;
import org.ruoyi.service.IChatGptsService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.ruoyi.common.log.annotation.Log;
import org.ruoyi.common.web.core.BaseController;
import org.ruoyi.core.page.PageQuery;
import org.ruoyi.common.core.domain.R;
import org.ruoyi.common.core.validate.AddGroup;
import org.ruoyi.common.core.validate.EditGroup;
import org.ruoyi.common.log.enums.BusinessType;
/**
* 应用管理
*
* @author ageerle
* @date 2025-04-08
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/gpts")
public class ChatGptsController extends BaseController {
private final IChatGptsService chatGptsService;
/**
* 查询应用管理列表
*/
@GetMapping("/list")
public TableDataInfo<ChatGptsVo> list(ChatGptsBo bo, PageQuery pageQuery) {
return chatGptsService.queryPageList(bo, pageQuery);
}
/**
* 导出应用管理列表
*/
@SaCheckPermission("system:gpts:export")
@Log(title = "应用管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(ChatGptsBo bo, HttpServletResponse response) {
List<ChatGptsVo> list = chatGptsService.queryList(bo);
ExcelUtil.exportExcel(list, "应用管理", ChatGptsVo.class, response);
}
/**
* 获取应用管理详细信息
*
* @param id 主键
*/
@SaCheckPermission("system:gpts:query")
@GetMapping("/{id}")
public R<ChatGptsVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(chatGptsService.queryById(id));
}
/**
* 新增应用管理
*/
@SaCheckPermission("system:gpts:add")
@Log(title = "应用管理", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody ChatGptsBo bo) {
return toAjax(chatGptsService.insertByBo(bo));
}
/**
* 修改应用管理
*/
@SaCheckPermission("system:gpts:edit")
@Log(title = "应用管理", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ChatGptsBo bo) {
return toAjax(chatGptsService.updateByBo(bo));
}
/**
* 删除应用管理
*
* @param ids 主键串
*/
@SaCheckPermission("system:gpts:remove")
@Log(title = "应用管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(chatGptsService.deleteWithValidByIds(List.of(ids), true));
}
}

View File

@@ -6,7 +6,7 @@ import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.ruoyi.chat.service.chat.UserModelService;
import org.ruoyi.chat.enums.DisplayType;
import org.ruoyi.common.excel.utils.ExcelUtil;
import org.ruoyi.common.idempotent.annotation.RepeatSubmit;
import org.ruoyi.core.page.TableDataInfo;
@@ -37,8 +37,6 @@ public class ChatModelController extends BaseController {
private final IChatModelService chatModelService;
private final UserModelService modelService;
/**
* 查询聊天模型列表
*/
@@ -53,7 +51,8 @@ public class ChatModelController extends BaseController {
*/
@GetMapping("/modelList")
public R<List<ChatModelVo>> modelList(ChatModelBo bo) {
return R.ok(modelService.modelList(bo));
bo.setModelShow(DisplayType.VISIBLE.getCode());
return R.ok(chatModelService.queryList(bo));
}
/**

View File

@@ -1,113 +0,0 @@
package org.ruoyi.chat.controller.chat;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.ruoyi.common.excel.utils.ExcelUtil;
import org.ruoyi.common.idempotent.annotation.RepeatSubmit;
import org.ruoyi.core.page.TableDataInfo;
import org.ruoyi.domain.bo.ChatPackagePlanBo;
import org.ruoyi.domain.vo.ChatPackagePlanVo;
import org.ruoyi.service.IChatPackagePlanService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.ruoyi.common.log.annotation.Log;
import org.ruoyi.common.web.core.BaseController;
import org.ruoyi.core.page.PageQuery;
import org.ruoyi.common.core.domain.R;
import org.ruoyi.common.core.validate.AddGroup;
import org.ruoyi.common.core.validate.EditGroup;
import org.ruoyi.common.log.enums.BusinessType;
/**
* 套餐管理
*
* @author ageerle
* @date 2025-04-08
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/packagePlan")
public class ChatPackagePlanController extends BaseController {
private final IChatPackagePlanService chatPackagePlanService;
/**
* 查询套餐管理列表
*/
@SaCheckPermission("system:packagePlan:list")
@GetMapping("/list")
public TableDataInfo<ChatPackagePlanVo> list(ChatPackagePlanBo bo, PageQuery pageQuery) {
return chatPackagePlanService.queryPageList(bo, pageQuery);
}
/**
* 查询套餐列表-不分页
*/
@GetMapping("/listPlan")
public R<List<ChatPackagePlanVo>> listPlan() {
return R.ok(chatPackagePlanService.queryList(new ChatPackagePlanBo()));
}
/**
* 导出套餐管理列表
*/
@SaCheckPermission("system:packagePlan:export")
@Log(title = "套餐管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(ChatPackagePlanBo bo, HttpServletResponse response) {
List<ChatPackagePlanVo> list = chatPackagePlanService.queryList(bo);
ExcelUtil.exportExcel(list, "套餐管理", ChatPackagePlanVo.class, response);
}
/**
* 获取套餐管理详细信息
*
* @param id 主键
*/
@SaCheckPermission("system:packagePlan:query")
@GetMapping("/{id}")
public R<ChatPackagePlanVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(chatPackagePlanService.queryById(id));
}
/**
* 新增套餐管理
*/
@SaCheckPermission("system:packagePlan:add")
@Log(title = "套餐管理", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody ChatPackagePlanBo bo) {
return toAjax(chatPackagePlanService.insertByBo(bo));
}
/**
* 修改套餐管理
*/
@SaCheckPermission("system:packagePlan:edit")
@Log(title = "套餐管理", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ChatPackagePlanBo bo) {
return toAjax(chatPackagePlanService.updateByBo(bo));
}
/**
* 删除套餐管理
*
* @param ids 主键串
*/
@SaCheckPermission("system:packagePlan:remove")
@Log(title = "套餐管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(chatPackagePlanService.deleteWithValidByIds(List.of(ids), true));
}
}

View File

@@ -1,105 +0,0 @@
package org.ruoyi.chat.controller.chat;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.ruoyi.common.excel.utils.ExcelUtil;
import org.ruoyi.common.idempotent.annotation.RepeatSubmit;
import org.ruoyi.core.page.TableDataInfo;
import org.ruoyi.domain.bo.ChatPluginBo;
import org.ruoyi.domain.vo.ChatPluginVo;
import org.ruoyi.service.IChatPluginService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.ruoyi.common.log.annotation.Log;
import org.ruoyi.common.web.core.BaseController;
import org.ruoyi.core.page.PageQuery;
import org.ruoyi.common.core.domain.R;
import org.ruoyi.common.core.validate.AddGroup;
import org.ruoyi.common.core.validate.EditGroup;
import org.ruoyi.common.log.enums.BusinessType;
/**
* 插件管理
*
* @author ageerle
* @date 2025-04-08
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/plugin")
public class ChatPluginController extends BaseController {
private final IChatPluginService chatPluginService;
/**
* 查询插件管理列表
*/
@SaCheckPermission("system:plugin:list")
@GetMapping("/list")
public TableDataInfo<ChatPluginVo> list(ChatPluginBo bo, PageQuery pageQuery) {
return chatPluginService.queryPageList(bo, pageQuery);
}
/**
* 导出插件管理列表
*/
@SaCheckPermission("system:plugin:export")
@Log(title = "插件管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(ChatPluginBo bo, HttpServletResponse response) {
List<ChatPluginVo> list = chatPluginService.queryList(bo);
ExcelUtil.exportExcel(list, "插件管理", ChatPluginVo.class, response);
}
/**
* 获取插件管理详细信息
*
* @param id 主键
*/
@SaCheckPermission("system:plugin:query")
@GetMapping("/{id}")
public R<ChatPluginVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(chatPluginService.queryById(id));
}
/**
* 新增插件管理
*/
@SaCheckPermission("system:plugin:add")
@Log(title = "插件管理", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody ChatPluginBo bo) {
return toAjax(chatPluginService.insertByBo(bo));
}
/**
* 修改插件管理
*/
@SaCheckPermission("system:plugin:edit")
@Log(title = "插件管理", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ChatPluginBo bo) {
return toAjax(chatPluginService.updateByBo(bo));
}
/**
* 删除插件管理
*
* @param ids 主键串
*/
@SaCheckPermission("system:plugin:remove")
@Log(title = "插件管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(chatPluginService.deleteWithValidByIds(List.of(ids), true));
}
}

View File

@@ -1,44 +0,0 @@
package org.ruoyi.chat.controller.chat;
import lombok.RequiredArgsConstructor;
import org.ruoyi.common.core.domain.R;
import org.ruoyi.common.web.core.BaseController;
import org.ruoyi.domain.bo.ChatAppStoreBo;
import org.ruoyi.domain.vo.ChatAppStoreVo;
import org.ruoyi.service.IChatAppStoreService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 应用商店
*
* @author Lion Li
* @date 2024-03-19
*/
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/store")
public class ChatStoreController extends BaseController {
private final IChatAppStoreService appStoreService;
/**
* 应用商店
*/
@GetMapping("/appList")
public R<List<ChatAppStoreVo>> appList(ChatAppStoreBo bo) {
return R.ok(appStoreService.queryList(bo));
}
/**
* 收藏应用
*/
@PostMapping("/copyApp")
public R<String> copyApp() {
return R.ok();
}
}

View File

@@ -1,104 +0,0 @@
package org.ruoyi.chat.controller.chat;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.ruoyi.common.idempotent.annotation.RepeatSubmit;
import org.ruoyi.core.page.TableDataInfo;
import org.ruoyi.domain.bo.ChatVoucherBo;
import org.ruoyi.domain.vo.ChatVoucherVo;
import org.ruoyi.service.IChatVoucherService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.ruoyi.common.log.annotation.Log;
import org.ruoyi.common.web.core.BaseController;
import org.ruoyi.core.page.PageQuery;
import org.ruoyi.common.core.domain.R;
import org.ruoyi.common.core.validate.AddGroup;
import org.ruoyi.common.core.validate.EditGroup;
import org.ruoyi.common.log.enums.BusinessType;
import org.ruoyi.common.excel.utils.ExcelUtil;
/**
* 用户兑换记录
*
* @author ageerle
* @date 2025-04-08
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/voucher")
public class ChatVoucherController extends BaseController {
private final IChatVoucherService chatVoucherService;
/**
* 查询用户兑换记录列表
*/
@SaCheckPermission("system:voucher:list")
@GetMapping("/list")
public TableDataInfo<ChatVoucherVo> list(ChatVoucherBo bo, PageQuery pageQuery) {
return chatVoucherService.queryPageList(bo, pageQuery);
}
/**
* 导出用户兑换记录列表
*/
@SaCheckPermission("system:voucher:export")
@Log(title = "用户兑换记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(ChatVoucherBo bo, HttpServletResponse response) {
List<ChatVoucherVo> list = chatVoucherService.queryList(bo);
ExcelUtil.exportExcel(list, "用户兑换记录", ChatVoucherVo.class, response);
}
/**
* 获取用户兑换记录详细信息
*
* @param id 主键
*/
@SaCheckPermission("system:voucher:query")
@GetMapping("/{id}")
public R<ChatVoucherVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(chatVoucherService.queryById(id));
}
/**
* 新增用户兑换记录
*/
@SaCheckPermission("system:voucher:add")
@Log(title = "用户兑换记录", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody ChatVoucherBo bo) {
return toAjax(chatVoucherService.insertByBo(bo));
}
/**
* 修改用户兑换记录
*/
@SaCheckPermission("system:voucher:edit")
@Log(title = "用户兑换记录", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ChatVoucherBo bo) {
return toAjax(chatVoucherService.updateByBo(bo));
}
/**
* 删除用户兑换记录
*
* @param ids 主键串
*/
@SaCheckPermission("system:voucher:remove")
@Log(title = "用户兑换记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(chatVoucherService.deleteWithValidByIds(List.of(ids), true));
}
}

View File

@@ -1,12 +1,9 @@
package org.ruoyi.chat.controller.knowledge;
import cn.dev33.satoken.stp.StpUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.io.IOException;
import lombok.RequiredArgsConstructor;
import org.ruoyi.common.core.domain.R;
import org.ruoyi.common.core.validate.AddGroup;
@@ -17,7 +14,6 @@ import org.ruoyi.common.satoken.utils.LoginHelper;
import org.ruoyi.common.web.core.BaseController;
import org.ruoyi.core.page.PageQuery;
import org.ruoyi.core.page.TableDataInfo;
import org.ruoyi.domain.PdfFileContentResult;
import org.ruoyi.domain.bo.KnowledgeAttachBo;
import org.ruoyi.domain.bo.KnowledgeFragmentBo;
import org.ruoyi.domain.bo.KnowledgeInfoBo;
@@ -28,7 +24,6 @@ import org.ruoyi.domain.vo.KnowledgeInfoVo;
import org.ruoyi.service.IKnowledgeAttachService;
import org.ruoyi.service.IKnowledgeFragmentService;
import org.ruoyi.service.IKnowledgeInfoService;
import org.ruoyi.service.PdfImageExtractService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -52,8 +47,6 @@ public class KnowledgeController extends BaseController {
private final IKnowledgeFragmentService fragmentService;
// private final PdfImageExtractService pdfImageExtractService;
/**
* 根据用户信息查询本地知识库
*/
@@ -164,17 +157,4 @@ public class KnowledgeController extends BaseController {
return attachService.translationByFile(file, targetLanguage);
}
/**
* 提取PDF中的图片并调用gpt-4o-mini,识别图片内容并返回
*
* @param file PDF文件
* @return 文件名称和图片内容
*/
// @PostMapping("/extract-images")
// @Operation(summary = "提取PDF中的图片并调用大模型,识别图片内容并返回", description = "提取PDF中的图片并调用gpt-4o-mini,识别图片内容并返回")
// public R<List<PdfFileContentResult>> extractImages(
// @RequestPart("file") MultipartFile file
// ) throws IOException {
// return R.ok(pdfImageExtractService.extractImages(file));
// }
}

View File

@@ -37,7 +37,7 @@ public class FaceController {
@PostMapping("/insight-face/swap")
public String insightFace(@RequestBody InsightFace insightFace) {
// 扣除接口费用并且保存消息记录
chatCostService.taskDeduct("mj","Face Changing", NumberUtils.toDouble(mjOkHttpUtil.getKey("faceSwapping"), 0.1));
chatCostService.taskDeduct("mj","Face Changing", 0.0);
// 创建请求体这里使用JSON作为媒体类型
String insightFaceJson = JSONUtil.toJsonStr(insightFace);
String url = "mj/insight-face/swap";

View File

@@ -6,7 +6,6 @@ import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import org.apache.commons.lang3.math.NumberUtils;
import org.ruoyi.chat.domain.dto.*;
import org.ruoyi.chat.enums.ActionType;
import org.ruoyi.chat.service.chat.IChatCostService;
@@ -50,17 +49,17 @@ public class SubmitController {
type -> {
switch (type) {
case UP_SAMPLE:
chatCostService.taskDeduct("mj","enlarge", NumberUtils.toDouble(mjOkHttpUtil.getKey("upsample"), 0.3));
chatCostService.taskDeduct("mj","enlarge", 0.0);
break;
case IN_PAINT:
// 局部重绘已经扣费,不执行任何操作
break;
default:
chatCostService.taskDeduct("mj","change", NumberUtils.toDouble(mjOkHttpUtil.getKey("change"), 0.3));
chatCostService.taskDeduct("mj","change", 0.0);
break;
}
},
() -> chatCostService.taskDeduct("mj","change", NumberUtils.toDouble(mjOkHttpUtil.getKey("change"), 0.3))
() -> chatCostService.taskDeduct("mj","change", 0.0)
);
String jsonStr = JSONUtil.toJsonStr(changeDTO);
@@ -81,7 +80,7 @@ public class SubmitController {
@ApiOperation(value = "提交图生图、混图任务")
@PostMapping("/blend")
public String blend(@RequestBody SubmitBlendDTO blendDTO) {
chatCostService.taskDeduct("mj","blend", NumberUtils.toDouble(mjOkHttpUtil.getKey("blend"), 0.3));
chatCostService.taskDeduct("mj","blend", 0.0);
String jsonStr = JSONUtil.toJsonStr(blendDTO);
String url = "mj/submit/blend";
Request request = mjOkHttpUtil.createPostRequest(url, jsonStr);
@@ -91,7 +90,7 @@ public class SubmitController {
@ApiOperation(value = "提交图生文任务")
@PostMapping("/describe")
public String describe(@RequestBody SubmitDescribeDTO describeDTO) {
chatCostService.taskDeduct("mj","describe", NumberUtils.toDouble(mjOkHttpUtil.getKey("describe"), 0.1));
chatCostService.taskDeduct("mj","describe",0.0);
String jsonStr = JSONUtil.toJsonStr(describeDTO);
String url = "mj/submit/describe";
Request request = mjOkHttpUtil.createPostRequest(url, jsonStr);
@@ -101,7 +100,7 @@ public class SubmitController {
@ApiOperation(value = "提交文生图任务")
@PostMapping("/imagine")
public String imagine(@RequestBody SubmitImagineDTO imagineDTO) {
chatCostService.taskDeduct("mj",imagineDTO.getPrompt(), NumberUtils.toDouble(mjOkHttpUtil.getKey("imagine"), 0.3));
chatCostService.taskDeduct("mj",imagineDTO.getPrompt(), 0.0);
String jsonStr = JSONUtil.toJsonStr(imagineDTO);
String url = "mj/submit/imagine";
Request request = mjOkHttpUtil.createPostRequest(url, jsonStr);
@@ -111,7 +110,7 @@ public class SubmitController {
@ApiOperation(value = "提交局部重绘任务")
@PostMapping("/modal")
public String modal(@RequestBody SubmitModalDTO submitModalDTO) {
chatCostService.taskDeduct("mj","repaint ", NumberUtils.toDouble(mjOkHttpUtil.getKey("inpaint"), 0.1));
chatCostService.taskDeduct("mj","repaint ", 0.0);
String jsonStr = JSONUtil.toJsonStr(submitModalDTO);
String url = "mj/submit/modal";
Request request = mjOkHttpUtil.createPostRequest(url, jsonStr);
@@ -121,7 +120,7 @@ public class SubmitController {
@ApiOperation(value = "提交提示词分析任务")
@PostMapping("/shorten")
public String shorten(@RequestBody SubmitShortenDTO submitShortenDTO) {
chatCostService.taskDeduct("mj","shorten", NumberUtils.toDouble(mjOkHttpUtil.getKey("shorten"), 0.1));
chatCostService.taskDeduct("mj","shorten", 0.0);
String jsonStr = JSONUtil.toJsonStr(submitShortenDTO);
String url = "mj/submit/shorten";
Request request = mjOkHttpUtil.createPostRequest(url, jsonStr);

View File

@@ -34,12 +34,19 @@ import java.util.Objects;
@Component
public class SSEEventSourceListener extends EventSourceListener {
private SseEmitter emitter;
private Long userId;
private Long sessionId;
@Autowired(required = false)
public SSEEventSourceListener(SseEmitter emitter) {
public SSEEventSourceListener(SseEmitter emitter,Long userId,Long sessionId) {
this.emitter = emitter;
this.userId = userId;
this.sessionId = sessionId;
}
private SseEmitter emitter;
private StringBuilder stringBuffer = new StringBuilder();
@@ -70,6 +77,8 @@ public class SSEEventSourceListener extends EventSourceListener {
// 设置对话角色
chatRequest.setRole(Message.Role.ASSISTANT.getName());
chatRequest.setModel(modelName);
chatRequest.setUserId(userId);
chatRequest.setSessionId(sessionId);
chatRequest.setPrompt(stringBuffer.toString());
chatCostService.deductToken(chatRequest);
return;

View File

@@ -1,30 +0,0 @@
package org.ruoyi.chat.service.chat;
import lombok.RequiredArgsConstructor;
import org.ruoyi.chat.enums.DisplayType;
import org.ruoyi.domain.bo.ChatModelBo;
import org.ruoyi.domain.vo.ChatModelVo;
import org.ruoyi.service.IChatModelService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 用户模型信息
*
* @author ageerle@163.com
* date 2025/4/10
*/
@Service
@RequiredArgsConstructor
public class UserModelService {
private final IChatModelService chatModelService;
public List<ChatModelVo> modelList(ChatModelBo bo) {
bo.setModelShow(DisplayType.VISIBLE.getCode());
return chatModelService.queryList(bo);
}
}

View File

@@ -13,7 +13,7 @@ import org.ruoyi.common.core.domain.model.LoginUser;
import org.ruoyi.common.core.exception.ServiceException;
import org.ruoyi.common.core.exception.base.BaseException;
import org.ruoyi.common.satoken.utils.LoginHelper;
import org.ruoyi.domain.ChatToken;
import org.ruoyi.domain.ChatUsageToken;
import org.ruoyi.domain.bo.ChatMessageBo;
import org.ruoyi.domain.vo.ChatModelVo;
import org.ruoyi.service.IChatMessageService;
@@ -48,6 +48,9 @@ public class ChatCostServiceImpl implements IChatCostService {
*/
@Override
public void deductToken(ChatRequest chatRequest) {
if(chatRequest.getUserId()==null || chatRequest.getSessionId()==null){
return;
}
int tokens = TikTokensUtil.tokens(chatRequest.getModel(), chatRequest.getPrompt());
@@ -55,24 +58,19 @@ public class ChatCostServiceImpl implements IChatCostService {
ChatMessageBo chatMessageBo = new ChatMessageBo();
if(chatRequest.getSessionId() == null){
Object sessionId = LocalCache.CACHE.get("sessionId");
chatRequest.setSessionId((Long) sessionId);
}
Object userId = LocalCache.CACHE.get("userId");
chatMessageBo.setUserId((Long) userId);
// 设置用户id
chatMessageBo.setUserId(chatRequest.getUserId());
// 设置对话角色
chatMessageBo.setRole(chatRequest.getRole());
// 设置会话id
chatMessageBo.setSessionId(chatRequest.getSessionId());
// 设置对话内容
chatMessageBo.setContent(chatRequest.getPrompt());
// 计算总token数
ChatToken chatToken = chatTokenService.queryByUserId(chatMessageBo.getUserId(), modelName);
ChatUsageToken chatToken = chatTokenService.queryByUserId(chatMessageBo.getUserId(), modelName);
if (chatToken == null) {
chatToken = new ChatToken();
chatToken = new ChatUsageToken();
chatToken.setToken(0);
}
int totalTokens = chatToken.getToken() + tokens;

View File

@@ -55,7 +55,7 @@ public class OpenAIServiceImpl implements IChatService {
Message userMessage = Message.builder().content("工具返回信息:"+toolString).role(Message.Role.USER).build();
messages.add(userMessage);
}
SSEEventSourceListener listener = new SSEEventSourceListener(emitter);
SSEEventSourceListener listener = new SSEEventSourceListener(emitter,chatRequest.getUserId(),chatRequest.getSessionId());
ChatCompletion completion = ChatCompletion
.builder()
.messages(messages)

View File

@@ -21,6 +21,7 @@ import org.ruoyi.common.core.utils.DateUtils;
import org.ruoyi.common.core.utils.StringUtils;
import org.ruoyi.common.core.utils.file.FileUtils;
import org.ruoyi.common.core.utils.file.MimeTypeUtils;
import org.ruoyi.common.satoken.utils.LoginHelper;
import org.ruoyi.domain.bo.ChatSessionBo;
import org.ruoyi.domain.bo.QueryVectorBo;
import org.ruoyi.domain.vo.ChatModelVo;
@@ -77,23 +78,22 @@ public class SseServiceImpl implements ISseService {
try {
// 构建消息列表
buildChatMessageList(chatRequest);
LocalCache.CACHE.put("userId", chatCostService.getUserId());
chatRequest.setUserId(chatCostService.getUserId());
// 保存会话信息
if(chatRequest.getSessionId()==null){
ChatSessionBo chatSessionBo = new ChatSessionBo();
chatSessionBo.setUserId(chatCostService.getUserId());
chatSessionBo.setSessionTitle(getFirst10Characters(chatRequest.getPrompt()));
chatSessionBo.setSessionContent(chatRequest.getPrompt());
chatSessionService.insertByBo(chatSessionBo);
chatRequest.setSessionId(chatSessionBo.getId());
}
LocalCache.CACHE.put("sessionId", chatRequest.getSessionId());
// 设置对话角色
chatRequest.setRole(Message.Role.USER.getName());
// 保存消息记录 并扣除费用
chatCostService.deductToken(chatRequest);
if(LoginHelper.isLogin()){
// 保存消息记录 并扣除费用
chatCostService.deductToken(chatRequest);
chatRequest.setUserId(chatCostService.getUserId());
if(chatRequest.getSessionId()==null){
ChatSessionBo chatSessionBo = new ChatSessionBo();
chatSessionBo.setUserId(chatCostService.getUserId());
chatSessionBo.setSessionTitle(getFirst10Characters(chatRequest.getPrompt()));
chatSessionBo.setSessionContent(chatRequest.getPrompt());
chatSessionService.insertByBo(chatSessionBo);
chatRequest.setSessionId(chatSessionBo.getId());
}
}
// 根据模型分类调用不同的处理逻辑
IChatService chatService = chatServiceFactory.getChatService(chatModelVo.getCategory());
chatService.chat(chatRequest, sseEmitter);