package com.vote.system.controller;

import cn.hutool.http.HttpRequest;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.vctgo.common.core.web.domain.AjaxResult;
import com.vctgo.system.api.domain.dto.VoteExpertWorkingPlatformDto;
import com.vote.system.domain.vo.VoteExpertWorkingPlatformVo;
import com.vote.system.service.VoteExpertWorkingPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author feng
 * @date 2024/8/29
 */
@RestController
@RequestMapping("/workingPlatform")
public class VoteExpertWorkingPlatformController {

    @Autowired
    private VoteExpertWorkingPlatformService voteExpertWorkingPlatformService;


    /**
     * 专家平台分页
     */
    @GetMapping("/page/{judgesId}")
    public AjaxResult expertPlatformPage(@PathVariable("judgesId") String judgesId) {
        IPage<VoteExpertWorkingPlatformVo> page = voteExpertWorkingPlatformService.expertPlatformPage(judgesId);
        return AjaxResult.success(page);
    }

    /**
     * 查询规则项
     */
    @GetMapping("/item/{ruleId}")
    public AjaxResult getItem(@PathVariable("ruleId") Long ruleId) {
        return AjaxResult.success(voteExpertWorkingPlatformService.getItem(ruleId));
    }

    /**
     * 查询活动详情
     */
    @GetMapping("/eventDetails/{eventId}")
    public AjaxResult getEventDetails(@PathVariable("eventId") Long eventId) {
        return AjaxResult.success(voteExpertWorkingPlatformService.getEventDetails(eventId));
    }

    /**
     * 评分清单分页
     */
    @GetMapping("/submissionList")
    public AjaxResult submissionList(Long eventId, Long workSettingsId, Long roundId, String status, HttpServletRequest request ) {
        return AjaxResult.success(voteExpertWorkingPlatformService.expertPlatformDetail(eventId, workSettingsId, roundId,status,request));
    }

    /**
     * 作品数
     */
    @GetMapping("/count")
    public AjaxResult submissionCount(Long eventId, Long workSettingsId, Long roundId,HttpServletRequest request ) {
        return AjaxResult.success(voteExpertWorkingPlatformService.expertPlatformCount(eventId, workSettingsId, roundId,request));
    }


    /**
     * 作品详情
     */
    @GetMapping("/submissionDetails")
    public AjaxResult submissionDetails(Long eventId, Long workSettingsId, Long roundId, Long submissionId) {
        return AjaxResult.success(voteExpertWorkingPlatformService.expertPlatformSubmissionDetails(eventId, workSettingsId, roundId, submissionId));
    }


    /**
     * 专家评分
     */
    @PostMapping("/expertScoring")
    public AjaxResult expertScoring(@RequestBody String encode, HttpServletRequest request) {
        return AjaxResult.success(voteExpertWorkingPlatformService.expertScoring(encode,request));
    }


}
