RepairRecController.java 1.84 KB
package vion.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import org.dromara.hutool.core.lang.Assert;
import org.dromara.hutool.core.array.ArrayUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vion.dto.RepairRecDTO;
import vion.service.IRepairRecService;
import vion.vo.RepairRecVO;

import java.util.List;

/**
 * 返修申请
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/repairRec")
public class RepairRecController {

    private final IRepairRecService repairRecService;

    @PostMapping("/frontSubmit")
    public Object frontSubmit(RepairRecDTO dto) {
        return repairRecService.frontSubmit(dto);
    }

    @GetMapping
    @SaCheckPermission(value = "repairRec:list", orRole = "admin")
    public List<RepairRecVO> list(RepairRecDTO dto) {
        Assert.isTrue(ArrayUtil.isAllNotNull(dto.getCreateTimeStart(), dto.getCreateTimeEnd()), "查询时间范围不能为空");
        return repairRecService.list(dto);
    }

    @GetMapping("/{id}")
    @SaCheckPermission(value = "repairRec:query", orRole = "admin")
    public RepairRecVO getById(@PathVariable Long id) {
        return repairRecService.getRepairRecDetail(id, null);
    }

    @GetMapping("/get/{uuid}")
    public RepairRecVO getByUuid(@PathVariable String uuid) {
        return repairRecService.getRepairRecDetail(null, uuid);
    }

    @PostMapping("/{id}")
    @SaCheckPermission(value = "repairRec:edit", orRole = "admin")
    public String updById(@PathVariable Long id, @RequestBody RepairRecDTO dto) {
        return repairRecService.updById(id, dto);
    }

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

}