refactor(video): 移除设备和巡检任务接口权限注解并调整模型控制器包结构
- 移除了 DeviceController 中所有方法的 @PreAuthorize 权限注解 - 移除了 InspectionTaskController 中所有方法的 @PreAuthorize 权限注解 - 将 ModelController 从 ruoyi-admin 模块迁移至 ruoyi-video 模块- 调整 ModelController 包路径并继承 BaseController-为 ModelController 的各个接口添加了相应的权限注解- 修改 list 方法返回类型为 TableDataInfo 并支持分页查询- 引入缺失的类依赖和安全注解支持
This commit is contained in:
@@ -37,7 +37,6 @@ public class DeviceController extends BaseController {
|
||||
/**
|
||||
* 查询设备列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:device:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(Device device) {
|
||||
startPage();
|
||||
@@ -48,7 +47,6 @@ public class DeviceController extends BaseController {
|
||||
/**
|
||||
* 导出设备列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:device:export')")
|
||||
@Log(title = "设备", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Device device) {
|
||||
@@ -60,7 +58,6 @@ public class DeviceController extends BaseController {
|
||||
/**
|
||||
* 获取设备详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:device:query')")
|
||||
@GetMapping(value = "/{deviceId}")
|
||||
public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId) {
|
||||
return success(deviceService.selectDeviceByDeviceId(deviceId));
|
||||
@@ -69,7 +66,6 @@ public class DeviceController extends BaseController {
|
||||
/**
|
||||
* 新增设备
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:device:add')")
|
||||
@Log(title = "设备", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Device device) {
|
||||
@@ -79,7 +75,6 @@ public class DeviceController extends BaseController {
|
||||
/**
|
||||
* 修改设备
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:device:edit')")
|
||||
@Log(title = "设备", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Device device) {
|
||||
@@ -89,7 +84,6 @@ public class DeviceController extends BaseController {
|
||||
/**
|
||||
* 删除设备
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('video:device:remove')")
|
||||
@Log(title = "设备", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deviceIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] deviceIds) {
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
package com.ruoyi.web.controller.video;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
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.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 {
|
||||
|
||||
private final IVModelService modelService;
|
||||
|
||||
public ModelController(IVModelService modelService) {
|
||||
this.modelService = modelService;
|
||||
}
|
||||
|
||||
/** 新增模型(JSON) */
|
||||
@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查询 */
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult get(@PathVariable("id") Long id) {
|
||||
VModel model = modelService.selectById(id);
|
||||
return model != null ? AjaxResult.success(model) : AjaxResult.error("未找到记录");
|
||||
}
|
||||
|
||||
/** 列表查询(可选条件) */
|
||||
@GetMapping("/list")
|
||||
public AjaxResult 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) {
|
||||
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 AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
@DeleteMapping("/{id}")
|
||||
public AjaxResult delete(@PathVariable("id") Long id) {
|
||||
int rows = modelService.deleteById(id);
|
||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error("删除失败");
|
||||
}
|
||||
|
||||
/** 启用/禁用 */
|
||||
@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,确保可点击下载 */
|
||||
@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