package com.vote.system.controller;

import com.vctgo.common.core.web.domain.AjaxResult;
import com.vote.system.domain.VoteEventWorkSettings;
import com.vote.system.domain.dto.VoteEventWorkSettingsDto;
import com.vote.system.service.VoteEventWorkSettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.Map;

/**
 * @CreateTime: 2024/8/13 下午4:55
 * @Description:
 * @Email: f2965573933@163.com
 * @Author: FanJiaBao
 */
@Validated
@RestController
@RequestMapping("/eventWorkSettings")
public class VoteEventWorkSettingsController {

    @Autowired
    private VoteEventWorkSettingsService voteEventWorkSettingsService;


    /**
     * 查询活动单个详情
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public AjaxResult getEventWorkSettings(@PathVariable("id") Long id) {
        return AjaxResult.success(voteEventWorkSettingsService.getEventWorkSettings(id));
    }

    /**
     * 添加活动类型
     *
     * @param voteEventWorkSettings
     * @return
     */
    @PostMapping("/saveWorkType")
    public AjaxResult saveWorkType(@RequestBody @Valid VoteEventWorkSettings voteEventWorkSettings) {
        return AjaxResult.success(voteEventWorkSettingsService.saveWorkType(voteEventWorkSettings));
    }

    @GetMapping("/judges")
    public AjaxResult getJudges() {
        Map<String, String> map = voteEventWorkSettingsService.getJudges();
        return AjaxResult.success(map);

    }


    @PostMapping("/edit")
    public AjaxResult editWorkSettings(@RequestBody @Valid VoteEventWorkSettingsDto voteEventWorkSettingsDto){
        return voteEventWorkSettingsService.editWorkSettings(voteEventWorkSettingsDto);
    }


    @DeleteMapping("/{id}")
    public AjaxResult deleteWorkSettings(@PathVariable("id") Long id){
        return AjaxResult.success(voteEventWorkSettingsService.deleteWorkSettings(id));
    }

    @GetMapping("/list/{id}")
    public AjaxResult getWorkSettingsList(@PathVariable("id") Long id){
        return AjaxResult.success(voteEventWorkSettingsService.getWorkSettingsList(id));
    }
}
