DeviceController.java 1.47 KB
package vion.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vion.dto.DeviceDTO;
import vion.service.IDeviceService;
import vion.vo.DeviceVO;

import java.util.List;

/**
 * 设备管理
 */
@RestController
@RequestMapping("/api/device")
@RequiredArgsConstructor
public class DeviceController {

    private final IDeviceService deviceService;

    @GetMapping
    @SaCheckPermission(value = "device:list", orRole = "admin")
    public Page<DeviceVO> list(DeviceDTO dto) {
        return deviceService.list(dto);
    }

    @GetMapping("/{id}")
    @SaCheckPermission(value = "device:query", orRole = "admin")
    public DeviceVO getById(@PathVariable Long id) {
        return deviceService.getById(id);
    }

    @PostMapping
    @SaCheckPermission(value = "device:edit", orRole = "admin")
    public String update(@RequestBody List<DeviceDTO> dtoList) {
        return deviceService.update(dtoList);
    }

    @PostMapping("/single")
    @SaCheckPermission(value = "device:save", orRole = "admin")
    public String save(@RequestBody DeviceDTO dto) {
        return deviceService.save(dto);
    }

    @PostMapping("/batch")
    @SaCheckPermission(value = "device:saveBatch", orRole = "admin")
    public String saveBatch(@RequestBody List<DeviceDTO> dtoList) {
        return deviceService.saveBatch(dtoList);
    }

}