mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-03-22 00:53:44 +08:00
fix: 重构模块
This commit is contained in:
@@ -2,7 +2,7 @@ package org.ruoyi.domain.bo;
|
||||
|
||||
import org.ruoyi.common.core.validate.AddGroup;
|
||||
import org.ruoyi.common.core.validate.EditGroup;
|
||||
import org.ruoyi.system.domain.ChatModel;
|
||||
import org.ruoyi.domain.ChatModel;
|
||||
import org.ruoyi.common.mybatis.core.domain.BaseEntity;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -52,4 +52,5 @@ public interface IChatModelService {
|
||||
* 通过模型名称获取模型信息
|
||||
*/
|
||||
ChatModelVo selectModelByName(String modelName);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
package org.ruoyi.service.impl;
|
||||
|
||||
import org.ruoyi.common.core.utils.MapstructUtils;
|
||||
import org.ruoyi.common.core.utils.StringUtils;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.ruoyi.service.IChatConfigService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 配置信息Service业务层处理
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-04-08
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ChatConfigServiceImpl implements IChatConfigService {
|
||||
|
||||
private final ChatConfigMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询配置信息
|
||||
*/
|
||||
@Override
|
||||
public ChatConfigVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配置信息列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<ChatConfigVo> queryPageList(ChatConfigBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<ChatConfig> lqw = buildQueryWrapper(bo);
|
||||
Page<ChatConfigVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配置信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<ChatConfigVo> queryList(ChatConfigBo bo) {
|
||||
LambdaQueryWrapper<ChatConfig> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<ChatConfig> buildQueryWrapper(ChatConfigBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<ChatConfig> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getCategory()), ChatConfig::getCategory, bo.getCategory());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getConfigName()), ChatConfig::getConfigName, bo.getConfigName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getConfigValue()), ChatConfig::getConfigValue, bo.getConfigValue());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getConfigDict()), ChatConfig::getConfigDict, bo.getConfigDict());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getUpdateIp()), ChatConfig::getUpdateIp, bo.getUpdateIp());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配置信息
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(ChatConfigBo bo) {
|
||||
ChatConfig add = MapstructUtils.convert(bo, ChatConfig.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改配置信息
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(ChatConfigBo bo) {
|
||||
ChatConfig update = MapstructUtils.convert(bo, ChatConfig.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(ChatConfig entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除配置信息
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,7 @@ import org.ruoyi.service.IChatModelService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 聊天模型Service业务层处理
|
||||
@@ -32,6 +30,7 @@ public class ChatModelServiceImpl implements IChatModelService {
|
||||
|
||||
private final ChatModelMapper baseMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 查询聊天模型
|
||||
*/
|
||||
@@ -123,4 +122,6 @@ public class ChatModelServiceImpl implements IChatModelService {
|
||||
public ChatModelVo selectModelByName(String modelName) {
|
||||
return baseMapper.selectVoOne(Wrappers.<ChatModel>lambdaQuery().eq(ChatModel::getModelName, modelName));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package org.ruoyi.service;
|
||||
package org.ruoyi.system.service;
|
||||
|
||||
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.system.domain.bo.ChatConfigBo;
|
||||
import org.ruoyi.system.domain.vo.ChatConfigVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -2,15 +2,24 @@ package org.ruoyi.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.ruoyi.common.core.service.ConfigService;
|
||||
import org.ruoyi.common.core.utils.MapstructUtils;
|
||||
import org.ruoyi.common.core.utils.StringUtils;
|
||||
import org.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.system.domain.ChatConfig;
|
||||
import org.ruoyi.system.domain.bo.ChatConfigBo;
|
||||
import org.ruoyi.system.domain.vo.ChatConfigVo;
|
||||
import org.ruoyi.system.mapper.ChatConfigMapper;
|
||||
import org.ruoyi.system.service.IChatConfigService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 配置信息Service业务层处理
|
||||
@@ -20,7 +29,7 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ChatConfigServiceImpl implements ConfigService {
|
||||
public class ChatConfigServiceImpl implements ConfigService, IChatConfigService {
|
||||
|
||||
private final ChatConfigMapper baseMapper;
|
||||
|
||||
@@ -41,11 +50,83 @@ public class ChatConfigServiceImpl implements ConfigService {
|
||||
return chatConfigVo.getConfigValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配置信息
|
||||
*/
|
||||
@Override
|
||||
public ChatConfigVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配置信息列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<ChatConfigVo> queryPageList(ChatConfigBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<ChatConfig> lqw = buildQueryWrapper(bo);
|
||||
Page<ChatConfigVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配置信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<ChatConfigVo> queryList(ChatConfigBo bo) {
|
||||
LambdaQueryWrapper<ChatConfig> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<ChatConfig> buildQueryWrapper(ChatConfigBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<ChatConfig> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getCategory()), ChatConfig::getCategory, bo.getCategory());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getConfigName()), ChatConfig::getConfigName, bo.getConfigName());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getConfigName()), ChatConfig::getConfigName, bo.getConfigName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getConfigValue()), ChatConfig::getConfigValue, bo.getConfigValue());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getConfigDict()), ChatConfig::getConfigDict, bo.getConfigDict());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配置信息
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(ChatConfigBo bo) {
|
||||
ChatConfig add = MapstructUtils.convert(bo, ChatConfig.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改配置信息
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(ChatConfigBo bo) {
|
||||
ChatConfig update = MapstructUtils.convert(bo, ChatConfig.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(ChatConfig entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除配置信息
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,4 +24,16 @@
|
||||
<module>ruoyi-generator</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-idempotent</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -109,6 +109,11 @@
|
||||
<artifactId>ruoyi-chat-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.ruoyi</groupId>
|
||||
<artifactId>ruoyi-system-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.ruoyi.chat.controller;
|
||||
package org.ruoyi.chat.controller.api;
|
||||
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.ruoyi.chat.controller;
|
||||
package org.ruoyi.chat.controller.api;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.ruoyi.chat.controller;
|
||||
package org.ruoyi.chat.controller.api;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.ruoyi.chat.controller;
|
||||
package org.ruoyi.chat.controller.api;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.ruoyi.chat.controller;
|
||||
package org.ruoyi.chat.controller.api;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.ruoyi.chat.controller;
|
||||
package org.ruoyi.chat.controller.api;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -0,0 +1,105 @@
|
||||
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.common.web.core.BaseController;
|
||||
import org.ruoyi.domain.bo.ChatAgentManageBo;
|
||||
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.common.mybatis.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.system.domain.vo.ChatAgentManageVo;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 智能体管理
|
||||
*
|
||||
* @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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
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.domain.bo.ChatAppStoreBo;
|
||||
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.common.mybatis.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.system.domain.vo.ChatAppStoreVo;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 应用商店
|
||||
*
|
||||
* @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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
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.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.system.domain.bo.ChatConfigBo;
|
||||
import org.ruoyi.system.domain.vo.ChatConfigVo;
|
||||
import org.ruoyi.system.service.IChatConfigService;
|
||||
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.common.mybatis.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/config")
|
||||
public class ChatConfigController extends BaseController {
|
||||
|
||||
private final IChatConfigService chatConfigService;
|
||||
|
||||
/**
|
||||
* 查询配置信息列表
|
||||
*/
|
||||
@SaCheckPermission("system:config:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<ChatConfigVo> list(ChatConfigBo bo, PageQuery pageQuery) {
|
||||
return chatConfigService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出配置信息列表
|
||||
*/
|
||||
@SaCheckPermission("system:config:export")
|
||||
@Log(title = "配置信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(ChatConfigBo bo, HttpServletResponse response) {
|
||||
List<ChatConfigVo> list = chatConfigService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "配置信息", ChatConfigVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置信息详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system:config:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<ChatConfigVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(chatConfigService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配置信息
|
||||
*/
|
||||
@SaCheckPermission("system:config:add")
|
||||
@Log(title = "配置信息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ChatConfigBo bo) {
|
||||
return toAjax(chatConfigService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改配置信息
|
||||
*/
|
||||
@SaCheckPermission("system:config:edit")
|
||||
@Log(title = "配置信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ChatConfigBo bo) {
|
||||
return toAjax(chatConfigService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配置信息
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("system:config:remove")
|
||||
@Log(title = "配置信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(chatConfigService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
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.common.mybatis.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.common.mybatis.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;
|
||||
|
||||
/**
|
||||
* 查询应用管理列表
|
||||
*/
|
||||
@SaCheckPermission("system:gpts:list")
|
||||
@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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
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.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.domain.bo.ChatMessageBo;
|
||||
import org.ruoyi.domain.vo.ChatMessageVo;
|
||||
import org.ruoyi.service.IChatMessageService;
|
||||
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.common.mybatis.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/message")
|
||||
public class ChatMessageController extends BaseController {
|
||||
|
||||
private final IChatMessageService chatMessageService;
|
||||
|
||||
/**
|
||||
* 查询聊天消息列表
|
||||
*/
|
||||
@SaCheckPermission("system:message:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<ChatMessageVo> list(ChatMessageBo bo, PageQuery pageQuery) {
|
||||
return chatMessageService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出聊天消息列表
|
||||
*/
|
||||
@SaCheckPermission("system:message:export")
|
||||
@Log(title = "聊天消息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(ChatMessageBo bo, HttpServletResponse response) {
|
||||
List<ChatMessageVo> list = chatMessageService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "聊天消息", ChatMessageVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取聊天消息详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system:message:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<ChatMessageVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(chatMessageService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增聊天消息
|
||||
*/
|
||||
@SaCheckPermission("system:message:add")
|
||||
@Log(title = "聊天消息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ChatMessageBo bo) {
|
||||
return toAjax(chatMessageService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改聊天消息
|
||||
*/
|
||||
@SaCheckPermission("system:message:edit")
|
||||
@Log(title = "聊天消息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ChatMessageBo bo) {
|
||||
return toAjax(chatMessageService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除聊天消息
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("system:message:remove")
|
||||
@Log(title = "聊天消息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(chatMessageService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
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.chat.service.chat.UserModelService;
|
||||
import org.ruoyi.common.excel.utils.ExcelUtil;
|
||||
import org.ruoyi.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.domain.bo.ChatModelBo;
|
||||
import org.ruoyi.domain.vo.ChatModelVo;
|
||||
import org.ruoyi.service.IChatModelService;
|
||||
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.common.mybatis.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/model")
|
||||
public class ChatModelController extends BaseController {
|
||||
|
||||
private final IChatModelService chatModelService;
|
||||
|
||||
private final UserModelService modelService;
|
||||
|
||||
/**
|
||||
* 查询聊天模型列表
|
||||
*/
|
||||
@SaCheckPermission("system:model:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<ChatModelVo> list(ChatModelBo bo, PageQuery pageQuery) {
|
||||
return chatModelService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户模型列表
|
||||
*/
|
||||
@GetMapping("/modelList")
|
||||
public R<List<ChatModelVo>> modelList(ChatModelBo bo) {
|
||||
return R.ok(modelService.modelList(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出聊天模型列表
|
||||
*/
|
||||
@SaCheckPermission("system:model:export")
|
||||
@Log(title = "聊天模型", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(ChatModelBo bo, HttpServletResponse response) {
|
||||
List<ChatModelVo> list = chatModelService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "聊天模型", ChatModelVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取聊天模型详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system:model:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<ChatModelVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(chatModelService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增聊天模型
|
||||
*/
|
||||
@SaCheckPermission("system:model:add")
|
||||
@Log(title = "聊天模型", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ChatModelBo bo) {
|
||||
return toAjax(chatModelService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改聊天模型
|
||||
*/
|
||||
@SaCheckPermission("system:model:edit")
|
||||
@Log(title = "聊天模型", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ChatModelBo bo) {
|
||||
return toAjax(chatModelService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除聊天模型
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("system:model:remove")
|
||||
@Log(title = "聊天模型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(chatModelService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
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.common.mybatis.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.common.mybatis.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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出套餐管理列表
|
||||
*/
|
||||
@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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
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.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.domain.bo.ChatPayOrderBo;
|
||||
import org.ruoyi.domain.vo.ChatPayOrderVo;
|
||||
import org.ruoyi.service.IChatPayOrderService;
|
||||
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.common.mybatis.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/payOrder")
|
||||
public class ChatPayOrderController extends BaseController {
|
||||
|
||||
private final IChatPayOrderService chatPayOrderService;
|
||||
|
||||
/**
|
||||
* 查询支付订单列表
|
||||
*/
|
||||
@SaCheckPermission("system:payOrder:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<ChatPayOrderVo> list(ChatPayOrderBo bo, PageQuery pageQuery) {
|
||||
return chatPayOrderService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出支付订单列表
|
||||
*/
|
||||
@SaCheckPermission("system:payOrder:export")
|
||||
@Log(title = "支付订单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(ChatPayOrderBo bo, HttpServletResponse response) {
|
||||
List<ChatPayOrderVo> list = chatPayOrderService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "支付订单", ChatPayOrderVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付订单详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system:payOrder:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<ChatPayOrderVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(chatPayOrderService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增支付订单
|
||||
*/
|
||||
@SaCheckPermission("system:payOrder:add")
|
||||
@Log(title = "支付订单", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ChatPayOrderBo bo) {
|
||||
return toAjax(chatPayOrderService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改支付订单
|
||||
*/
|
||||
@SaCheckPermission("system:payOrder:edit")
|
||||
@Log(title = "支付订单", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ChatPayOrderBo bo) {
|
||||
return toAjax(chatPayOrderService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除支付订单
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("system:payOrder:remove")
|
||||
@Log(title = "支付订单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(chatPayOrderService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
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.common.mybatis.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.common.mybatis.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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
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.common.mybatis.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.common.mybatis.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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.ruoyi.chat.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author ageerle@163.com
|
||||
* date 2025/4/10
|
||||
*/
|
||||
@Getter
|
||||
public enum DisplayType {
|
||||
HIDDEN("1", "不显示"),
|
||||
VISIBLE("0", "显示");
|
||||
|
||||
private final String code;
|
||||
private final String description;
|
||||
|
||||
DisplayType(String code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public static DisplayType fromCode(String code) {
|
||||
for (DisplayType type : values()) {
|
||||
if (type.getCode().equals(code)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,13 @@ package org.ruoyi.chat.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author ageer
|
||||
*/
|
||||
@Getter
|
||||
public enum UserGradeType {
|
||||
UNPAID("0", "未付费"), // 未付费用户
|
||||
PAID("1", "已付费"); // 已付费用户
|
||||
UNPAID("0", "未付费"),
|
||||
PAID("1", "已付费");
|
||||
|
||||
private final String code;
|
||||
private final String description;
|
||||
@@ -24,11 +27,4 @@ public enum UserGradeType {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.ruoyi.chat.service.chat;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.ruoyi.chat.enums.DisplayType;
|
||||
import org.ruoyi.chat.enums.UserGradeType;
|
||||
import org.ruoyi.common.satoken.utils.LoginHelper;
|
||||
import org.ruoyi.domain.bo.ChatModelBo;
|
||||
import org.ruoyi.domain.bo.ChatPackagePlanBo;
|
||||
import org.ruoyi.domain.vo.ChatModelVo;
|
||||
import org.ruoyi.domain.vo.ChatPackagePlanVo;
|
||||
import org.ruoyi.service.IChatModelService;
|
||||
import org.ruoyi.service.IChatPackagePlanService;
|
||||
import org.ruoyi.system.domain.vo.SysUserVo;
|
||||
import org.ruoyi.system.service.ISysUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:用户模型信息
|
||||
*
|
||||
* @author ageerle@163.com
|
||||
* date 2025/4/10
|
||||
*/
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserModelService {
|
||||
|
||||
private final IChatModelService chatModelService;
|
||||
|
||||
private final ISysUserService userService;
|
||||
|
||||
private final IChatPackagePlanService packagePlanService;
|
||||
|
||||
public List<ChatModelVo> modelList(ChatModelBo bo) {
|
||||
bo.setModelShow(DisplayType.VISIBLE.getCode());
|
||||
List<ChatModelVo> chatModelList = chatModelService.queryList(bo);
|
||||
ChatPackagePlanBo sysPackagePlanBo = new ChatPackagePlanBo();
|
||||
if (StpUtil.isLogin()) {
|
||||
Long userId = LoginHelper.getLoginUser().getUserId();
|
||||
SysUserVo sysUserVo = userService.selectUserById(userId);
|
||||
if (UserGradeType.UNPAID.getCode().equals(sysUserVo.getUserGrade())){
|
||||
sysPackagePlanBo.setName("Free");
|
||||
ChatPackagePlanVo chatPackagePlanVo = packagePlanService.queryList(sysPackagePlanBo).get(0);
|
||||
List<String> array = new ArrayList<>(Arrays.asList(chatPackagePlanVo.getPlanDetail().split(",")));
|
||||
chatModelList.removeIf(model -> !array.contains(model.getModelName()));
|
||||
}
|
||||
}else {
|
||||
sysPackagePlanBo.setName("Visitor");
|
||||
ChatPackagePlanVo sysPackagePlanVo = packagePlanService.queryList(sysPackagePlanBo).get(0);
|
||||
List<String> array = new ArrayList<>(Arrays.asList(sysPackagePlanVo.getPlanDetail().split(",")));
|
||||
chatModelList.removeIf(model -> !array.contains(model.getModelName()));
|
||||
}
|
||||
return new ArrayList<>(chatModelList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.ruoyi.chat.enums.BillingType;
|
||||
import org.ruoyi.chat.enums.UserGradeType;
|
||||
import org.ruoyi.chat.service.chat.IChatCostService;
|
||||
import org.ruoyi.common.chat.domain.request.ChatRequest;
|
||||
import org.ruoyi.common.chat.request.ChatRequest;
|
||||
import org.ruoyi.common.chat.utils.TikTokensUtil;
|
||||
import org.ruoyi.common.core.domain.model.LoginUser;
|
||||
import org.ruoyi.common.core.exception.ServiceException;
|
||||
|
||||
Reference in New Issue
Block a user