refactor(video): 移除设备和巡检任务接口权限注解并调整模型控制器包结构
- 移除了 DeviceController 中所有方法的 @PreAuthorize 权限注解 - 移除了 InspectionTaskController 中所有方法的 @PreAuthorize 权限注解 - 将 ModelController 从 ruoyi-admin 模块迁移至 ruoyi-video 模块- 调整 ModelController 包路径并继承 BaseController-为 ModelController 的各个接口添加了相应的权限注解- 修改 list 方法返回类型为 TableDataInfo 并支持分页查询- 引入缺失的类依赖和安全注解支持
This commit is contained in:
@@ -32,7 +32,6 @@ public class InspectionTaskController extends BaseController {
|
||||
/**
|
||||
* 查询巡检任务列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:inspection:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(InspectionTask inspectionTask) {
|
||||
startPage();
|
||||
@@ -43,7 +42,6 @@ public class InspectionTaskController extends BaseController {
|
||||
/**
|
||||
* 导出巡检任务列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:inspection:export')")
|
||||
@Log(title = "巡检任务", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, InspectionTask inspectionTask) {
|
||||
@@ -55,7 +53,6 @@ public class InspectionTaskController extends BaseController {
|
||||
/**
|
||||
* 获取巡检任务详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:inspection:query')")
|
||||
@GetMapping(value = "/{taskId}")
|
||||
public AjaxResult getInfo(@PathVariable("taskId") Long taskId) {
|
||||
return success(inspectionTaskService.selectInspectionTaskById(taskId));
|
||||
@@ -64,7 +61,6 @@ public class InspectionTaskController extends BaseController {
|
||||
/**
|
||||
* 新增巡检任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:inspection:add')")
|
||||
@Log(title = "巡检任务", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody InspectionTask inspectionTask) {
|
||||
@@ -74,7 +70,6 @@ public class InspectionTaskController extends BaseController {
|
||||
/**
|
||||
* 修改巡检任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:inspection:edit')")
|
||||
@Log(title = "巡检任务", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody InspectionTask inspectionTask) {
|
||||
@@ -84,7 +79,6 @@ public class InspectionTaskController extends BaseController {
|
||||
/**
|
||||
* 删除巡检任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:inspection:remove')")
|
||||
@Log(title = "巡检任务", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{taskIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] taskIds) {
|
||||
@@ -94,7 +88,6 @@ public class InspectionTaskController extends BaseController {
|
||||
/**
|
||||
* 启动巡检任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:inspection:start')")
|
||||
@Log(title = "启动巡检任务", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/start/{taskId}")
|
||||
public AjaxResult start(@PathVariable Long taskId) {
|
||||
@@ -105,7 +98,6 @@ public class InspectionTaskController extends BaseController {
|
||||
/**
|
||||
* 停止巡检任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:inspection:stop')")
|
||||
@Log(title = "停止巡检任务", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/stop/{taskId}")
|
||||
public AjaxResult stop(@PathVariable Long taskId) {
|
||||
@@ -116,7 +108,6 @@ public class InspectionTaskController extends BaseController {
|
||||
/**
|
||||
* 手动执行巡检任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:inspection:execute')")
|
||||
@Log(title = "执行巡检任务", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/execute/{taskId}")
|
||||
public AjaxResult execute(@PathVariable Long taskId) {
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.ruoyi.video.controller;
|
||||
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.video.domain.VModel;
|
||||
import com.ruoyi.video.service.IVModelService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/video/model")
|
||||
public class ModelController extends BaseController {
|
||||
|
||||
private final IVModelService modelService;
|
||||
|
||||
public ModelController(IVModelService modelService) {
|
||||
this.modelService = modelService;
|
||||
}
|
||||
|
||||
/** 新增模型(JSON) */
|
||||
@PreAuthorize("@ss.hasPermi('video:model:add')")
|
||||
@PostMapping
|
||||
public AjaxResult create(@RequestBody VModel model) {
|
||||
if (StringUtils.isEmpty(model.getModelName())) {
|
||||
return AjaxResult.error("模型名称不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(model.getUrl())) {
|
||||
return AjaxResult.error("模型URL不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(model.getFramework())) {
|
||||
model.setFramework("onnx");
|
||||
}
|
||||
int rows = modelService.insert(model);
|
||||
return rows > 0 ? AjaxResult.success(model) : AjaxResult.error("新增失败");
|
||||
}
|
||||
|
||||
/** 根据ID查询 */
|
||||
@PreAuthorize("@ss.hasPermi('video:model:query')")
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult get(@PathVariable("id") Long id) {
|
||||
VModel model = modelService.selectById(id);
|
||||
return model != null ? AjaxResult.success(model) : AjaxResult.error("未找到记录");
|
||||
}
|
||||
|
||||
/** 列表查询(可选条件) */
|
||||
@PreAuthorize("@ss.hasPermi('video:model:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(@RequestParam(value = "modelName", required = false) String modelName,
|
||||
@RequestParam(value = "framework", required = false) String framework,
|
||||
@RequestParam(value = "enabled", required = false) Integer enabled,
|
||||
@RequestParam(value = "keyword", required = false) String keyword) {
|
||||
startPage();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("modelName", modelName);
|
||||
params.put("framework", framework);
|
||||
params.put("enabled", enabled);
|
||||
params.put("keyword", keyword);
|
||||
List<VModel> list = modelService.selectList(params);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
@PreAuthorize("@ss.hasPermi('video:model:remove')")
|
||||
@DeleteMapping("/{id}")
|
||||
public AjaxResult delete(@PathVariable("id") Long id) {
|
||||
int rows = modelService.deleteById(id);
|
||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error("删除失败");
|
||||
}
|
||||
|
||||
/** 启用/禁用 */
|
||||
@PreAuthorize("@ss.hasPermi('video:model:edit')")
|
||||
@PutMapping("/{id}/enable")
|
||||
public AjaxResult enable(@PathVariable("id") Long id,
|
||||
@RequestParam("enabled") Integer enabled) {
|
||||
if (enabled == null || (enabled != 0 && enabled != 1)) {
|
||||
return AjaxResult.error("enabled 仅支持 0 或 1");
|
||||
}
|
||||
int rows = modelService.updateEnabled(id, enabled);
|
||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error("更新失败");
|
||||
}
|
||||
|
||||
/** 下载:直接 302 重定向到模型URL,确保可点击下载 */
|
||||
@PreAuthorize("@ss.hasPermi('video:model:download')")
|
||||
@GetMapping("/download/{id}")
|
||||
public void download(@PathVariable("id") Long id, HttpServletResponse response) throws IOException {
|
||||
VModel model = modelService.selectById(id);
|
||||
if (model == null || StringUtils.isEmpty(model.getUrl())) {
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND, "模型或URL不存在");
|
||||
return;
|
||||
}
|
||||
// 302 跳转到真实URL
|
||||
String target = model.getUrl();
|
||||
response.setStatus(HttpServletResponse.SC_FOUND);
|
||||
response.setHeader("Location", target);
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(model.getModelName(), StandardCharsets.UTF_8) + ".onnx\"");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user