package com.goafanti.common.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.goafanti.common.dao.SysDictMapper;
import com.goafanti.common.utils.LoggerUtils;
@Service
public class SysDictService {
	@Autowired
	SysDictMapper		sysDictMapper;
	
	private static final Logger	logger	= LoggerFactory.getLogger(SysDictService.class);
	
	@Cacheable(value = "SysDictCache", key = "'SysDict:'+#id")
	public String getValue(String id){
		LoggerUtils.debug(logger, "缓存字典:[%s]", id);
		return sysDictMapper.selectByPrimaryKey(id).getValue();
	}
	
	@CacheEvict(value = "SysDictCache", key = "'SysDict:'+#id")
	public void clear(String id) {
		LoggerUtils.debug(logger, "清除字典缓存:[%s]", id);
	}
}
