package com.goafanti.common.service; import java.util.List; 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.FieldGlossoryMapper; import com.goafanti.common.model.FieldGlossory; import com.goafanti.common.utils.LoggerUtils; @Service public class FieldGlossoryService { @Autowired FieldGlossoryMapper fieldGlossoryMapper; private static final Logger logger = LoggerFactory.getLogger(FieldGlossoryService.class); @Cacheable(value = "FieldGlossoryCache", key = "'FieldGlossory:'+#id") public String getName(Integer id){ LoggerUtils.debug(logger, "缓存领域列表:[%s]", id); FieldGlossory nameid = fieldGlossoryMapper.selectByPrimaryKey(id); String name = nameid.getName(); return name; } @CacheEvict(value = "FieldGlossoryCache", key = "'FieldGlossory:'+#id") public void clear(Integer id) { LoggerUtils.debug(logger, "清除领域列表缓存:[%s]", id); } public List getField(Integer pid, Integer level){ return fieldGlossoryMapper.getField(pid,level); } }