package com.ycwl.basic.controller.pc;

import com.ycwl.basic.model.pc.task.entity.TaskEntity;
import com.ycwl.basic.model.pc.task.req.TaskReqQuery;
import com.ycwl.basic.service.pc.TaskService;
import com.ycwl.basic.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：longbinbin
 * @Date：2024/12/3 16:01
 */
@RestController
@RequestMapping("/api/task/v1")
// 任务列表管理
public class TaskController {

    @Autowired
    private TaskService taskService;

    // 分页查询任务列表
    @PostMapping("/page")
    public ApiResponse pageQuery(@RequestBody TaskReqQuery taskReqQuery) {
        return taskService.pageQuery(taskReqQuery);
    }
    // 查询任务列表
    @PostMapping("/list")
    public ApiResponse list(@RequestBody TaskReqQuery taskReqQuery) {
        return taskService.list(taskReqQuery);
    }
    // 查询任务详情
    @GetMapping("/getDetail/{id}")
    public ApiResponse getById(@PathVariable Long id) {
        return taskService.getById(id);
    }
    // 删除任务
    @DeleteMapping("/delete/{id}")
    public ApiResponse deleteById(@PathVariable Long id) {
        return taskService.deleteById(id);
    }
    // 修改任务
    @PostMapping("/update")
    public ApiResponse update(@RequestBody TaskEntity taskEntity) {
        return taskService.update(taskEntity);
    }
    // 修改任务状态
    @PostMapping("/updateStatus")
    public ApiResponse updateStatus(@RequestParam Long id, @RequestParam Integer status) {
        return taskService.updateStatus(id,status);
    }
}
