package com.ruoyi.ems.base.service.impl;

import java.util.List;

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ems.base.mapper.EmsBaseEnergyPriceMapper;
import com.ruoyi.ems.base.domain.EmsBaseEnergyPrice;
import com.ruoyi.ems.base.service.IEmsBaseEnergyPriceService;

/**
 * 能源月份单价Service业务层处理
 * 
 * @author Yinq
 * @date 2024-05-08
 */
@Service
public class EmsBaseEnergyPriceServiceImpl implements IEmsBaseEnergyPriceService 
{
    @Autowired
    private EmsBaseEnergyPriceMapper emsBaseEnergyPriceMapper;

    /**
     * 查询能源月份单价
     * 
     * @param objId 能源月份单价主键
     * @return 能源月份单价
     */
    @Override
    public EmsBaseEnergyPrice selectEmsBaseEnergyPriceByObjId(Long objId)
    {
        return emsBaseEnergyPriceMapper.selectEmsBaseEnergyPriceByObjId(objId);
    }

    /**
     * 查询能源月份单价列表
     * 
     * @param emsBaseEnergyPrice 能源月份单价
     * @return 能源月份单价
     */
    @Override
    public List<EmsBaseEnergyPrice> selectEmsBaseEnergyPriceList(EmsBaseEnergyPrice emsBaseEnergyPrice)
    {
        return emsBaseEnergyPriceMapper.selectEmsBaseEnergyPriceList(emsBaseEnergyPrice);
    }

    /**
     * 新增能源月份单价
     * 
     * @param emsBaseEnergyPrice 能源月份单价
     * @return 结果
     */
    @Override
    public int insertEmsBaseEnergyPrice(EmsBaseEnergyPrice emsBaseEnergyPrice)
    {
        try {
            emsBaseEnergyPrice.setCreateTime(DateUtils.getNowDate());
            emsBaseEnergyPriceMapper.insertEmsBaseEnergyPrice(emsBaseEnergyPrice);
        } catch (Exception e) {
            throw new ServiceException("能源月份重复！");
        }
        return 1;
    }

    /**
     * 修改能源月份单价
     * 
     * @param emsBaseEnergyPrice 能源月份单价
     * @return 结果
     */
    @Override
    public int updateEmsBaseEnergyPrice(EmsBaseEnergyPrice emsBaseEnergyPrice)
    {
        emsBaseEnergyPrice.setUpdateTime(DateUtils.getNowDate());
        return emsBaseEnergyPriceMapper.updateEmsBaseEnergyPrice(emsBaseEnergyPrice);
    }

    /**
     * 批量删除能源月份单价
     * 
     * @param objIds 需要删除的能源月份单价主键
     * @return 结果
     */
    @Override
    public int deleteEmsBaseEnergyPriceByObjIds(Long[] objIds)
    {
        return emsBaseEnergyPriceMapper.deleteEmsBaseEnergyPriceByObjIds(objIds);
    }

    /**
     * 删除能源月份单价信息
     * 
     * @param objId 能源月份单价主键
     * @return 结果
     */
    @Override
    public int deleteEmsBaseEnergyPriceByObjId(Long objId)
    {
        return emsBaseEnergyPriceMapper.deleteEmsBaseEnergyPriceByObjId(objId);
    }
}
