package com.vote.system.controller;

import com.vctgo.common.core.web.domain.AjaxResult;
import com.vote.system.domain.VoteOrganizers;
import com.vote.system.service.VoteOrganizersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author feng
 * @date 2024/8/11
 */
@RestController
@RequestMapping("/organizers")
public class VoteOrganizersController {

    @Autowired
    private VoteOrganizersService organizersService;


    /**
     * 查询所有主办方
     *
     * @return
     */
    @GetMapping
    public AjaxResult getOrganizers() {
        return AjaxResult.success(organizersService.getOrganizers());
    }

    /**
     * 添加
     *
     * @param voteOrganizers
     * @return
     */
    @PostMapping
    public AjaxResult addOrganizers(@RequestBody VoteOrganizers voteOrganizers) {
        return AjaxResult.success(organizersService.addOrganizers(voteOrganizers));
    }

    /**
     * 修改
     *
     * @param voteOrganizers
     * @return
     */
    @PutMapping("/edit")
    public AjaxResult editOrganizers(@RequestBody VoteOrganizers voteOrganizers) {
        return AjaxResult.success(organizersService.updateById(voteOrganizers));
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public AjaxResult deleteOrganizers(@PathVariable Integer id) {
        return AjaxResult.success(organizersService.removeById(id));
    }

}
