package com.ruoyi.web.controller.reception;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ReceptionPersonnel;
import com.ruoyi.system.service.IReceptionPersonnelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 接待人员信息Controller
 * 
 * @author ruoyi
 * @date 2023-11-02
 */
@RestController
@RequestMapping("/system/personnel")
public class ReceptionPersonnelController extends BaseController
{
    @Autowired
    private IReceptionPersonnelService receptionPersonnelService;

    /**
     * 查询接待人员信息列表
     */
    //@PreAuthorize("@ss.hasPermi('system:personnel:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReceptionPersonnel receptionPersonnel)
    {
        startPage();
        List<ReceptionPersonnel> list = receptionPersonnelService.selectReceptionPersonnelList(receptionPersonnel);
        return getDataTable(list);
    }

    /**
     * 查询接待人员信息列表（不分页）
     */
    @GetMapping("/noPage/list")
    public AjaxResult noPageList(ReceptionPersonnel receptionPersonnel)
    {
        List<ReceptionPersonnel> list = receptionPersonnelService.selectReceptionPersonnelList(receptionPersonnel);
        return AjaxResult.success(list);
    }

    /**
     * 导出接待人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:personnel:export')")
    @Log(title = "接待人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReceptionPersonnel receptionPersonnel)
    {
        List<ReceptionPersonnel> list = receptionPersonnelService.selectReceptionPersonnelList(receptionPersonnel);
        ExcelUtil<ReceptionPersonnel> util = new ExcelUtil<ReceptionPersonnel>(ReceptionPersonnel.class);
        util.exportExcel(response, list, "接待人员信息数据");
    }

    /**
     * 获取接待人员信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:personnel:query')")
    @GetMapping(value = "/{receptionId}")
    public AjaxResult getInfo(@PathVariable("receptionId") Long receptionId)
    {
        return success(receptionPersonnelService.selectReceptionPersonnelByReceptionId(receptionId));
    }

    /**
     * 新增接待人员信息
     */
    @PreAuthorize("@ss.hasPermi('system:personnel:add')")
    @Log(title = "接待人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReceptionPersonnel receptionPersonnel)
    {
        return toAjax(receptionPersonnelService.insertReceptionPersonnel(receptionPersonnel));
    }

    /**
     * 修改接待人员信息
     */
    @PreAuthorize("@ss.hasPermi('system:personnel:edit')")
    @Log(title = "接待人员信息", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody ReceptionPersonnel receptionPersonnel)
    {
        return toAjax(receptionPersonnelService.updateReceptionPersonnel(receptionPersonnel));
    }

    /**
     * 删除接待人员信息
     */
    @PreAuthorize("@ss.hasPermi('system:personnel:remove')")
    @Log(title = "接待人员信息", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{receptionIds}")
    public AjaxResult remove(@PathVariable Long[] receptionIds)
    {
        return toAjax(receptionPersonnelService.deleteReceptionPersonnelByReceptionIds(receptionIds));
    }
}
