TaskController.java 1.34 KB
package vion.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import vion.Global;
import vion.dto.TaskDTO;
import vion.model.FaultLog;
import vion.service.IFaultLogService;
import vion.service.ITaskService;
import vion.vo.TaskVO;

import java.util.List;

@RestController
@RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor
@Slf4j
public class TaskController {

    private final ITaskService taskService;
    private final IFaultLogService faultLogService;

    @GetMapping("/tasks")
    public Page<TaskVO> getTaskList(TaskDTO data) {
        return taskService.getTaskList(data);
    }

    @GetMapping("/task")
    public TaskVO getTaskById(Long taskId) {
        return taskService.getTaskById(taskId);
    }

    @PostMapping("/tasks")
    public Long saveOrUpdate(TaskDTO data, @RequestHeader String token) {
        return taskService.circTask(data, token);
    }

    @GetMapping("/faultLogs")
    public List<FaultLog> getFaultLogById(Integer storeId, Integer taskId) {
        return faultLogService.lambdaQuery()
                .eq(FaultLog::getStoreId, storeId)
                .eq(FaultLog::getTaskId, taskId)
                .orderByAsc(FaultLog::getCreateTime)
                .list();
    }
}