package com.ruoyi.controller;

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.cs.domain.CsUserInfo;
import com.ruoyi.cs.service.ICsUserInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 使用人员信息Controller
 * 
 * @author ruoyi
 * @date 2024-04-25
 */
@RestController
@RequestMapping("/cs/csUserInfo")
public class CsUserInfoController extends BaseController
{
    @Autowired
    private ICsUserInfoService csUserInfoService;

    /**
     * 查询使用人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csUserInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsUserInfo csUserInfo)
    {
        startPage();
        List<CsUserInfo> list = csUserInfoService.selectCsUserInfoList(csUserInfo);
        return getDataTable(list);
    }

    /**
     * 导出使用人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csUserInfo:export')")
    @Log(title = "使用人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsUserInfo csUserInfo)
    {
        List<CsUserInfo> list = csUserInfoService.selectCsUserInfoList(csUserInfo);
        ExcelUtil<CsUserInfo> util = new ExcelUtil<CsUserInfo>(CsUserInfo.class);
        util.exportExcel(response, list, "使用人员信息数据");
    }

    /**
     * 获取使用人员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csUserInfo:query')")
    @GetMapping(value = "/{userInfoId}")
    public AjaxResult getInfo(@PathVariable("userInfoId") String userInfoId)
    {
        return AjaxResult.success(csUserInfoService.selectCsUserInfoByUserInfoId(userInfoId));
    }

    /**
     * 新增使用人员信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csUserInfo:add')")
    @Log(title = "使用人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsUserInfo csUserInfo)
    {
        return toAjax(csUserInfoService.insertCsUserInfo(csUserInfo));
    }

    /**
     * 修改使用人员信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csUserInfo:edit')")
    @Log(title = "使用人员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsUserInfo csUserInfo)
    {
        return toAjax(csUserInfoService.updateCsUserInfo(csUserInfo));
    }

    /**
     * 删除使用人员信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csUserInfo:remove')")
    @Log(title = "使用人员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userInfoIds}")
    public AjaxResult remove(@PathVariable String[] userInfoIds)
    {
        return toAjax(csUserInfoService.deleteCsUserInfoByUserInfoIds(userInfoIds));
    }
}
