mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-04 15:27:32 +00:00
feat: 1. 调整项目结构 2.增加插件管理
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
package org.ruoyi.system.controller.system;
|
||||
|
||||
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.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.ChatPluginVo;
|
||||
import org.ruoyi.system.domain.bo.ChatPluginBo;
|
||||
import org.ruoyi.system.service.IChatPluginService;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 插件管理
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-03-30
|
||||
*/
|
||||
@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));
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/orders")
|
||||
@RequestMapping("/system/payOrder")
|
||||
public class PaymentOrdersController extends BaseController {
|
||||
|
||||
private final IPaymentOrdersService paymentOrdersService;
|
||||
@@ -40,7 +40,7 @@ public class PaymentOrdersController extends BaseController {
|
||||
/**
|
||||
* 查询支付订单列表
|
||||
*/
|
||||
@SaCheckPermission("system:orders:list")
|
||||
@SaCheckPermission("system:order:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<PaymentOrdersVo> list(PaymentOrdersBo bo, PageQuery pageQuery) {
|
||||
pageQuery.setOrderByColumn("createTime");
|
||||
@@ -51,7 +51,7 @@ public class PaymentOrdersController extends BaseController {
|
||||
/**
|
||||
* 导出支付订单列表
|
||||
*/
|
||||
@SaCheckPermission("system:orders:export")
|
||||
@SaCheckPermission("system:order:export")
|
||||
@Log(title = "支付订单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(PaymentOrdersBo bo, HttpServletResponse response) {
|
||||
@@ -64,7 +64,7 @@ public class PaymentOrdersController extends BaseController {
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system:orders:query")
|
||||
@SaCheckPermission("system:order:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<PaymentOrdersVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
@@ -74,7 +74,7 @@ public class PaymentOrdersController extends BaseController {
|
||||
/**
|
||||
* 新增支付订单
|
||||
*/
|
||||
@SaCheckPermission("system:orders:add")
|
||||
@SaCheckPermission("system:order:add")
|
||||
@Log(title = "支付订单", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
@@ -85,7 +85,7 @@ public class PaymentOrdersController extends BaseController {
|
||||
/**
|
||||
* 修改支付订单
|
||||
*/
|
||||
@SaCheckPermission("system:orders:edit")
|
||||
@SaCheckPermission("system:order:edit")
|
||||
@Log(title = "支付订单", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
@@ -98,7 +98,7 @@ public class PaymentOrdersController extends BaseController {
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("system:orders:remove")
|
||||
@SaCheckPermission("system:order:remove")
|
||||
@Log(title = "支付订单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.ruoyi.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.ruoyi.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 插件管理对象 chat_plugin
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-03-30
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("chat_plugin")
|
||||
public class ChatPlugin extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 插件名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 插件编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.ruoyi.system.domain;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
@@ -28,6 +29,12 @@ public class SysModel extends BaseEntity {
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 模型分类
|
||||
*/
|
||||
@ExcelProperty(value = "模型分类")
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.ruoyi.system.domain.bo;
|
||||
|
||||
import org.ruoyi.common.core.validate.AddGroup;
|
||||
import org.ruoyi.common.core.validate.EditGroup;
|
||||
import org.ruoyi.system.domain.ChatPlugin;
|
||||
import org.ruoyi.common.mybatis.core.domain.BaseEntity;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 插件管理业务对象 chat_plugin
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-03-30
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = ChatPlugin.class, reverseConvertGenerate = false)
|
||||
public class ChatPluginBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "主键不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 插件名称
|
||||
*/
|
||||
@NotBlank(message = "插件名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 插件编码
|
||||
*/
|
||||
@NotBlank(message = "插件编码不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.ruoyi.system.domain.bo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@@ -27,6 +28,12 @@ public class SysModelBo extends BaseEntity {
|
||||
@NotNull(message = "主键不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 模型分类
|
||||
*/
|
||||
@ExcelProperty(value = "模型分类")
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.ruoyi.system.domain.vo;
|
||||
|
||||
import org.ruoyi.system.domain.ChatPlugin;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 插件管理视图对象 chat_plugin
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-03-30
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = ChatPlugin.class)
|
||||
public class ChatPluginVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ExcelProperty(value = "主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 插件名称
|
||||
*/
|
||||
@ExcelProperty(value = "插件名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 插件编码
|
||||
*/
|
||||
@ExcelProperty(value = "插件编码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -11,5 +11,7 @@ import org.ruoyi.common.core.domain.model.LoginUser;
|
||||
@Data
|
||||
public class LoginVo {
|
||||
private String token;
|
||||
// 兼容新版后台管理系统
|
||||
private String access_token;
|
||||
private LoginUser userInfo;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,12 @@ public class SysModelVo implements Serializable {
|
||||
@ExcelProperty(value = "主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 模型分类
|
||||
*/
|
||||
@ExcelProperty(value = "模型分类")
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.ruoyi.system.mapper;
|
||||
|
||||
import org.ruoyi.system.domain.ChatPlugin;
|
||||
import org.ruoyi.system.domain.vo.ChatPluginVo;
|
||||
import org.ruoyi.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 插件管理Mapper接口
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-03-30
|
||||
*/
|
||||
public interface ChatPluginMapper extends BaseMapperPlus<ChatPlugin, ChatPluginVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.ruoyi.system.service;
|
||||
|
||||
import org.ruoyi.system.domain.ChatPlugin;
|
||||
import org.ruoyi.system.domain.vo.ChatPluginVo;
|
||||
import org.ruoyi.system.domain.bo.ChatPluginBo;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 插件管理Service接口
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-03-30
|
||||
*/
|
||||
public interface IChatPluginService {
|
||||
|
||||
/**
|
||||
* 查询插件管理
|
||||
*/
|
||||
ChatPluginVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询插件管理列表
|
||||
*/
|
||||
TableDataInfo<ChatPluginVo> queryPageList(ChatPluginBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询插件管理列表
|
||||
*/
|
||||
List<ChatPluginVo> queryList(ChatPluginBo bo);
|
||||
|
||||
/**
|
||||
* 新增插件管理
|
||||
*/
|
||||
Boolean insertByBo(ChatPluginBo bo);
|
||||
|
||||
/**
|
||||
* 修改插件管理
|
||||
*/
|
||||
Boolean updateByBo(ChatPluginBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除插件管理信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package org.ruoyi.system.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.springframework.stereotype.Service;
|
||||
import org.ruoyi.system.domain.bo.ChatPluginBo;
|
||||
import org.ruoyi.system.domain.vo.ChatPluginVo;
|
||||
import org.ruoyi.system.domain.ChatPlugin;
|
||||
import org.ruoyi.system.mapper.ChatPluginMapper;
|
||||
import org.ruoyi.system.service.IChatPluginService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 插件管理Service业务层处理
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-03-30
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ChatPluginServiceImpl implements IChatPluginService {
|
||||
|
||||
private final ChatPluginMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询插件管理
|
||||
*/
|
||||
@Override
|
||||
public ChatPluginVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询插件管理列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<ChatPluginVo> queryPageList(ChatPluginBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<ChatPlugin> lqw = buildQueryWrapper(bo);
|
||||
Page<ChatPluginVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询插件管理列表
|
||||
*/
|
||||
@Override
|
||||
public List<ChatPluginVo> queryList(ChatPluginBo bo) {
|
||||
LambdaQueryWrapper<ChatPlugin> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<ChatPlugin> buildQueryWrapper(ChatPluginBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<ChatPlugin> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getName()), ChatPlugin::getName, bo.getName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getCode()), ChatPlugin::getCode, bo.getCode());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增插件管理
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(ChatPluginBo bo) {
|
||||
ChatPlugin add = MapstructUtils.convert(bo, ChatPlugin.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改插件管理
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(ChatPluginBo bo) {
|
||||
ChatPlugin update = MapstructUtils.convert(bo, ChatPlugin.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(ChatPlugin entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除插件管理
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user