package com.sqx.modules.app.service.impl;

import com.sqx.common.utils.RedisUtils;
import com.sqx.modules.app.service.AdService;
import com.sqx.modules.redisService.impl.RedisServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class AdServiceImpl implements AdService {

    private final RedisServiceImpl redisServiceImpl;

    public AdServiceImpl(RedisServiceImpl redisServiceImpl) {
        this.redisServiceImpl = redisServiceImpl;
    }

    @Override
    public HashMap<String, Object> getDetail(Long userId) {
        Long freeWatchRemainTime = redisServiceImpl.getFreeWatchRemainTime(userId, false);
        Long permanentlyFreeWatchRemainTime = redisServiceImpl.getFreeWatchRemainTime(userId, true);
        return new HashMap<String, Object>(){{
            put("adFreeWatchTime", permanentlyFreeWatchRemainTime);
            put("payFreeWatchTime", freeWatchRemainTime);
            put("totalFreeWatchTime", freeWatchRemainTime + permanentlyFreeWatchRemainTime);
        }};
    }
}
