package com.zehong.web.controller.train;

import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.train.TrainCourseStat;
import com.zehong.system.domain.train.TrainCourseStatDetail;
import com.zehong.system.service.train.TTrainCourseStatService;
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.RestController;

import java.util.List;

/**
 * @author geng
 * 培训统计
 */
@RestController
@RequestMapping("/train/trainStat")
public class TTrainCourseStatController extends BaseController {

    @Autowired
    private TTrainCourseStatService tTrainCourseStatService;

    /**
     * 获取培训统计查询
     * @param trainCourseStat 统计查询参数
     * @return
     */
    @GetMapping("/getTrainCourseStatData")
    public TableDataInfo getTrainCourseStatData(TrainCourseStat trainCourseStat){
        startPage();
        List<TrainCourseStat> list = tTrainCourseStatService.getTrainCourseStatData(trainCourseStat);
        return getDataTable(list);
    }

    /**
     * 获取培训统计详情
     * @param courseId 培训id
     * @return
     */
    @GetMapping("/getTrainCourseStatDetailData")
    public TableDataInfo getTrainCourseStatDetailData(Long courseId){
        startPage();
        List<TrainCourseStatDetail> list = tTrainCourseStatService.getTrainCourseStatDetailData(courseId);
        return getDataTable(list);
    }


    @GetMapping("/trainCourseStatDetailExport")
    public AjaxResult trainCourseStatDetailExport(Long courseId) {
        List<TrainCourseStatDetail> list = tTrainCourseStatService.getTrainCourseStatDetailData(courseId);
        ExcelUtil<TrainCourseStatDetail> util = new ExcelUtil<>(TrainCourseStatDetail.class);
        return util.exportExcel(list, "培训统计详情");
    }
}
