mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-09 09:47:32 +00:00
mcp 信息 增删改查 完成
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
package org.ruoyi.mcp.controller;
|
||||
|
||||
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.domain.bo.McpInfoBo;
|
||||
import org.ruoyi.domain.vo.McpInfoVo;
|
||||
import org.ruoyi.mcp.service.McpInfoService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.ruoyi.common.idempotent.annotation.RepeatSubmit;
|
||||
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;
|
||||
|
||||
import org.ruoyi.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* MCP
|
||||
*
|
||||
* @author ageerle
|
||||
* @date Sat Aug 09 16:50:58 CST 2025
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/operator/mcpInfo")
|
||||
public class McpInfoController extends BaseController {
|
||||
|
||||
private final McpInfoService mcpInfoService;
|
||||
|
||||
/**
|
||||
* 查询MCP列表
|
||||
*/
|
||||
@SaCheckPermission("operator:mcpInfo:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<McpInfoVo> list(McpInfoBo bo, PageQuery pageQuery) {
|
||||
return mcpInfoService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出MCP列表
|
||||
*/
|
||||
@SaCheckPermission("operator:mcpInfo:export")
|
||||
@Log(title = "MCP", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(McpInfoBo bo, HttpServletResponse response) {
|
||||
List<McpInfoVo> list = mcpInfoService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "MCP", McpInfoVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取MCP详细信息
|
||||
*
|
||||
* @param mcpId 主键
|
||||
*/
|
||||
@SaCheckPermission("operator:mcpInfo:query")
|
||||
@GetMapping("/{mcpId}")
|
||||
public R<McpInfoVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Integer mcpId) {
|
||||
return R.ok(mcpInfoService.queryById(mcpId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增MCP
|
||||
*/
|
||||
@SaCheckPermission("operator:mcpInfo:add")
|
||||
@Log(title = "MCP", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody McpInfoBo bo) {
|
||||
return toAjax(mcpInfoService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改MCP
|
||||
*/
|
||||
@SaCheckPermission("operator:mcpInfo:edit")
|
||||
@Log(title = "MCP", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody McpInfoBo bo) {
|
||||
return toAjax(mcpInfoService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除MCP
|
||||
*
|
||||
* @param mcpIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("operator:mcpInfo:remove")
|
||||
@Log(title = "MCP", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{mcpIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Integer[] mcpIds) {
|
||||
return toAjax(mcpInfoService.deleteWithValidByIds(List.of(mcpIds), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.ruoyi.mcp.service;
|
||||
|
||||
import org.ruoyi.core.page.TableDataInfo;
|
||||
import org.ruoyi.core.page.PageQuery;
|
||||
import org.ruoyi.domain.bo.McpInfoBo;
|
||||
import org.ruoyi.domain.vo.McpInfoVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* MCPService接口
|
||||
*
|
||||
* @author ageerle
|
||||
* @date Sat Aug 09 16:50:58 CST 2025
|
||||
*/
|
||||
public interface McpInfoService {
|
||||
|
||||
/**
|
||||
* 查询MCP
|
||||
*/
|
||||
McpInfoVo queryById(Integer mcpId);
|
||||
|
||||
/**
|
||||
* 查询MCP列表
|
||||
*/
|
||||
TableDataInfo<McpInfoVo> queryPageList(McpInfoBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询MCP列表
|
||||
*/
|
||||
List<McpInfoVo> queryList(McpInfoBo bo);
|
||||
|
||||
/**
|
||||
* 新增MCP
|
||||
*/
|
||||
Boolean insertByBo(McpInfoBo bo);
|
||||
|
||||
/**
|
||||
* 修改MCP
|
||||
*/
|
||||
Boolean updateByBo(McpInfoBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除MCP信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Integer> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package org.ruoyi.mcp.service.impl;
|
||||
|
||||
import org.ruoyi.common.core.utils.MapstructUtils;
|
||||
import org.ruoyi.core.page.TableDataInfo;
|
||||
import org.ruoyi.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.domain.McpInfo;
|
||||
import org.ruoyi.domain.bo.McpInfoBo;
|
||||
import org.ruoyi.domain.vo.McpInfoVo;
|
||||
import org.ruoyi.mapper.McpInfoMapper;
|
||||
import org.ruoyi.mcp.service.McpInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import org.ruoyi.common.core.utils.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* MCPService业务层处理
|
||||
*
|
||||
* @author ageerle
|
||||
* @date Sat Aug 09 16:50:58 CST 2025
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class McpInfoServiceImpl implements McpInfoService {
|
||||
|
||||
private final McpInfoMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询MCP
|
||||
*/
|
||||
@Override
|
||||
public McpInfoVo queryById(Integer mcpId) {
|
||||
return baseMapper.selectVoById(mcpId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询MCP列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<McpInfoVo> queryPageList(McpInfoBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<McpInfo> lqw = buildQueryWrapper(bo);
|
||||
Page<McpInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询MCP列表
|
||||
*/
|
||||
@Override
|
||||
public List<McpInfoVo> queryList(McpInfoBo bo) {
|
||||
LambdaQueryWrapper<McpInfo> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<McpInfo> buildQueryWrapper(McpInfoBo bo) {
|
||||
LambdaQueryWrapper<McpInfo> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getServerName()), McpInfo::getServerName, bo.getServerName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getTransportType()), McpInfo::getTransportType, bo.getTransportType());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getCommand()), McpInfo::getCommand, bo.getCommand());
|
||||
lqw.eq(bo.getStatus() != null, McpInfo::getStatus, bo.getStatus());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增MCP
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(McpInfoBo bo) {
|
||||
McpInfo add = MapstructUtils.convert(bo, McpInfo. class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setMcpId(add.getMcpId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改MCP
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(McpInfoBo bo) {
|
||||
McpInfo update = MapstructUtils.convert(bo, McpInfo. class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(McpInfo entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除MCP
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Integer> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user