package com.yijia.station.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.yijia.common.annotation.Log;
import com.yijia.common.core.controller.BaseController;
import com.yijia.common.core.domain.AjaxResult;
import com.yijia.common.enums.BusinessType;
import com.yijia.station.domain.StationPersonnel;
import com.yijia.station.service.IStationPersonnelService;
import com.yijia.common.utils.poi.ExcelUtil;
import com.yijia.common.core.page.TableDataInfo;

/**
 * 油站员工信息Controller
 * 
 * @author yijia
 * @date 2020-12-09
 */
@RestController
@RequestMapping("/station/personnel")
public class StationPersonnelController extends BaseController
{
    @Autowired
    private IStationPersonnelService stationPersonnelService;

    /**
     * 查询油站员工信息列表
     */
    @PreAuthorize("@ss.hasPermi('station:personnel:list')")
    @GetMapping("/list")
    public TableDataInfo list(StationPersonnel stationPersonnel)
    {
        startPage();
        List<StationPersonnel> list = stationPersonnelService.selectStationPersonnelList(stationPersonnel);
        return getDataTable(list);
    }

    /**
     * 导出油站员工信息列表
     */
    @PreAuthorize("@ss.hasPermi('station:personnel:export')")
    @Log(title = "油站员工信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StationPersonnel stationPersonnel)
    {
        List<StationPersonnel> list = stationPersonnelService.selectStationPersonnelList(stationPersonnel);
        ExcelUtil<StationPersonnel> util = new ExcelUtil<StationPersonnel>(StationPersonnel.class);
        return util.exportExcel(list, "personnel");
    }

    /**
     * 获取油站员工信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('station:personnel:query')")
    @GetMapping(value = "/{personnelId}")
    public AjaxResult getInfo(@PathVariable("personnelId") Long personnelId)
    {
        return AjaxResult.success(stationPersonnelService.selectStationPersonnelById(personnelId));
    }

    /**
     * 新增油站员工信息
     */
    @PreAuthorize("@ss.hasPermi('station:personnel:add')")
    @Log(title = "油站员工信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StationPersonnel stationPersonnel)
    {
        return toAjax(stationPersonnelService.insertStationPersonnel(stationPersonnel));
    }

    /**
     * 修改油站员工信息
     */
    @PreAuthorize("@ss.hasPermi('station:personnel:edit')")
    @Log(title = "油站员工信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StationPersonnel stationPersonnel)
    {
        return toAjax(stationPersonnelService.updateStationPersonnel(stationPersonnel));
    }

    /**
     * 删除油站员工信息
     */
    @PreAuthorize("@ss.hasPermi('station:personnel:remove')")
    @Log(title = "油站员工信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{personnelIds}")
    public AjaxResult remove(@PathVariable Long[] personnelIds)
    {
        return toAjax(stationPersonnelService.deleteStationPersonnelByIds(personnelIds));
    }
}
