package com.rwk.web.controller.ability;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.rwk.common.annotation.Log;
import com.rwk.common.enums.BusinessType;
import com.rwk.system.domain.RwkMeetingStaff;
import com.rwk.system.service.IRwkMeetingStaffService;
import com.rwk.common.core.controller.BaseController;
import com.rwk.common.core.domain.AjaxResult;
import com.rwk.common.utils.poi.ExcelUtil;
import com.rwk.common.core.page.TableDataInfo;

/**
 * 培训人员签到Controller
 * 
 * @author ruoyi
 * @date 2024-12-05
 */
@Controller
@RequestMapping("/system/trainStaff")
public class RwkMeetingStaffController extends BaseController
{
    private String prefix = "system/trainStaff";

    @Autowired
    private IRwkMeetingStaffService rwkMeetingStaffService;

    @RequiresPermissions("system:trainStaff:view")
    @GetMapping()
    public String trainStaff()
    {
        return prefix + "/trainStaff";
    }

    /**
     * 查询培训人员签到列表
     */
    @RequiresPermissions("system:trainStaff:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RwkMeetingStaff rwkMeetingStaff)
    {
        startPage();
        List<RwkMeetingStaff> list = rwkMeetingStaffService.selectRwkMeetingStaffList(rwkMeetingStaff);
        return getDataTable(list);
    }

    /**
     * 导出培训人员签到列表
     */
    @RequiresPermissions("system:trainStaff:export")
    @Log(title = "培训人员签到", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RwkMeetingStaff rwkMeetingStaff)
    {
        List<RwkMeetingStaff> list = rwkMeetingStaffService.selectRwkMeetingStaffList(rwkMeetingStaff);
        ExcelUtil<RwkMeetingStaff> util = new ExcelUtil<RwkMeetingStaff>(RwkMeetingStaff.class);
        return util.exportExcel(list, "培训人员签到数据");
    }

    /**
     * 新增培训人员签到
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存培训人员签到
     */
    @RequiresPermissions("system:trainStaff:add")
    @Log(title = "培训人员签到", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RwkMeetingStaff rwkMeetingStaff)
    {
        return toAjax(rwkMeetingStaffService.insertRwkMeetingStaff(rwkMeetingStaff));
    }

    /**
     * 修改培训人员签到
     */
    @RequiresPermissions("system:trainStaff:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        RwkMeetingStaff rwkMeetingStaff = rwkMeetingStaffService.selectRwkMeetingStaffById(id);
        mmap.put("rwkMeetingStaff", rwkMeetingStaff);
        return prefix + "/edit";
    }

    /**
     * 修改保存培训人员签到
     */
    @RequiresPermissions("system:trainStaff:edit")
    @Log(title = "培训人员签到", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RwkMeetingStaff rwkMeetingStaff)
    {
        return toAjax(rwkMeetingStaffService.updateRwkMeetingStaff(rwkMeetingStaff));
    }

    /**
     * 删除培训人员签到
     */
    @RequiresPermissions("system:trainStaff:remove")
    @Log(title = "培训人员签到", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(rwkMeetingStaffService.deleteRwkMeetingStaffByIds(ids));
    }
}
