package com.yc.ship.module.trade.controller.admin.report;

import com.yc.ship.framework.apilog.core.annotation.ApiAccessLog;
import com.yc.ship.framework.common.pojo.CommonResult;
import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.module.trade.controller.admin.report.vo.CruiseOpsDailyReqVO;
import com.yc.ship.module.trade.controller.admin.report.vo.CruiseOpsDailyRespVO;
import com.yc.ship.module.trade.controller.admin.report.vo.YangtzePassengerSummaryPageReqVO;
import com.yc.ship.module.trade.controller.admin.report.vo.YangtzePassengerSummaryRespVO;
import com.yc.ship.module.trade.service.report.OpsDailyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;

import static com.yc.ship.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.yc.ship.framework.common.pojo.CommonResult.success;

/**
 * 省际度假游轮经营情况日报表 / 长江行游轮游客数据及营收统计 Controller
 *
 * @author jincheng
 */
@Tag(name = "管理后台 - 省际度假游轮经营情况日报")
@RestController
@RequestMapping("/report/interprovincial/cruise-ops-daily")
@Validated
@Slf4j
public class OpsDailyController {

    @Resource
    private OpsDailyService opsDailyService;

    /**
     * 查询省际度假游轮经营情况日报列表
     *
     * @param reqVO 查询条件
     * @return 数据列表
     */
    @GetMapping("/list")
    @Operation(summary = "查询省际度假游轮经营情况日报列表")
    public CommonResult<List<CruiseOpsDailyRespVO>> getCruiseOpsDailyList(@Valid CruiseOpsDailyReqVO reqVO) {
        List<CruiseOpsDailyRespVO> list = opsDailyService.getCruiseOpsDailyList(reqVO);
        return success(list);
    }

    /**
     * 导出省际度假游轮经营情况日报 Excel
     *
     * @param reqVO    查询条件
     * @param response HTTP响应
     * @throws IOException IO异常
     */
    @GetMapping("/export-excel")
    @Operation(summary = "导出省际度假游轮经营情况日报 Excel")
    @ApiAccessLog(operateType = EXPORT)
    public void exportCruiseOpsDailyExcel(@Valid CruiseOpsDailyReqVO reqVO,
                                           HttpServletResponse response) throws IOException {
        opsDailyService.exportCruiseOpsDailyExcel(reqVO, response);
    }

    // ==================== 长江行游轮游客数据及营收统计 ====================

    /**
     * 分页查询长江行游轮游客数据及营收统计
     *
     * @param pageReqVO 分页查询条件
     * @return 分页结果
     */
    @GetMapping("/yangtze-passenger-summary/page")
    @Operation(summary = "分页查询长江行游轮游客数据及营收统计")
    public CommonResult<PageResult<YangtzePassengerSummaryRespVO>> getYangtzePassengerSummaryPage(
            @Valid YangtzePassengerSummaryPageReqVO pageReqVO) {
        PageResult<YangtzePassengerSummaryRespVO> pageResult = opsDailyService.getYangtzePassengerSummaryPage(pageReqVO);
        return success(pageResult);
    }

    /**
     * 导出长江行游轮游客数据及营收统计 Excel
     *
     * @param pageReqVO 查询条件
     * @param response  HTTP响应
     * @throws IOException IO异常
     */
    @GetMapping("/yangtze-passenger-summary/export-excel")
    @Operation(summary = "导出长江行游轮游客数据及营收统计 Excel")
    @ApiAccessLog(operateType = EXPORT)
    public void exportYangtzePassengerSummaryExcel(@Valid YangtzePassengerSummaryPageReqVO pageReqVO,
                                                     HttpServletResponse response) throws IOException {
        opsDailyService.exportYangtzePassengerSummaryExcel(pageReqVO, response);
    }
}

