package com.ruoyi.hezhi.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.hezhi.domain.TbConferenceRegistration;
import com.ruoyi.hezhi.service.ITbConferenceRegistrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 参会报名Controller
 *
 * @author ruoyi
 * @date 2024-10-28
 */
@RestController
@RequestMapping("/hezhi/conferenceRegistration")
public class TbConferenceRegistrationController extends BaseController
{
    @Autowired
    private ITbConferenceRegistrationService tbConferenceRegistrationService;

    /**
     * 查询参会报名列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:conferenceRegistration:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbConferenceRegistration tbConferenceRegistration)
    {
        startPage();
        List<TbConferenceRegistration> list = tbConferenceRegistrationService.selectTbConferenceRegistrationList(tbConferenceRegistration);
        return getDataTable(list);
    }

    /**
     * 导出参会报名列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:conferenceRegistration:export')")
    @Log(title = "参会报名", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbConferenceRegistration tbConferenceRegistration)
    {
        List<TbConferenceRegistration> list = tbConferenceRegistrationService.selectTbConferenceRegistrationList(tbConferenceRegistration);
        ExcelUtil<TbConferenceRegistration> util = new ExcelUtil<TbConferenceRegistration>(TbConferenceRegistration.class);
        util.exportExcel(response, list, "参会报名数据");
    }

    /**
     * 获取参会报名详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:conferenceRegistration:query')")
    @GetMapping(value = "/{conferenceRegistrationId}")
    public AjaxResult getInfo(@PathVariable("conferenceRegistrationId") Long conferenceRegistrationId)
    {
        return success(tbConferenceRegistrationService.selectTbConferenceRegistrationByConferenceRegistrationId(conferenceRegistrationId));
    }

    /**
     * 新增参会报名
     */
    @PreAuthorize("@ss.hasPermi('hezhi:conferenceRegistration:add')")
    @Log(title = "参会报名", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbConferenceRegistration tbConferenceRegistration)
    {
        return toAjax(tbConferenceRegistrationService.insertTbConferenceRegistration(tbConferenceRegistration));
    }

    /**
     * 修改参会报名
     */
    @PreAuthorize("@ss.hasPermi('hezhi:conferenceRegistration:edit')")
    @Log(title = "参会报名", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbConferenceRegistration tbConferenceRegistration)
    {
        return toAjax(tbConferenceRegistrationService.updateTbConferenceRegistration(tbConferenceRegistration));
    }

    /**
     * 删除参会报名
     */
    @PreAuthorize("@ss.hasPermi('hezhi:conferenceRegistration:remove')")
    @Log(title = "参会报名", businessType = BusinessType.DELETE)
	@DeleteMapping("/{conferenceRegistrationIds}")
    public AjaxResult remove(@PathVariable Long[] conferenceRegistrationIds)
    {
        return toAjax(tbConferenceRegistrationService.deleteTbConferenceRegistrationByConferenceRegistrationIds(conferenceRegistrationIds));
    }
}
