package com.yunyan.business.service.impl;

import com.yunyan.business.constant.BusinessCacheConstants;
import com.yunyan.business.pojo.admin.dto.FinalDataListDto;
import com.yunyan.business.service.ICommonUtilService;
import com.yunyan.common.core.redis.RedisCache;
import com.yunyan.common.exception.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ICommonUtilServiceImpl implements ICommonUtilService {
    @Autowired
    private RedisCache redisCache;

    @Override
    public void checkWebsiteFillRedisStatus(FinalDataListDto dto) {
        //判断 redis 是否存在
        //String redisKey = BusinessCacheConstants.WEBSITE_FILL_STATUS_CHECK + dto.getYear() + ":" + dto.getType();
        String redisKey = BusinessCacheConstants.WEBSITE_FILL_STATUS_CHECK;
        if (redisCache.hasKey(redisKey)) {
            log.error("正在检测公开网址中, 请稍后再试~");
            throw new ServiceException("正在检测公开网址中, 请稍后再试~");
        }
    }
}
