SysDictService.java 980 B

123456789101112131415161718192021222324252627282930
  1. package com.goafanti.common.service;
  2. import org.slf4j.Logger;
  3. import org.slf4j.LoggerFactory;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.cache.annotation.CacheEvict;
  6. import org.springframework.cache.annotation.Cacheable;
  7. import org.springframework.stereotype.Service;
  8. import com.goafanti.common.dao.SysDictMapper;
  9. import com.goafanti.common.utils.LoggerUtils;
  10. @Service
  11. public class SysDictService {
  12. @Autowired
  13. SysDictMapper sysDictMapper;
  14. private static final Logger logger = LoggerFactory.getLogger(SysDictService.class);
  15. @Cacheable(value = "SysDictCache", key = "'SysDict:'+#id")
  16. public String getValue(String id){
  17. LoggerUtils.debug(logger, "缓存字典:[%s]", id);
  18. return sysDictMapper.selectByPrimaryKey(id).getValue();
  19. }
  20. @CacheEvict(value = "SysDictCache", key = "'SysDict:'+#id")
  21. public void clear(String id) {
  22. LoggerUtils.debug(logger, "清除字典缓存:[%s]", id);
  23. }
  24. }