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.TbConferencePeople;
import com.ruoyi.hezhi.service.ITbConferencePeopleService;
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-29
 */
@RestController
@RequestMapping("/hezhi/conferencePeople")
public class TbConferencePeopleController extends BaseController
{
    @Autowired
    private ITbConferencePeopleService tbConferencePeopleService;

    /**
     * 查询数字教育大会参会嘉宾列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:conferencePeople:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbConferencePeople tbConferencePeople)
    {
        startPage();
        List<TbConferencePeople> list = tbConferencePeopleService.selectTbConferencePeopleList(tbConferencePeople);
        return getDataTable(list);
    }

    /**
     * 导出数字教育大会参会嘉宾列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:conferencePeople:export')")
    @Log(title = "数字教育大会参会嘉宾", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbConferencePeople tbConferencePeople)
    {
        List<TbConferencePeople> list = tbConferencePeopleService.selectTbConferencePeopleList(tbConferencePeople);
        ExcelUtil<TbConferencePeople> util = new ExcelUtil<TbConferencePeople>(TbConferencePeople.class);
        util.exportExcel(response, list, "数字教育大会参会嘉宾数据");
    }

    /**
     * 获取数字教育大会参会嘉宾详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:conferencePeople:query')")
    @GetMapping(value = "/{conferencePeopleId}")
    public AjaxResult getInfo(@PathVariable("conferencePeopleId") Long conferencePeopleId)
    {
        return success(tbConferencePeopleService.selectTbConferencePeopleByConferencePeopleId(conferencePeopleId));
    }

    /**
     * 新增数字教育大会参会嘉宾
     */
    @PreAuthorize("@ss.hasPermi('hezhi:conferencePeople:add')")
    @Log(title = "数字教育大会参会嘉宾", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbConferencePeople tbConferencePeople)
    {
        return toAjax(tbConferencePeopleService.insertTbConferencePeople(tbConferencePeople));
    }

    /**
     * 修改数字教育大会参会嘉宾
     */
    @PreAuthorize("@ss.hasPermi('hezhi:conferencePeople:edit')")
    @Log(title = "数字教育大会参会嘉宾", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbConferencePeople tbConferencePeople)
    {
        return toAjax(tbConferencePeopleService.updateTbConferencePeople(tbConferencePeople));
    }

    /**
     * 删除数字教育大会参会嘉宾
     */
    @PreAuthorize("@ss.hasPermi('hezhi:conferencePeople:remove')")
    @Log(title = "数字教育大会参会嘉宾", businessType = BusinessType.DELETE)
	@DeleteMapping("/{conferencePeopleIds}")
    public AjaxResult remove(@PathVariable Long[] conferencePeopleIds)
    {
        return toAjax(tbConferencePeopleService.deleteTbConferencePeopleByConferencePeopleIds(conferencePeopleIds));
    }
}
