package net.lab1024.sa.admin.module.business.wms.task.controller;

import net.lab1024.sa.admin.module.business.wms.task.domain.form.TaskAddForm;
import net.lab1024.sa.admin.module.business.wms.task.domain.form.TaskQueryForm;
import net.lab1024.sa.admin.module.business.wms.task.domain.form.TaskUpdateForm;
import net.lab1024.sa.admin.module.business.wms.task.domain.vo.TaskVO;
import net.lab1024.sa.admin.module.business.wms.task.service.TaskQueryService;
import net.lab1024.sa.admin.module.business.wms.task.service.TaskService;
import net.lab1024.sa.admin.module.business.wms.task.service.TaskQueryService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.*;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

/**
 * Task任务 Controller
 *
 * @Author 霍锦
 * @Date 2024-12-03 17:08:30
 * @Copyright 友仓
 */

@RestController
@Tag(name = "Task任务")
public class TaskController {

    @Resource
    private TaskService taskService;

    @Resource
    private TaskQueryService taskQueryService;

    @Operation(summary = "分页查询 @author 霍锦")
    @PostMapping("/task/queryPage")
    @SaCheckPermission("task:query")
    public ResponseDTO<PageResult<TaskVO>> queryPage(@RequestBody @Valid TaskQueryForm queryForm) {
        return ResponseDTO.ok(taskQueryService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 霍锦")
    @PostMapping("/task/add")
    @SaCheckPermission("task:add")
    public ResponseDTO<String> add(@RequestBody @Valid TaskAddForm addForm) {
        return taskService.add(addForm);
    }

    @Operation(summary = "更新 @author 霍锦")
    @PostMapping("/task/update")
    @SaCheckPermission("task:update")
    public ResponseDTO<String> update(@RequestBody @Valid TaskUpdateForm updateForm) {
        return taskService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 霍锦")
    @PostMapping("/task/batchDelete")
    @SaCheckPermission("task:batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return taskService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 霍锦")
    @GetMapping("/task/delete")
    @SaCheckPermission("task:delete")
    public ResponseDTO<String> delete(@RequestParam Long taskId) {
        return taskService.delete(taskId);
    }
}
