package com.ruoyi.project.configuration.controller;

import java.util.List;
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.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.configuration.domain.TStaffmgr;
import com.ruoyi.project.configuration.service.ITStaffmgrService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 人员信息Controller
 *
 * @author ruoyi
 * @date 2022-01-11
 */
@RestController
@RequestMapping("/configuration/staffmgr")
public class TStaffmgrController extends BaseController
{
    @Autowired
    private ITStaffmgrService tStaffmgrService;

    /**
     * 查询人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('configuration:staffmgr:list')")
    @GetMapping("/list")
    public TableDataInfo list(TStaffmgr tStaffmgr)
    {
        startPage();
        List<TStaffmgr> list = tStaffmgrService.selectTStaffmgrList(tStaffmgr);
        return getDataTable(list);
    }

    /**
     * 导出人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('configuration:staffmgr:export')")
    @Log(title = "人员信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TStaffmgr tStaffmgr)
    {
        List<TStaffmgr> list = tStaffmgrService.selectTStaffmgrList(tStaffmgr);
        ExcelUtil<TStaffmgr> util = new ExcelUtil<TStaffmgr>(TStaffmgr.class);
        return util.exportExcel(list, "staffmgr");
    }

    /**
     * 获取人员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('configuration:staffmgr:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tStaffmgrService.selectTStaffmgrById(id));
    }

    /**
     * 获取人员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('configuration:staffmgr:query')")
    @GetMapping(value = "/getByIc/{cardId}")
    public AjaxResult getInfoByIc(@PathVariable("cardId") String cardId)
    {
        return AjaxResult.success(tStaffmgrService.selectTStaffmgrByIc(cardId));
    }

    /**
     * 新增人员信息
     */
    @PreAuthorize("@ss.hasPermi('configuration:staffmgr:add')")
    @Log(title = "人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TStaffmgr tStaffmgr)
    {
        return toAjax(tStaffmgrService.insertTStaffmgr(tStaffmgr));
    }

    /**
     * 修改人员信息
     */
    @PreAuthorize("@ss.hasPermi('configuration:staffmgr:edit')")
    @Log(title = "人员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TStaffmgr tStaffmgr)
    {
        return toAjax(tStaffmgrService.updateTStaffmgr(tStaffmgr));
    }

    /**
     * 删除人员信息
     */
    @PreAuthorize("@ss.hasPermi('configuration:staffmgr:remove')")
    @Log(title = "人员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tStaffmgrService.deleteTStaffmgrByIds(ids));
    }
}
