package com.ai.da.controller;

import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.Response;
import com.ai.da.model.dto.QueryTaskHistoryDTO;
import com.ai.da.model.dto.SuperResolutionDTO;
import com.ai.da.model.dto.TaskDTO;
import com.ai.da.model.vo.TaskVO;
import com.ai.da.service.TaskListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@Api(tags = "任务列表模块")
@Slf4j
@RestController
@RequestMapping("/api/tasks")
public class TaskListController {

    @Resource
    private TaskListService taskListService;

    @PostMapping("/getList")
    @ApiOperation("获取未执行完的任务")
    public Response<List<TaskDTO<SuperResolutionDTO>>> getTaskList(@Valid @RequestBody List<String> taskIdList) {
        return Response.success(taskListService.getExecTask(taskIdList));
    }

    @PostMapping("/getAllTask")
    @ApiOperation("获取所有任务")
    public Response<PageBaseResponse<TaskVO>> getAllTask(@Valid @RequestBody QueryTaskHistoryDTO queryTaskHistoryDTO) {
        return Response.success(taskListService.getAllTask(queryTaskHistoryDTO));
    }

}
