| | |
| | | package com.vincent.rsf.server.ai.controller; |
| | | |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.vincent.rsf.server.ai.dto.AiMcpToolTestRequest; |
| | | import com.vincent.rsf.server.ai.entity.AiMcpMount; |
| | | import com.vincent.rsf.server.ai.service.AiMcpMountService; |
| | |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<AiMcpMount, BaseParam> pageParam = new PageParam<>(baseParam, AiMcpMount.class); |
| | | return R.ok().add(aiMcpMountService.page(pageParam, pageParam.buildWrapper(true))); |
| | | return R.ok().add(aiMcpMountService.page(pageParam, pageParam.buildWrapper(true) |
| | | .eq("tenant_id", getTenantId()) |
| | | .eq("deleted", 0))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:aiMcpMount:list')") |
| | | @PostMapping("/aiMcpMount/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(aiMcpMountService.list()); |
| | | return R.ok().add(aiMcpMountService.list(new LambdaQueryWrapper<AiMcpMount>() |
| | | .eq(AiMcpMount::getTenantId, getTenantId()) |
| | | .eq(AiMcpMount::getDeleted, 0) |
| | | .orderByAsc(AiMcpMount::getSort) |
| | | .orderByDesc(AiMcpMount::getId))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:aiMcpMount:list')") |
| | | @PostMapping({"/aiMcpMount/many/{ids}", "/aiMcpMounts/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(aiMcpMountService.listByIds(Arrays.asList(ids))); |
| | | return R.ok().add(aiMcpMountService.list(new LambdaQueryWrapper<AiMcpMount>() |
| | | .eq(AiMcpMount::getTenantId, getTenantId()) |
| | | .eq(AiMcpMount::getDeleted, 0) |
| | | .in(AiMcpMount::getId, Arrays.asList(ids)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:aiMcpMount:list')") |
| | | @GetMapping("/aiMcpMount/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(aiMcpMountService.getById(id)); |
| | | return R.ok().add(aiMcpMountService.getOne(new LambdaQueryWrapper<AiMcpMount>() |
| | | .eq(AiMcpMount::getId, id) |
| | | .eq(AiMcpMount::getTenantId, getTenantId()) |
| | | .eq(AiMcpMount::getDeleted, 0) |
| | | .last("limit 1"))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:aiMcpMount:list')") |
| | | @GetMapping("/aiMcpMount/{id}/tools") |
| | | public R previewTools(@PathVariable("id") Long id) { |
| | | return R.ok().add(aiMcpMountService.previewTools(id, getLoginUserId(), getTenantId())); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:aiMcpMount:update')") |
| | | @PostMapping("/aiMcpMount/{id}/connectivity/test") |
| | | public R testConnectivity(@PathVariable("id") Long id) { |
| | | return R.ok().add(aiMcpMountService.testConnectivity(id, getLoginUserId(), getTenantId())); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:aiMcpMount:update')") |
| | |
| | | @OperationLog("Create AiMcpMount") |
| | | @PostMapping("/aiMcpMount/save") |
| | | public R save(@RequestBody AiMcpMount aiMcpMount) { |
| | | aiMcpMountService.validateBeforeSave(aiMcpMount); |
| | | aiMcpMount.setTenantId(getTenantId()); |
| | | aiMcpMountService.validateBeforeSave(aiMcpMount, getTenantId()); |
| | | aiMcpMount.setCreateBy(getLoginUserId()); |
| | | aiMcpMount.setCreateTime(new Date()); |
| | | aiMcpMount.setUpdateBy(getLoginUserId()); |
| | |
| | | @OperationLog("Update AiMcpMount") |
| | | @PostMapping("/aiMcpMount/update") |
| | | public R update(@RequestBody AiMcpMount aiMcpMount) { |
| | | aiMcpMountService.validateBeforeUpdate(aiMcpMount); |
| | | aiMcpMount.setTenantId(getTenantId()); |
| | | aiMcpMountService.validateBeforeUpdate(aiMcpMount, getTenantId()); |
| | | aiMcpMount.setUpdateBy(getLoginUserId()); |
| | | aiMcpMount.setUpdateTime(new Date()); |
| | | if (!aiMcpMountService.updateById(aiMcpMount)) { |
| | |
| | | @PreAuthorize("hasAuthority('system:aiMcpMount:list')") |
| | | @PostMapping("/aiMcpMount/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(aiMcpMountService.list(), AiMcpMount.class), response); |
| | | ExcelUtil.build(ExcelUtil.create(aiMcpMountService.list(new LambdaQueryWrapper<AiMcpMount>() |
| | | .eq(AiMcpMount::getTenantId, getTenantId()) |
| | | .eq(AiMcpMount::getDeleted, 0) |
| | | .orderByAsc(AiMcpMount::getSort) |
| | | .orderByDesc(AiMcpMount::getId)), AiMcpMount.class), response); |
| | | } |
| | | } |