ConstructionTeamController.java 2.59 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.ConstructionTeamDTO;
import vion.dto.RContractTeamDTO;
import vion.service.IConstructionTeamService;
import vion.vo.ConstructionTeamVO;
import vion.vo.RContractTeamVO;

/**
* 施工队管理
*/
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class ConstructionTeamController {

    private final IConstructionTeamService constructionTeamService;

    @GetMapping("/constructionTeam")
    @SaCheckPermission(value = "constructionTeam:list", orRole = "admin")
    public Page<ConstructionTeamVO> list(ConstructionTeamDTO dto) {
        return constructionTeamService.list(dto);
    }

    @GetMapping("/constructionTeam/{id}")
    @SaCheckPermission(value = "constructionTeam:query", orRole = "admin")
    public ConstructionTeamVO getVOById(@PathVariable Long id) {
        return constructionTeamService.getVOById(id);
    }

    @PostMapping("/constructionTeam")
    @SaCheckPermission(value = "constructionTeam:save", orRole = "admin")
    public Object save(@RequestBody ConstructionTeamDTO dto) {
        return constructionTeamService.save(dto);
    }

    @PostMapping("/constructionTeam/{id}")
    @SaCheckPermission(value = "constructionTeam:edit", orRole = "admin")
    public String update(@PathVariable Long id, @RequestBody ConstructionTeamDTO dto) {
        dto.setId(id);
        return constructionTeamService.updateById(dto);
    }

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

    @GetMapping("/contractTeam")
    @SaCheckPermission(value = "contract:team:list", orRole = "admin")
    public Page<RContractTeamVO> list(RContractTeamDTO dto) {
        return constructionTeamService.list(dto);
    }

    @PostMapping("/contractTeam/{id}")
    @SaCheckPermission(value = "contract:team:assign", orRole = "admin")
    public String assignTeam(@PathVariable Long id, @RequestBody RContractTeamDTO dto) {
        dto.setId(id);
        return constructionTeamService.assignTeam(dto);
    }

    @DeleteMapping("/contractTeam/{id}")
    @SaCheckPermission(value = "contract:team:remove", orRole = "admin")
    public String delContractTeamById(@PathVariable Long id) {
        return constructionTeamService.delContractTeamById(id);
    }

}