package com.cpop.oam.business.controller.backstage;

import com.cpop.api.cloudDb.core.dto.*;
import com.cpop.api.cloudDb.handler.*;
import com.cpop.core.base.R;
import com.mybatisflex.core.paginate.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DB
 * @version 1.0.0
 * @since 2024-01-09 16:01
 */
@RestController
@Api(tags = "云数据查询接口")
@RequestMapping("/backstage/cloudData")
public class BackstageCloudDataController {

    @Autowired
    private CloudCustomerStudentHandler cloudCustomerStudentHandler;

    @Autowired
    private CloudCourseHandler cloudCourseHandler;

    @Autowired
    private CloudClassHandler cloudClassHandler;

    @Autowired
    private CloudOrderHandler cloudOrderHandler;

    @Autowired
    private CloudClassCardHandler cloudClassCardHandler;

    @Autowired
    private CloudStaffHandler cloudStaffHandler;

    /**
     * 获取客户分页
     * @author DB
     * @since 2024/1/9
     * @param page 分页参数
     * @param pageSize 分页参数
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @param storeId 校区Id
     * @param customerId 客户id
     * @return R<Page<CloudCustomerDto>>
     */
    @ApiOperation("获取客户分页")
    @GetMapping("/getCustomerPage")
    public R<Page<CloudCustomerDto>> getCustomerPage(@ApiParam("分页参数") @RequestParam("page") Integer page,
                                                     @ApiParam("分页参数") @RequestParam("pageSize") Integer pageSize,
                                                     @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
                                                     @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate,
                                                     @ApiParam("校区Id") @RequestParam("storeId") String storeId,
                                                     @ApiParam("客户id") @RequestParam(value = "customerId", required = false) String customerId) {
        Page<CloudCustomerDto> pageList = cloudCustomerStudentHandler.getCustomerPage(page, pageSize, startDate, endDate, storeId, customerId);
        return R.ok(pageList);
    }

    /**
     * 获取客户分页
     * @author DB
     * @since 2024/1/9
     * @param page 分页参数
     * @param pageSize 分页参数
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @param storeId 校区Id
     * @param customerId 客户id
     * @return R<Page<CloudCustomerDto>>
     */
    @ApiOperation("获取学员分页")
    @GetMapping("/getStudentPage")
    public R<Page<CloudStudentDto>> getStudentPage(@ApiParam("分页参数") @RequestParam("page") Integer page,
                                                   @ApiParam("分页参数") @RequestParam("pageSize") Integer pageSize,
                                                   @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
                                                   @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate,
                                                   @ApiParam("校区Id") @RequestParam("storeId") String storeId,
                                                   @ApiParam("客户id") @RequestParam(value = "customerId", required = false) String customerId,
                                                   @ApiParam("学员id") @RequestParam(value = "studentId", required = false) String studentId) {
        Page<CloudStudentDto> studentPage = cloudCustomerStudentHandler.getStudentPage(page, pageSize, startDate, endDate, storeId, customerId, studentId);
        return R.ok(studentPage);
    }

    /**
     * 获取课程分页
     * @author DB
     * @since 2024/1/10
     * @param page 分页参数
     * @param pageSize 分页参数
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @param storeId 校区Id
     * @param courseId 课程id
     * @return R<Page<CloudCourseDto>>
     */
    @ApiOperation("获取课程分页")
    @GetMapping("/getCoursePage")
    public R<Page<CloudCourseDto>> getCoursePage(@ApiParam("分页参数") @RequestParam("page") Integer page,
                                                 @ApiParam("分页参数") @RequestParam("pageSize") Integer pageSize,
                                                 @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
                                                 @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate,
                                                 @ApiParam("校区Id") @RequestParam("storeId") String storeId,
                                                 @ApiParam("课程id") @RequestParam(value = "courseId", required = false) String courseId,
                                                 @ApiParam("班id") @RequestParam(value = "classId", required = false) String classId) {
        Page<CloudCourseDto> coursePage = cloudCourseHandler.getCoursePage(page, pageSize, startDate, endDate, storeId, courseId, classId);
        return R.ok(coursePage);
    }

    /**
     * 获取学员上课
     * @author DB
     * @since 2024/1/10
     * @param customerId 客户id
     * @param studentId 学员id
     * @param cardId 课卡id
     * @param classId 教室id
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @param storeId 校区Id
     * @param courseId 课程id
     * @return R<CloudCourseStudentListDto>
     */
    @ApiOperation("获取学员上课")
    @GetMapping("/getCourseStudentList")
    public R<CloudCourseStudentListDto> getCourseStudentList(@ApiParam("客户id") @RequestParam(value = "customerId", required = false) String customerId,
                                                             @ApiParam("学员id") @RequestParam(value = "studentId", required = false) String studentId,
                                                             @ApiParam("课卡id") @RequestParam(value = "cardId", required = false) String cardId,
                                                             @ApiParam("教室id") @RequestParam(value = "classId", required = false) String classId,
                                                             @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
                                                             @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate,
                                                             @ApiParam("校区Id") @RequestParam("storeId") String storeId,
                                                             @ApiParam("课程id") @RequestParam(value = "courseId", required = false) String courseId) {
        CloudCourseStudentListDto studentListDto = cloudCourseHandler.getCourseStudentList(customerId, studentId, cardId, classId, startDate, endDate, storeId, courseId);
        return R.ok(studentListDto);
    }

    /**
     * 获取班级分页
     * @author DB
     * @since 2024/1/10
     * @param page 分页参数
     * @param pageSize 分页参数
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @param storeId 校区Id
     * @param classId 教室id
     * @return R<Page<CloudClassDto>>
     */
    @ApiOperation("获取班级分页")
    @GetMapping("/getClassPage")
    public R<Page<CloudClassDto>> getClassPage(@ApiParam("分页参数") @RequestParam("page") Integer page,
                                               @ApiParam("分页参数") @RequestParam("pageSize") Integer pageSize,
                                               @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
                                               @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate,
                                               @ApiParam("校区Id") @RequestParam("storeId") String storeId,
                                               @ApiParam("教室id") @RequestParam(value = "classId", required = false) String classId) {
        Page<CloudClassDto> classPage = cloudClassHandler.getClassPage(page, pageSize, startDate, endDate, storeId, classId);
        return R.ok(classPage);
    }


    /**
     * 获取班级学员分页
     * @author DB
     * @since 2024/1/10
     * @param page 分页参数
     * @param pageSize 分页参数
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @param storeId 校区Id
     * @param classId 教室id
     * @return R<Page<CloudClassDto>>
     */
    @ApiOperation("获取班级学员分页")
    @GetMapping("/getClassStudentPage")
    public R<Page<CloudClassStudentDto>> getClassStudentPage(@ApiParam("分页参数") @RequestParam("page") Integer page,
                                                             @ApiParam("分页参数") @RequestParam("pageSize") Integer pageSize,
                                                             @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
                                                             @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate,
                                                             @ApiParam("校区Id") @RequestParam("storeId") String storeId,
                                                             @ApiParam("教室id") @RequestParam(value = "classId", required = false) String classId) {
        Page<CloudClassStudentDto> classStudentPage = cloudClassHandler.getClassStudentPage(page, pageSize, startDate, endDate, storeId, classId);
        return R.ok(classStudentPage);
    }

    /**
     * 获取订单分页
     * @author DB
     * @since 2024/1/10
     * @param page 分页参数
     * @param pageSize 分页参数
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @param storeId 校区Id
     * @param customerId 客户id
     * @param cardId 课卡id
     * @param orderId 订单id
     * @return R<Page<CloudClassDto>>
     */
    @ApiOperation("获取订单分页")
    @GetMapping("/getOrderPage")
    public R<Page<CloudOrderDto>> getOrderPage(@ApiParam("分页参数") @RequestParam("page") Integer page,
                                               @ApiParam("分页参数") @RequestParam("pageSize") Integer pageSize,
                                               @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
                                               @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate,
                                               @ApiParam("校区Id") @RequestParam("storeId") String storeId,
                                               @ApiParam("客户id") @RequestParam(value = "customerId", required = false) String customerId,
                                               @ApiParam("课卡id") @RequestParam(value = "cardId", required = false) String cardId,
                                               @ApiParam("订单id") @RequestParam(value = "orderId", required = false) String orderId) {
        Page<CloudOrderDto> orderPage = cloudOrderHandler.getOrderPage(page, pageSize, startDate, endDate, storeId, customerId, cardId, orderId);
        return R.ok(orderPage);
    }

    /**
     * 获取订单分页
     * @author DB
     * @since 2024/1/10
     * @param page 分页参数
     * @param pageSize 分页参数
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @param storeId 校区Id
     * @param customerId 客户id
     * @param cardId 课卡id
     * @param cardType 课卡类型
     * @param cardStatus 课卡状态
     * @return R<Page<CloudClassDto>>
     */
    @ApiOperation("获取课卡分页")
    @GetMapping("/getClassCardPage")
    public R<Page<CloudClassCardDto>> getClassCardPage(@ApiParam("分页参数") @RequestParam("page") Integer page,
                                                       @ApiParam("分页参数") @RequestParam("pageSize") Integer pageSize,
                                                       @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
                                                       @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate,
                                                       @ApiParam("校区Id") @RequestParam("storeId") String storeId,
                                                       @ApiParam("客户id") @RequestParam(value = "customerId", required = false) String customerId,
                                                       @ApiParam("课卡id") @RequestParam(value = "cardId", required = false) String cardId,
                                                       @ApiParam("课卡类型") @RequestParam(value = "cardType", required = false) String cardType,
                                                       @ApiParam("课卡状态") @RequestParam(value = "cardStatus", required = false) Integer cardStatus) {
        Page<CloudClassCardDto> classCardPage = cloudClassCardHandler.getClassCardPage(page, pageSize, startDate, endDate, storeId, customerId, cardId, cardType, cardStatus);
        return R.ok(classCardPage);
    }

    /**
     * 获取订单分页
     * @author DB
     * @since 2024/1/10
     * @param page 分页参数
     * @param pageSize 分页参数
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @param storeId 校区Id
     * @param customerId 客户id
     * @param cardId 课卡id
     * @return R<Page<CloudClassDto>>
     */
    @ApiOperation("获取课卡记录分页")
    @GetMapping("/getClassCardRecordPage")
    public R<Page<CloudClassCardRecordDto>> getClassCardRecordPage(@ApiParam("分页参数") @RequestParam("page") Integer page,
                                                                   @ApiParam("分页参数") @RequestParam("pageSize") Integer pageSize,
                                                                   @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
                                                                   @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate,
                                                                   @ApiParam("校区Id") @RequestParam("storeId") String storeId,
                                                                   @ApiParam("客户id") @RequestParam(value = "customerId", required = false) String customerId,
                                                                   @ApiParam("课卡id") @RequestParam(value = "cardId", required = false) String cardId) {
        Page<CloudClassCardRecordDto> classCardRecordPage = cloudClassCardHandler.getClassCardRecordPage(page, pageSize, startDate, endDate, storeId, customerId, cardId);
        return R.ok(classCardRecordPage);
    }

    /**
     * 获取订单分页
     * @author DB
     * @since 2024/1/10
     * @param page 分页参数
     * @param pageSize 分页参数
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @param storeId 校区Id
     * @param staffId 员工id
     * @return R<Page<CloudClassDto>>
     */
    @ApiOperation("获取班级分页")
    @GetMapping("/getStoreStaffPage")
    public R<Page<CloudStaffDto>> getStoreStaffPage(@ApiParam("分页参数") @RequestParam("page") Integer page,
                                                    @ApiParam("分页参数") @RequestParam("pageSize") Integer pageSize,
                                                    @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
                                                    @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate,
                                                    @ApiParam("校区Id") @RequestParam("storeId") String storeId,
                                                    @ApiParam("员工id") @RequestParam(value = "staffId", required = false) String staffId) {
        Page<CloudStaffDto> storeStaffPage = cloudStaffHandler.getStoreStaffPage(page, pageSize, startDate, endDate, storeId, staffId);
        return R.ok(storeStaffPage);
    }

}
