package com.vote.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.vctgo.common.core.web.domain.AjaxResult;
import com.vote.system.domain.VoteEvaluationTasks;
import com.vote.system.domain.dto.VoteEvaluationTasksDto;
import com.vote.system.domain.vo.VoteJudgeTaskInfoVo;
import com.vote.system.domain.vo.VoteTasksIssueVo;
import com.vote.system.domain.vo.VoteTasksScoresVo;
import com.vote.system.service.VoteEvaluationTasksService;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author feng
 * @date 2024/8/22
 */
@RestController
@RequestMapping("/evaluationTasks")
public class VoteEvaluationTasksController {

    @Autowired
    private VoteEvaluationTasksService voteEvaluationTasksService;

    /**
     * 统计数据
     *
     * @param voteEvaluationTasksDto
     * @return
     */
    @GetMapping
    public AjaxResult getStatistics(VoteEvaluationTasksDto voteEvaluationTasksDto) {
        return AjaxResult.success(voteEvaluationTasksService.getStatistics(voteEvaluationTasksDto));
    }


    /**
     * 分页查询评选任务
     *
     * @param voteEvaluationTasksDto
     * @return
     */
    @GetMapping("/page")
    public AjaxResult selectByPage(VoteEvaluationTasksDto voteEvaluationTasksDto) {
        IPage<VoteJudgeTaskInfoVo> page = voteEvaluationTasksService.selectPage(voteEvaluationTasksDto);
        return AjaxResult.success(page);
    }


    /**
     * 查看详情
     */
    @GetMapping("/detail")
    public AjaxResult getDetail(VoteEvaluationTasksDto voteEvaluationTasksDto) {
        IPage<VoteTasksScoresVo> page = voteEvaluationTasksService.getDetail(voteEvaluationTasksDto);
        return AjaxResult.success(page);
    }

    /**
     * 查询评选任务
     */
    @GetMapping("/tasksIssue")
    public AjaxResult tasksIssue(VoteEvaluationTasksDto VoteEvaluationTasksDto) {
        IPage<VoteTasksIssueVo> page = voteEvaluationTasksService.tasksIssue(VoteEvaluationTasksDto);
        return AjaxResult.success(page);
    }


    /**
     * 发布评选任务
     */
    @PostMapping("/releaseTask")
    public AjaxResult releaseTask(@RequestBody VoteEvaluationTasksDto voteEvaluationTasksDto) {
        return AjaxResult.success(voteEvaluationTasksService.releaseTask(voteEvaluationTasksDto));
    }

}
