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.StationOilGun;
import com.yijia.station.service.IStationOilGunService;
import com.yijia.common.utils.poi.ExcelUtil;
import com.yijia.common.core.page.TableDataInfo;

/**
 * 油枪管理Controller
 * 
 * @author yijia
 * @date 2020-12-09
 */
@RestController
@RequestMapping("/station/gun")
public class StationOilGunController extends BaseController
{
    @Autowired
    private IStationOilGunService stationOilGunService;

    /**
     * 查询油枪管理列表
     */
    @PreAuthorize("@ss.hasPermi('station:gun:list')")
    @GetMapping("/list")
    public TableDataInfo list(StationOilGun stationOilGun)
    {
        startPage();
        List<StationOilGun> list = stationOilGunService.selectStationOilGunList(stationOilGun);
        return getDataTable(list);
    }

    /**
     * 导出油枪管理列表
     */
    @PreAuthorize("@ss.hasPermi('station:gun:export')")
    @Log(title = "油枪管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StationOilGun stationOilGun)
    {
        List<StationOilGun> list = stationOilGunService.selectStationOilGunList(stationOilGun);
        ExcelUtil<StationOilGun> util = new ExcelUtil<StationOilGun>(StationOilGun.class);
        return util.exportExcel(list, "gun");
    }

    /**
     * 获取油枪管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('station:gun:query')")
    @GetMapping(value = "/{oilGunId}")
    public AjaxResult getInfo(@PathVariable("oilGunId") Long oilGunId)
    {
        return AjaxResult.success(stationOilGunService.selectStationOilGunById(oilGunId));
    }

    /**
     * 新增油枪管理
     */
    @PreAuthorize("@ss.hasPermi('station:gun:add')")
    @Log(title = "油枪管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StationOilGun stationOilGun)
    {
        return toAjax(stationOilGunService.insertStationOilGun(stationOilGun));
    }

    /**
     * 修改油枪管理
     */
    @PreAuthorize("@ss.hasPermi('station:gun:edit')")
    @Log(title = "油枪管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StationOilGun stationOilGun)
    {
        return toAjax(stationOilGunService.updateStationOilGun(stationOilGun));
    }

    /**
     * 删除油枪管理
     */
    @PreAuthorize("@ss.hasPermi('station:gun:remove')")
    @Log(title = "油枪管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{oilGunIds}")
    public AjaxResult remove(@PathVariable Long[] oilGunIds)
    {
        return toAjax(stationOilGunService.deleteStationOilGunByIds(oilGunIds));
    }
}
