package org.wcs.serve.controller.app;

import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.wcs.model.dto.serve.recordError.QueryEquipmentErrorReq;
import org.wcs.model.vo.serve.AppServeDataResponse;
import org.wcs.model.vo.serve.common.PageDataResponse;
import org.wcs.model.vo.serve.recordError.QueryEquipmentErrorVo;
import org.wcs.serve.service.intf.IRecordErrorService;

/**
 * 报警记录控制器
 */
@RestController
@RequestMapping("/app/recordError")
@ResponseBody
@RequiredArgsConstructor
public class RecordErrorController {

    private final IRecordErrorService recordErrorService;

    /**
     * 查询设备错误
     * @param request 查询参数
     * @param pageSize 分页大小
     * @param pageIndex 页面序号
     * @return 查询结果
     */
    @PostMapping("queryEquipmentError")
    public AppServeDataResponse<PageDataResponse<QueryEquipmentErrorVo>> queryEquipmentError(@RequestBody QueryEquipmentErrorReq request, Integer pageSize, Integer pageIndex) {
        return recordErrorService.queryEquipmentError(request, pageSize, pageIndex);
    }

    /**
     * 导出设备错误
     * @param response 响应
     * @param request 查询参数
     */
    @PostMapping("exportEquipmentError")
    public void exportEquipmentError(HttpServletResponse response, @RequestBody QueryEquipmentErrorReq request) {
        recordErrorService.exportEquipmentError(response, request);
    }




}
