|
|
@@ -1,6 +1,9 @@
|
|
|
package com.goafanti.fragment.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.CachePut;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -8,6 +11,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import com.goafanti.common.dao.HtmlFragmentMapper;
|
|
|
import com.goafanti.common.model.HtmlFragment;
|
|
|
+import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
|
|
|
@Service
|
|
|
@@ -15,12 +19,19 @@ import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
public class FragmentService extends BaseMybatisDao<HtmlFragmentMapper> {
|
|
|
@Autowired
|
|
|
HtmlFragmentMapper htmlFragmentMapper;
|
|
|
+
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(FragmentService.class);
|
|
|
|
|
|
@Cacheable(value = "HtmlFragmentCache", key = "'HtmlFragment:'+#id")
|
|
|
public String selectById(String id) {
|
|
|
HtmlFragment hf = htmlFragmentMapper.selectByPrimaryKey(id);
|
|
|
return hf == null ? "" : hf.getContent();
|
|
|
}
|
|
|
+
|
|
|
+ @CacheEvict(value = "HtmlFragmentCache", key = "'HtmlFragment:'+#id")
|
|
|
+ public void clean(String id) {
|
|
|
+ LoggerUtils.debug(logger, "清除页面缓存:[%s]", id);
|
|
|
+ }
|
|
|
|
|
|
@CachePut(value = "HtmlFragmentCache", key = "'HtmlFragment:'+#id")
|
|
|
public String save(String id, String content) {
|