package cn.iocoder.yudao.module.base.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.base.service.DataViewService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 数据查询统一方法")
@RestController
@RequestMapping("/base/dataView")
@Validated
public class DataViewController {

    @Autowired
    private DataViewService dataViewService;

    /**
     * 查询学员详情
     * @author vinjor-M
     * @date 14:32 2025/2/8
     * @param id 学员id
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
    **/
    @GetMapping("/getStudentInfo")
    @Operation(summary = "查询学员详情")
    public CommonResult<?> selectStudentInfo(@RequestParam("id") Long id,@RequestParam(value = "coachId",required = false)Long coachId) {
        return success(dataViewService.selectStudentInfo(id,coachId));
    }

    /**
     * 首页数据统计查询接口 --
     * @author vinjor-M
     * @date 14:12 2025/2/14
     * @param type 查询类型（coach-教练查询|admin-管理员查询）
     * @param timeType 时间查询类型（all-全部|day-当日|month-当月|more-自定义）
     * @param coachId 教练id
     * @param startTime 查询时间范围--开始
     * @param endTime 查询时间范围--结束
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
    **/
    @GetMapping("/indexData")
    @Operation(summary = "首页数据统计查询接口")
    public CommonResult<?> selectIndexInfo(@RequestParam(value = "type") String type,
                                           @RequestParam(value = "timeType") String timeType,
                                           @RequestParam(value = "coachId",required = false) Long coachId,
                                           @RequestParam(value = "startTime",required = false) String startTime,
                                           @RequestParam(value = "endTime",required = false) String endTime) {
        return success(dataViewService.selectIndexInfo(type,timeType,coachId,startTime,endTime));
    }

    /**
     * 业务经理首页数据统计查询接口 --
     * @author vinjor-M
     * @date 14:12 2025/2/14
     * @param type 查询类型（coach-教练查询|admin-管理员查询）
     * @param timeType 时间查询类型（all-全部|day-当日|month-当月|more-自定义）
     * @param coachId 教练id
     * @param startTime 查询时间范围--开始
     * @param endTime 查询时间范围--结束
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
     **/
    @GetMapping("/indexDataByBusiness")
    @Operation(summary = "首页数据统计查询接口")
    public CommonResult<?> selectIndexInfoByBusiness(@RequestParam(value = "type") String type,
                                           @RequestParam(value = "timeType") String timeType,
                                           @RequestParam(value = "coachId",required = false) Long coachId,
                                           @RequestParam(value = "startTime",required = false) String startTime,
                                           @RequestParam(value = "endTime",required = false) String endTime,
                                                     @RequestParam(value = "isSign",required = false) Integer isSign) {
        return success(dataViewService.selectIndexInfoByBusiness(type,timeType,coachId,startTime,endTime, isSign));
    }

    @GetMapping("/indexDataByWorking")
    @Operation(summary = "首页数据统计查询接口")
    public CommonResult<?> selectIndexInfoByWorking(@RequestParam(value = "type") String type,
                                                     @RequestParam(value = "timeType") String timeType,
                                                     @RequestParam(value = "coachId",required = false) Long coachId,
                                                     @RequestParam(value = "startTime",required = false) String startTime,
                                                     @RequestParam(value = "endTime",required = false) String endTime,
                                                     @RequestParam(value = "isSign",required = false) Integer isSign) {
        return success(dataViewService.selectIndexInfoByWorking(type,timeType,coachId,startTime,endTime, isSign));
    }

    /**
     * 查询学生总数
     * @author vinjor-M
     * @date 15:57 2025/2/25
    **/
    @GetMapping("/getStudentCount")
    @Operation(summary = "查询学生总数")
    public CommonResult<?> getStudentCount() {
        return success(dataViewService.getStudentCount());
    }
}
