RRepairDeviceController.java 1.76 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.model.RRepairDevice;
import vion.service.IRRepairDeviceService;

/**
 * 备件、维修与设备关联
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/rRepairDevice")
public class RRepairDeviceController {

    private final IRRepairDeviceService repairDeviceService;

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

    @GetMapping
    @SaCheckPermission(value = "rRepairDevice:list", orRole = "admin")
    public Page<RRepairDevice> list(RRepairDevice dto) {
        return repairDeviceService.lambdaQuery(dto)
                .orderByDesc(RRepairDevice::getCreateTime)
                .page(Page.of(dto.getPageNum(), dto.getPageSize()));
    }

    @PostMapping
    @SaCheckPermission(value = "rRepairDevice:save", orRole = "admin")
    public String save(@RequestBody RRepairDevice dto) {
        return repairDeviceService.save(dto) ? "保存成功" : "保存失败";
    }

    @PostMapping("/{id}")
    @SaCheckPermission(value = "rRepairDevice:edit", orRole = "admin")
    public String updById(@RequestBody RRepairDevice dto) {
        return repairDeviceService.updateById(dto) ? "修改成功" : "修改失败";
    }

    @DeleteMapping("/{id}")
    @SaCheckPermission(value = "rRepairDevice:remove", orRole = "admin")
    public String delById(@PathVariable Long id) {
        return repairDeviceService.removeById(id) ? "删除成功" : "删除失败";
    }

}