package com.ruoyi.web.controller.manage;

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.manage.domain.StaffManage;
import com.ruoyi.manage.service.IStaffManageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员管理Controller
 *
 * @author boman
 * @date 2025-05-07
 */
@RestController
@RequestMapping("/manage/staffManage")
public class StaffManageController extends BaseController
{
    @Autowired
    private IStaffManageService staffManageService;

/**
 * 查询人员管理列表
 */
@PreAuthorize("@ss.hasPermi('manage:staffManage:list')")
@GetMapping("/list")
    public TableDataInfo list(StaffManage staffManage)
    {
        startPage();
        List<StaffManage> list = staffManageService.selectStaffManageList(staffManage);
        return getDataTable(list);
    }

    /**
     * 导出人员管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:staffManage:export')")
    @Log(title = "人员管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StaffManage staffManage)
    {
        List<StaffManage> list = staffManageService.selectStaffManageList(staffManage);
        ExcelUtil<StaffManage> util = new ExcelUtil<StaffManage>(StaffManage.class);
        util.exportExcel(response, list, "人员管理数据");
    }

    /**
     * 获取人员管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:staffManage:query')")
    @GetMapping(value = "/{staffId}")
    public AjaxResult getInfo(@PathVariable("staffId") Long staffId)
    {
        return success(staffManageService.selectStaffManageByStaffId(staffId));
    }

    /**
     * 新增人员管理
     */
    @PreAuthorize("@ss.hasPermi('manage:staffManage:add')")
    @Log(title = "人员管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StaffManage staffManage)
    {
        return toAjax(staffManageService.insertStaffManage(staffManage));
    }

    /**
     * 修改人员管理
     */
    @PreAuthorize("@ss.hasPermi('manage:staffManage:edit')")
    @Log(title = "人员管理", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody StaffManage staffManage)
    {
        return toAjax(staffManageService.updateStaffManage(staffManage));
    }

    /**
     * 删除人员管理
     */
    @PreAuthorize("@ss.hasPermi('manage:staffManage:remove')")
    @Log(title = "人员管理", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{staffIds}")
    public AjaxResult remove(@PathVariable Long[] staffIds)
    {
        return toAjax(staffManageService.deleteStaffManageByStaffIds(staffIds));
    }
}
