package com.inspur.web.controller.work;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.inspur.domain.ElevatorPersonInfo;
import com.inspur.service.IElevatorPersonInfoService;
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.inspur.common.annotation.Log;
import com.inspur.common.core.controller.BaseController;
import com.inspur.common.core.domain.AjaxResult;
import com.inspur.common.enums.BusinessType;
import com.inspur.common.utils.poi.ExcelUtil;
import com.inspur.common.core.page.TableDataInfo;

/**
 * 人员信息Controller
 *
 * @author inspur
 * @date 2024-09-30
 */
@RestController
@RequestMapping("/person/info")
public class ElevatorPersonInfoController extends BaseController
{
    @Autowired
    private IElevatorPersonInfoService elevatorPersonInfoService;

    /**
     * 查询人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('person:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(ElevatorPersonInfo elevatorPersonInfo)
    {
        startPage();
        List<ElevatorPersonInfo> list = elevatorPersonInfoService.selectElevatorPersonInfoList(elevatorPersonInfo);
        return getDataTable(list);
    }

    /**
     * 导出人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('person:info:export')")
    @Log(title = "人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElevatorPersonInfo elevatorPersonInfo)
    {
        List<ElevatorPersonInfo> list = elevatorPersonInfoService.selectElevatorPersonInfoList(elevatorPersonInfo);
        ExcelUtil<ElevatorPersonInfo> util = new ExcelUtil<ElevatorPersonInfo>(ElevatorPersonInfo.class);
        util.exportExcel(response, list, "人员信息数据");
    }

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

    /**
     * 新增人员信息
     */
    @PreAuthorize("@ss.hasPermi('person:info:add')")
    @Log(title = "人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElevatorPersonInfo elevatorPersonInfo)
    {
        return toAjax(elevatorPersonInfoService.insertElevatorPersonInfo(elevatorPersonInfo));
    }

    /**
     * 修改人员信息
     */
    @PreAuthorize("@ss.hasPermi('person:info:edit')")
    @Log(title = "人员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElevatorPersonInfo elevatorPersonInfo)
    {
        return toAjax(elevatorPersonInfoService.updateElevatorPersonInfo(elevatorPersonInfo));
    }

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