package com.iamberry.wechat.service.system;

import java.util.List;

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

import com.iamberry.cache.LocalCache;
import com.iamberry.wechat.core.entity.admin.ShopSystemRule;
import com.iamberry.wechat.face.admin.SystemService;
import com.iamberry.wechat.service.system.dao.SystemDao;
@Service
public class SystemServiceImpl implements SystemService {

	@Autowired
	private SystemDao systemDao;
	
	private LocalCache<String, ShopSystemRule> cache = new LocalCache<>(300);

	@Override
	public ShopSystemRule selectOneShopRuleById(Integer id) {
		// TODO Auto-generated method stub
		ShopSystemRule rule = cache.get("shopRule_"+id);
		if (rule != null) {
			return rule;
		}
		rule = systemDao.selectOneShopRuleById(id);
		cache.put("shopRule_"+rule.getRuleId(), rule);
		return rule;
	}

	@Override
	public ShopSystemRule selectOneShopRuleByIdDynamic(Integer id) {
		return systemDao.selectOneShopRuleById(id);
	}


	/**
	 * 查询所有系统规则
	 * 2016年5月4日
	 */
	public List<ShopSystemRule> selectAllShopRule(){
		return systemDao.selectAllShopRule();
	}
}