TaskTempController.java 1.87 KB
package vion.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import vion.dto.TaskTempDTO;
import vion.model.TaskTemp;
import vion.service.ITaskTempService;
import vion.vo.TaskTempVO;

import java.util.Map;

/**
 * 预工单
 */
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
@Slf4j
public class TaskTempController {

    private final ITaskTempService taskTempService;
    private final Converter converter;

    @GetMapping("/taskTemps")
    @SaCheckPermission(value = "taskTemp:list", orRole = "admin")
    public Page<TaskTempVO> getTaskTempList(TaskTempDTO data) {
        return taskTempService.getTaskTempList(data);
    }

    @GetMapping("/taskTemp")
    @SaCheckPermission(value = "taskTemp:query", orRole = "admin")
    public TaskTempVO getTaskTempById(Long id) {
        return taskTempService.getTaskTempById(id);
    }

    @PostMapping("/taskTemp")
    @SaCheckPermission(value = "taskTemp:save", orRole = "admin")
    public Object saveTaskTemp(TaskTempDTO data) {
        return taskTempService.saveTaskTemp(data);
    }

    @PostMapping("/taskTemp/{id}")
    @SaCheckPermission(value = "taskTemp:edit", orRole = "admin")
    public String upd(@PathVariable(name = "id") Long id, TaskTempDTO data) {
        TaskTemp taskTemp = converter.convert(data, TaskTemp.class);
        taskTemp.setId(id);
        return taskTempService.updateById(taskTemp) ? "更新成功" : "更新失败";
    }

    @GetMapping("/taskTemp/getInfoByPhone")
    @SaCheckPermission(value = "task:getInfoByPhone", orRole = "admin")
    public Map<String, Long> getInfoByPhone(String phone) {
        return taskTempService.getInfoByPhone(phone);
    }
}