DeviceController.java 1.63 KB
package vion.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.dromara.hutool.core.lang.Assert;
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) {
        Assert.notNull(dto.getStatus(), "status 不能为空!");
        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("/record")
    @SaCheckPermission(value = "device:record", orRole = "admin")
    public String circulate(@RequestBody List<DeviceDTO> dtoList) {
        return deviceService.recordDevice(dtoList);
    }

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

}