package org.wcs.serve.controller.app;

import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.wcs.model.dto.serve.etagBase.*;
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.etagBase.EtagControllerVo;
import org.wcs.model.vo.serve.etagBase.EtagLocationVo;
import org.wcs.model.vo.serve.etagBase.EtagTagInfoVo;
import org.wcs.serve.service.intf.IEtagBaseService;

/**
 * 电子标签基础数据控制器
 * 控制器；标签；货位；
 */
@RestController
@RequestMapping("/app/etag")
@ResponseBody
@RequiredArgsConstructor
public class EtagBaseController {

    private final IEtagBaseService etagBaseService;

    /* 电子标签控制器 */

    /**
     * 查询电子标签控制器基础数据
     * @param request 查询参数
     * @param pageIndex 页码
     * @param pageSize 页大小
     * @return 响应
     */
    @PostMapping("queryEtagController")
    public AppServeDataResponse<PageDataResponse<EtagControllerVo>> queryEtagController(@RequestBody EtagControllerQueryReq request, @RequestParam("pageIndex") @NotNull(message = "页码不能为空") Integer pageIndex, @RequestParam("pageSize") @NotNull(message = "页大小不能为空") Integer pageSize) {
        return etagBaseService.queryEtagController(request, pageIndex, pageSize);
    }

    /**
     * 新增电子标签控制器基础数据
     * @param request 新增参数
     * @return 响应
     */
    @PostMapping("addEtagController")
    public AppServeResponse addEtagController(@RequestBody @Validated AddEtagControllerReq request) {
        return etagBaseService.addEtagController(request);
    }

    /**
     * 修改电子标签控制器基础数据
     * @param request 修改参数
     * @return 响应
     */
    @PutMapping("updateEtagController")
    public AppServeResponse updateEtagController(@RequestBody @Validated UpdateEtagControllerReq request) {
        return etagBaseService.updateEtagController(request);
    }

    /**
     * 删除电子标签控制器基础数据
     * @param controllerId 控制器ID
     * @return 响应
     */
    @DeleteMapping("deleteEtagController")
    public AppServeResponse deleteEtagController(@RequestParam @NotNull(message = "控制器ID不能为空") Integer controllerId) {
        return etagBaseService.deleteEtagController(controllerId);
    }

    /* 电子标签小标签 */

    /**
     * 查询电子标签小标签基础信息
     * @param request 查询参数
     * @param pageIndex 页码
     * @param pageSize 页大小
     * @return 响应
     */
    @PostMapping("queryEtagTagInfo")
    public AppServeDataResponse<PageDataResponse<EtagTagInfoVo>> queryEtagTagInfo(@RequestBody EtagTagInfoQueryReq request, @RequestParam("pageIndex") @NotNull(message = "页码不能为空") Integer pageIndex, @RequestParam("pageSize") @NotNull(message = "页大小不能为空") Integer pageSize) {
        return etagBaseService.queryEtagTagInfo(request, pageIndex, pageSize);
    }

    /**
     * 新增电子标签小标签基础信息
     * @param request 新增参数
     * @return 响应
     */
    @PostMapping("addEtagTagInfo")
    public AppServeResponse addEtagTagInfo(@RequestBody @Validated AddEtagTagInfoReq request) {
        return etagBaseService.addEtagTagInfo(request);
    }

    /**
     * 修改电子标签小标签基础信息
     * @param request 修改参数
     * @return 响应
     */
    @PutMapping("updateEtagTagInfo")
    public AppServeResponse updateEtagTagInfo(@RequestBody @Validated UpdateEtagTagInfoReq request) {
        return etagBaseService.updateEtagTagInfo(request);
    }

    /**
     * 删除电子标签小标签基础信息
     * @param tagName 标签名称
     * @return 响应
     */
    @DeleteMapping("deleteEtagTagInfo")
    public AppServeResponse deleteEtagTagInfo(@RequestParam @NotNull(message = "标签名称不能为空") String tagName) {
        return etagBaseService.deleteEtagTagInfo(tagName);
    }

    /* 电子标签货位 */

    /**
     * 查询电子标签货位基础信息
     * @param request 查询参数
     * @param pageIndex 页码
     * @param pageSize 页大小
     * @return 响应
     */
    @PostMapping("queryEtagLocation")
    public AppServeDataResponse<PageDataResponse<EtagLocationVo>> queryEtagLocation(@RequestBody EtagLocationQueryReq request, @RequestParam("pageIndex") @NotNull(message = "页码不能为空") Integer pageIndex, @RequestParam("pageSize") @NotNull(message = "页大小不能为空") Integer pageSize) {
        return etagBaseService.queryEtagLocation(request, pageIndex, pageSize);
    }

    /**
     * 新增电子标签货位基础信息
     * @param request 新增参数
     * @return 响应
     */
    @PostMapping("addEtagLocation")
    public AppServeResponse addEtagLocation(@RequestBody @Validated AddEtagLocationReq request) {
        return etagBaseService.addEtagLocation(request);
    }

    /**
     * 修改电子标签货位基础信息
     * @param request 修改参数
     * @return 响应
     */
    @PutMapping("updateEtagLocation")
    public AppServeResponse updateEtagLocation(@RequestBody @Validated UpdateEtagLocationReq request) {
        return etagBaseService.updateEtagLocation(request);
    }

    /**
     * 删除电子标签货位基础信息
     * @param recordId 记录号
     * @return 响应
     */
    @DeleteMapping("deleteEtagLocation/{recordId}")
    public AppServeResponse deleteEtagLocation(@PathVariable @NotNull(message = "记录号不能为空") String recordId) {
        return etagBaseService.deleteEtagLocation(recordId);
    }


}
