package com.vote.system.controller;

import com.vctgo.common.core.web.domain.AjaxResult;
import com.vote.system.domain.VoteRegistrations;
import com.vote.system.domain.dto.VoteEvaluationTasksDto;
import com.vote.system.service.VoteDataStatisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;


/**
 * 数据统计
 */
@RestController
@RequestMapping("/data")
public class VoteDataStatisController {

    @Autowired
    private VoteDataStatisService voteDataStatisService;

    /**
     * 活动报名人数
     */
    @GetMapping("/eventReg")
    public AjaxResult getEventReg(Long eventId) {
        return AjaxResult.success(voteDataStatisService.getList(eventId));
    }


    /**
     * 活动作品数
     */
    @GetMapping("/eventSubmission")
    public AjaxResult getEventSubmission(Long eventId) {
        return AjaxResult.success(voteDataStatisService.getEventSubmission(eventId));
    }


    /**
     * 专家评分进度统计
     */
    @GetMapping("/eventCategories")
    public AjaxResult getEventCategories(Long eventId) {
        return AjaxResult.success(voteDataStatisService.getEventCategories(eventId));
    }

    /**
     * 活动人数导出
     */
    @PostMapping("/registrationExport")
    public void getExport(HttpServletResponse response, @RequestParam("eventId") Long eventId) {
        voteDataStatisService.getExport(response, eventId);
    }

    /**
     * 作品数导出
     */
    @PostMapping("/worksExport")
    public void getWorksExport(HttpServletResponse response, @RequestParam("eventId") Long eventId){
        voteDataStatisService.getWorksExport(response, eventId);
    }

    /**
     * 评分进度导出
     */
    @PostMapping("/progressExport")
    public void getProgressExport(HttpServletResponse response, @ModelAttribute VoteEvaluationTasksDto voteEvaluationTasksDto) {
        voteDataStatisService.getProgressExport(response, voteEvaluationTasksDto);
    }

    /**
     * 晋级评将导出
     */
    @PostMapping("/promotedAwardExport")
    public void getPromotedAwardExport(HttpServletResponse response, @ModelAttribute VoteEvaluationTasksDto voteEvaluationTasksDto){
        voteDataStatisService.getPromotedAwardExport(response, voteEvaluationTasksDto);
    }

}
