package cn.cecep.talroad.service.impl;

import cn.cecep.talroad.common.redis.service.RedisService;
import cn.cecep.talroad.domain.BasThresholdConfig;
import cn.cecep.talroad.mapper.BasThresholdConfigMapper;
import cn.cecep.talroad.service.IBasThresholdConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;




/**
 * 关联分析-阈值设置Service业务层处理
 *
 * @author szhpt
 * @date 2023-05-18*/
@Service
public class BasThresholdConfigServiceImpl extends ServiceImpl<BasThresholdConfigMapper,BasThresholdConfig> implements IBasThresholdConfigService
{
    @Autowired
    private BasThresholdConfigMapper basThresholdConfigMapper;
    @Autowired
    private RedisService redisService;

    /**
     * 查询关联分析-阈值设置列表
     *
     * @param basThresholdConfig 关联分析-阈值设置
     * @return 关联分析-阈值设置
     */
    @Override
    public List<BasThresholdConfig> selectBasThresholdConfigList(BasThresholdConfig basThresholdConfig)
    {
        return basThresholdConfigMapper.selectBasThresholdConfigList(basThresholdConfig);
    }

    @Override
    public BasThresholdConfig selectByParamCode(String paramCode) {
        BasThresholdConfig config = redisService.getCacheObject(BasThresholdConfig.tableKey+paramCode);
        if(config==null){
            config = basThresholdConfigMapper.selectByParamCode(paramCode);
            redisService.setCacheObject(BasThresholdConfig.tableKey+paramCode,config,1L, TimeUnit.DAYS);
        }
        return config;
    }

}
