package com.vote.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vctgo.common.core.web.domain.AjaxResult;
import com.vote.system.domain.VoteRegistrations;
import com.vote.system.domain.dto.VoteRegistrationsDto;
import com.vote.system.domain.vo.VoteRegistrationsVo;
import com.vote.system.service.VoteRegistrationsService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author feng
 * @date 2024/8/19
 */
@RestController
@RequestMapping("/registrations")
public class VoteRegistrationsController {

    @Autowired
    private VoteRegistrationsService voteRegistrationsService;


    /**
     * 分页查询 报名用户
     *
     * @param voteRegistrationsDto
     * @return
     */
    @GetMapping("/page")
    public AjaxResult SelectPage(VoteRegistrationsDto voteRegistrationsDto) {
        Page<VoteRegistrationsVo> page = voteRegistrationsService.selectPage(voteRegistrationsDto);
        return AjaxResult.success(page);
    }


    /**
     * 修改状态 禁用 解禁
     *
     * @param voteRegistrations
     * @return
     */
    @PutMapping("/edit")
    public AjaxResult editStatus(@RequestBody VoteRegistrations voteRegistrations) {
        return AjaxResult.success(voteRegistrationsService.editStatus(voteRegistrations));
    }


    /**
     * 查看用户信息详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public AjaxResult getUserInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(voteRegistrationsService.getUserInfo(id));
    }

}
