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.recordScan.QueryRecordScanReq;
import org.wcs.model.vo.serve.AppServeDataResponse;
import org.wcs.model.vo.serve.common.PageDataResponse;
import org.wcs.model.vo.serve.recordScan.RecordScanVo;
import org.wcs.serve.service.intf.IRecordScanService;

import java.math.BigDecimal;

/**
 * 扫码记录表控制器
 */
@RestController
@RequestMapping("/app/recordScan")
@ResponseBody
@RequiredArgsConstructor
public class RecordScanController {

    private final IRecordScanService recordScanService;

    /**
     * 查询扫码记录表
     *
     * @param request 查询参数
     * @param pageSize 每页数量
     * @param pageIndex 页码
     * @return 扫码记录表列表
     */
    @PostMapping("/queryWithPage")
    public AppServeDataResponse<PageDataResponse<RecordScanVo>> queryRecordScan(@RequestBody QueryRecordScanReq request, @RequestParam("pageSize") Integer pageSize, @RequestParam("pageIndex") Integer pageIndex) {
        return recordScanService.queryRecordScan(request, pageSize, pageIndex);
    }

    /**
     * 获取扫码率
     * @param request 查询参数
     * @return 扫码率
     */
    @PostMapping("/queryScanRatio")
    public AppServeDataResponse<BigDecimal> queryRecordScanRatio(@RequestBody QueryRecordScanReq request) {
        return recordScanService.queryRecordScanRatio(request);
    }

    /**
     * 下载扫码记录表
     * @param response 响应
     * @param request 扫码记录表查询参数
     */
    @PostMapping("/downLoadRecordScan")
    public void downLoadRecordScan(HttpServletResponse response, @RequestBody QueryRecordScanReq request) {
        recordScanService.downLoadRecordScan(response, request);
    }





}
