package com.wechat.dao;

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

import com.wechat.common.Constants;
import com.wechat.global.base.dao.RedisWithExpiryTimeDao;
import com.wechat.service.MdeOrdersService;

/**
 * This is test for Git Stash
 * 
 * @author Administrator
 *
 */
@Repository
public class RedisGoodsSaleDao{

	@Autowired
	RedisWithExpiryTimeDao baseRedisDao;
	
	public String selectSaleNum(int goodsId) {
		return baseRedisDao.select(Constants.REDIS_GOODS_SALE+String.valueOf(goodsId));
	}

	/**
	 * 存入缓存，30天后失效
	 * @param goodsId
	 * @param infoValue
	 */
	public void insertSaleNum(int goodsId, int infoValue) {
		baseRedisDao.insertDay(Constants.REDIS_GOODS_SALE+String.valueOf(goodsId), String.valueOf(infoValue), 30);
	}


	public void deleteSaleNum(int goodsId) {
		baseRedisDao.delete(Constants.REDIS_GOODS_SALE+String.valueOf(goodsId));
	}
	
   public Boolean hasSaleNum(int goodsId) {
       return baseRedisDao.hasKey(Constants.REDIS_GOODS_SALE+String.valueOf(goodsId));
    }

}
