package com.wechat.dao;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import com.wechat.common.Constants;
import com.wechat.common.utils.DateUtils;
import com.wechat.common.utils.StringsUtils;
import com.wechat.global.base.dao.RedisSetDao;

/**
 * This is test for Git Stash
 * @author Administrator
 *
 */
@Repository
public class JobUvRedisDao extends RedisSetDao<String>  {
	//PV/UV记录失效时间(一周 7天 )
	@Value("#{configProperties['pvuv.expired.days']}")
	private Integer uvExpiredDays;
    
    public void insertUv(String id, String value) {
    	//按日期统计
        String uvKey = Constants.REDIS_JOB_UV + DateUtils.getLocalDateNowStr(DateUtils.PATTEN_YMD)+Constants.UNDER_LINE;
    	if(!StringsUtils.isEmpty(id))
    	{
    		String key = uvKey+id;
        	if(super.hasKey(key))
        	{
        		super.insert(key, value);
        	} else {
        		super.insertDay(key, value, uvExpiredDays);
        	}
    	}
    }

}
