package com.ruoyi.ems.base.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ems.base.domain.EmsBaseEnergyPrice;
import com.ruoyi.ems.base.service.IEmsBaseEnergyPriceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 能源月份单价Controller
 * 
 * @author Yinq
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/ems/base/baseEnergyPrice")
public class EmsBaseEnergyPriceController extends BaseController
{
    @Autowired
    private IEmsBaseEnergyPriceService emsBaseEnergyPriceService;

    /**
     * 查询能源月份单价列表
     */
    @PreAuthorize("@ss.hasPermi('ems/base:baseEnergyPrice:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmsBaseEnergyPrice emsBaseEnergyPrice)
    {
        startPage();
        List<EmsBaseEnergyPrice> list = emsBaseEnergyPriceService.selectEmsBaseEnergyPriceList(emsBaseEnergyPrice);
        return getDataTable(list);
    }

    /**
     * 导出能源月份单价列表
     */
    @PreAuthorize("@ss.hasPermi('ems/base:baseEnergyPrice:export')")
    @Log(title = "能源月份单价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmsBaseEnergyPrice emsBaseEnergyPrice)
    {
        List<EmsBaseEnergyPrice> list = emsBaseEnergyPriceService.selectEmsBaseEnergyPriceList(emsBaseEnergyPrice);
        ExcelUtil<EmsBaseEnergyPrice> util = new ExcelUtil<EmsBaseEnergyPrice>(EmsBaseEnergyPrice.class);
        util.exportExcel(response, list, "能源月份单价数据");
    }

    /**
     * 获取能源月份单价详细信息
     */
    @PreAuthorize("@ss.hasPermi('ems/base:baseEnergyPrice:query')")
    @GetMapping(value = "/{objId}")
    public AjaxResult getInfo(@PathVariable("objId") Long objId)
    {
        return success(emsBaseEnergyPriceService.selectEmsBaseEnergyPriceByObjId(objId));
    }

    /**
     * 新增能源月份单价
     */
    @PreAuthorize("@ss.hasPermi('ems/base:baseEnergyPrice:add')")
    @Log(title = "能源月份单价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmsBaseEnergyPrice emsBaseEnergyPrice)
    {
        return toAjax(emsBaseEnergyPriceService.insertEmsBaseEnergyPrice(emsBaseEnergyPrice));
    }

    /**
     * 修改能源月份单价
     */
    @PreAuthorize("@ss.hasPermi('ems/base:baseEnergyPrice:edit')")
    @Log(title = "能源月份单价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmsBaseEnergyPrice emsBaseEnergyPrice)
    {
        return toAjax(emsBaseEnergyPriceService.updateEmsBaseEnergyPrice(emsBaseEnergyPrice));
    }

    /**
     * 删除能源月份单价
     */
    @PreAuthorize("@ss.hasPermi('ems/base:baseEnergyPrice:remove')")
    @Log(title = "能源月份单价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{objIds}")
    public AjaxResult remove(@PathVariable Long[] objIds)
    {
        return toAjax(emsBaseEnergyPriceService.deleteEmsBaseEnergyPriceByObjIds(objIds));
    }
}
