package org.wcs.serve.controller.app;

import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.wcs.model.dto.serve.etagTask.AddEtagTaskReq;
import org.wcs.model.dto.serve.etagTask.EtagTaskQueryReq;
import org.wcs.model.dto.serve.etagTask.UpdateEtagTaskReq;
import org.wcs.model.vo.serve.AppServeDataResponse;
import org.wcs.model.vo.serve.AppServeResponse;
import org.wcs.model.vo.serve.common.PageDataResponse;
import org.wcs.model.vo.serve.etagTask.EtagTaskBakVo;
import org.wcs.model.vo.serve.etagTask.EtagTaskVo;
import org.wcs.serve.service.intf.IEtagTaskService;

import javax.validation.constraints.NotNull;

/**
 * 电子标签任务控制器
 */
@RestController
@RequestMapping("/app/etagTask")
@ResponseBody
@RequiredArgsConstructor
public class EtagTaskController {

    private final IEtagTaskService etagTaskService;

    /**
     * 查询电子标签任务
     * @param request 查询参数
     * @param pageIndex 页码
     * @param pageSize 页大小
     * @return 响应
     */
    @PostMapping("/queryEtagTask")
    public AppServeDataResponse<PageDataResponse<EtagTaskVo>> queryEtagTask(@RequestBody EtagTaskQueryReq request, @RequestParam("pageIndex") @NotNull(message = "页码不能为空") Integer pageIndex, @RequestParam("pageSize") @NotNull(message = "页大小不能为空") Integer pageSize) {
        return etagTaskService.queryEtagTask(request, pageIndex, pageSize);

    }

    /**
     * 新增电子标签任务
     * @param request 新增参数
     * @return 响应
     */
    @PostMapping("/addEtagTask")
    public AppServeResponse addEtagTask(@RequestBody @Validated AddEtagTaskReq request) {
        return etagTaskService.addEtagTask(request);
    }

    /**
     * 修改电子标签任务
     * @param request 修改参数
     * @return 响应
     */
    @PostMapping("/updateEtagTask")
    public AppServeResponse updateEtagTask(@RequestBody @Validated UpdateEtagTaskReq request) {
        return etagTaskService.updateEtagTask(request);
    }




    /**
     * 查询电子标签任务 ---- 备份表
     * @param request 查询参数
     * @param pageIndex 页码
     * @param pageSize 页大小
     * @return 响应
     */
    @PostMapping("/queryEtagTaskBak")
    public AppServeDataResponse<PageDataResponse<EtagTaskBakVo>> queryEtagTaskBak(@RequestBody EtagTaskQueryReq request, @RequestParam("pageIndex") @NotNull(message = "页码不能为空") Integer pageIndex, @RequestParam("pageSize") @NotNull(message = "页大小不能为空") Integer pageSize) {
        return etagTaskService.queryEtagTaskBak(request, pageIndex, pageSize);

    }



}
