package com.ruoyi.ems.service.impl;

import com.huashe.common.exception.Assert;
import com.ruoyi.ems.domain.OpEnergyStrategyParam;
import com.ruoyi.ems.mapper.OpEnergyStrategyParamMapper;
import com.ruoyi.ems.service.IOpEnergyStrategyParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 能源策略参数Service业务层处理
 *
 * @author ruoyi
 * @date 2024-10-14
 */
@Service
public class OpEnergyStrategyParamServiceImpl implements IOpEnergyStrategyParamService {
    @Autowired
    private OpEnergyStrategyParamMapper paramMapper;

    @Override
    public List<OpEnergyStrategyParam> selectParamByStrategyCode(String strategyCode) {
        return paramMapper.selectParamByStrategyCode(strategyCode);
    }

    @Override
    public int updateParamValue(OpEnergyStrategyParam param) {
        Assert.notNull(param.getStrategyCode(), -1, "策略编码不能为空");
        Assert.notNull(param.getParamGroup(), -1, "策略分组不能为空");
        Assert.notNull(param.getParamKey(), -1, "策略参数键不能为空");

        return paramMapper.updateParamValue(param.getStrategyCode(), param.getParamGroup(), param.getParamKey(),
            param.getParamValue());
    }
}
