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

/**
 * 油品调价信息Controller
 * 
 * @author yijia
 * @date 2020-12-09
 */
@RestController
@RequestMapping("/station/adjust")
public class StationOilPriceAdjustController extends BaseController
{
    @Autowired
    private IStationOilPriceAdjustService stationOilPriceAdjustService;

    /**
     * 查询油品调价信息列表
     */
    @PreAuthorize("@ss.hasPermi('station:adjust:list')")
    @GetMapping("/list")
    public TableDataInfo list(StationOilPriceAdjust stationOilPriceAdjust)
    {
        startPage();
        List<StationOilPriceAdjust> list = stationOilPriceAdjustService.selectStationOilPriceAdjustList(stationOilPriceAdjust);
        return getDataTable(list);
    }

    /**
     * 导出油品调价信息列表
     */
    @PreAuthorize("@ss.hasPermi('station:adjust:export')")
    @Log(title = "油品调价信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StationOilPriceAdjust stationOilPriceAdjust)
    {
        List<StationOilPriceAdjust> list = stationOilPriceAdjustService.selectStationOilPriceAdjustList(stationOilPriceAdjust);
        ExcelUtil<StationOilPriceAdjust> util = new ExcelUtil<StationOilPriceAdjust>(StationOilPriceAdjust.class);
        return util.exportExcel(list, "adjust");
    }

    /**
     * 获取油品调价信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('station:adjust:query')")
    @GetMapping(value = "/{adjustPriceId}")
    public AjaxResult getInfo(@PathVariable("adjustPriceId") Long adjustPriceId)
    {
        return AjaxResult.success(stationOilPriceAdjustService.selectStationOilPriceAdjustById(adjustPriceId));
    }

    /**
     * 新增油品调价信息
     */
    @PreAuthorize("@ss.hasPermi('station:adjust:add')")
    @Log(title = "油品调价信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StationOilPriceAdjust stationOilPriceAdjust)
    {
        return toAjax(stationOilPriceAdjustService.insertStationOilPriceAdjust(stationOilPriceAdjust));
    }

    /**
     * 修改油品调价信息
     */
    @PreAuthorize("@ss.hasPermi('station:adjust:edit')")
    @Log(title = "油品调价信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StationOilPriceAdjust stationOilPriceAdjust)
    {
        return toAjax(stationOilPriceAdjustService.updateStationOilPriceAdjust(stationOilPriceAdjust));
    }

    /**
     * 删除油品调价信息
     */
    @PreAuthorize("@ss.hasPermi('station:adjust:remove')")
    @Log(title = "油品调价信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{adjustPriceIds}")
    public AjaxResult remove(@PathVariable Long[] adjustPriceIds)
    {
        return toAjax(stationOilPriceAdjustService.deleteStationOilPriceAdjustByIds(adjustPriceIds));
    }


}
