package org.wcs.serve.controller.pub;

import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.wcs.model.dto.pub.AddConveyTaskReq;
import org.wcs.model.dto.pub.AddEtagTaskReq;
import org.wcs.model.dto.pub.AddStockTaskReq;
import org.wcs.model.vo.pub.PubServeDataResponse;
import org.wcs.model.vo.pub.PubServeResponse;
import org.wcs.model.vo.pub.task.StockTaskDetailVo;
import org.wcs.serve.service.pub.intf.ITaskService;

/**
 * 对外开放的任务接口
 */
@RestController
@RequestMapping("/api/pub/task")
@ResponseBody
@RequiredArgsConstructor
public class TaskController {

    private final ITaskService taskService;

    /**
     * 添加仓库任务
     * @param addStockTaskReq 添加任务数据
     * @return 结果
     */
    @PostMapping("addStockTask")
    public PubServeResponse addStockTask(@RequestBody @Validated AddStockTaskReq addStockTaskReq) {
        return taskService.addStockTask(addStockTaskReq);
    }

    /**
     * 查询仓库任务详情
     * @param taskId 任务ID
     * @return 结果
     */
    @GetMapping("queryStockTaskDetail")
    public PubServeDataResponse<StockTaskDetailVo> queryStockTaskDetail(@RequestParam("taskId") @NotBlank(message = "任务ID不能为空") String taskId) {
        return taskService.queryStockTaskDetail(taskId);
    }

    /**
     * 取消仓库任务
     * @param taskId 仓库任务ID
     * @return 结果
     */
    @DeleteMapping("cancelStockTask")
    public PubServeResponse cancelStockTask(@RequestParam("taskId") @NotBlank(message = "任务ID不能为空") String taskId) {
        return taskService.cancelStockTask(taskId);
    }

    /**
     * 添加箱式线任务
     * @param addConveyTaskReq 添加任务数据
     * @return 添加结果
     */
    @PostMapping("addConveyTask")
    public PubServeResponse addConveyTask(@RequestBody @Validated AddConveyTaskReq addConveyTaskReq) {
        return taskService.addConveyTask(addConveyTaskReq);
    }

    /**
     * 添加电子标签任务
     * @param addEtagTaskReq 添加任务数据
     * @return 添加结果
     */
    @PostMapping("addEtagTask")
    public PubServeResponse addEtagTask(@RequestBody @Validated AddEtagTaskReq addEtagTaskReq) {
        return taskService.addEtagTask(addEtagTaskReq);
    }




}
