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

/**
 * 油站设备管理Controller
 * 
 * @author yijia
 * @date 2020-12-09
 */
@RestController
@RequestMapping("/station/manage")
public class StationDeviceManageController extends BaseController
{
    @Autowired
    private IStationDeviceManageService stationDeviceManageService;

    /**
     * 查询油站设备管理列表
     */
    @PreAuthorize("@ss.hasPermi('station:manage:list')")
    @GetMapping("/list")
    public TableDataInfo list(StationDeviceManage stationDeviceManage)
    {
        startPage();
        List<StationDeviceManage> list = stationDeviceManageService.selectStationDeviceManageList(stationDeviceManage);
        return getDataTable(list);
    }

    /**
     * 导出油站设备管理列表
     */
    @PreAuthorize("@ss.hasPermi('station:manage:export')")
    @Log(title = "油站设备管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StationDeviceManage stationDeviceManage)
    {
        List<StationDeviceManage> list = stationDeviceManageService.selectStationDeviceManageList(stationDeviceManage);
        ExcelUtil<StationDeviceManage> util = new ExcelUtil<StationDeviceManage>(StationDeviceManage.class);
        return util.exportExcel(list, "manage");
    }

    /**
     * 获取油站设备管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('station:manage:query')")
    @GetMapping(value = "/{deviceId}")
    public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId)
    {
        return AjaxResult.success(stationDeviceManageService.selectStationDeviceManageById(deviceId));
    }

    /**
     * 新增油站设备管理
     */
    @PreAuthorize("@ss.hasPermi('station:manage:add')")
    @Log(title = "油站设备管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StationDeviceManage stationDeviceManage)
    {
        return toAjax(stationDeviceManageService.insertStationDeviceManage(stationDeviceManage));
    }

    /**
     * 修改油站设备管理
     */
    @PreAuthorize("@ss.hasPermi('station:manage:edit')")
    @Log(title = "油站设备管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StationDeviceManage stationDeviceManage)
    {
        return toAjax(stationDeviceManageService.updateStationDeviceManage(stationDeviceManage));
    }

    /**
     * 删除油站设备管理
     */
    @PreAuthorize("@ss.hasPermi('station:manage:remove')")
    @Log(title = "油站设备管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceIds}")
    public AjaxResult remove(@PathVariable Long[] deviceIds)
    {
        return toAjax(stationDeviceManageService.deleteStationDeviceManageByIds(deviceIds));
    }
}
