Forráskód Böngészése

1、增加web内容管理缓存

rayson 7 hónapja
szülő
commit
10fa723f1d

+ 5 - 0
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/dal/redis/RedisKeyConstants.java

@@ -174,4 +174,9 @@ public interface RedisKeyConstants {
      * 企业用户查看人才权限
      **/
     String MDE_AUTH_ENTERPRISE_USER_VIEW_PERMISSION = "mde_auth_enterprise_user_look_person_permission:%s-%s";
+
+    /**
+     * web页面内容缓存
+     **/
+    String MDE_WEB_CONTENT = "mde_web_content:%s";
 }

+ 7 - 0
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/service/web/WebContentServiceImpl.java

@@ -7,6 +7,9 @@ import com.citu.module.menduner.system.controller.base.web.WebContentPageReqVO;
 import com.citu.module.menduner.system.controller.base.web.WebContentSaveReqVO;
 import com.citu.module.menduner.system.dal.dataobject.web.WebContentDO;
 import com.citu.module.menduner.system.dal.mysql.web.WebContentMapper;
+import com.citu.module.menduner.system.dal.redis.RedisKeyConstants;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 
@@ -37,6 +40,7 @@ public class WebContentServiceImpl implements WebContentService {
     }
 
     @Override
+    @CacheEvict(value = RedisKeyConstants.MDE_WEB_CONTENT, key = "#updateReqVO.id")
     public void updateWebContent(WebContentSaveReqVO updateReqVO) {
         // 校验存在
         validateWebContentExists(updateReqVO.getId());
@@ -46,6 +50,7 @@ public class WebContentServiceImpl implements WebContentService {
     }
 
     @Override
+    @CacheEvict(value = RedisKeyConstants.MDE_WEB_CONTENT, key = "#id")
     public void deleteWebContent(Long id) {
         // 校验存在
         validateWebContentExists(id);
@@ -60,6 +65,8 @@ public class WebContentServiceImpl implements WebContentService {
     }
 
     @Override
+    @Cacheable(cacheNames = RedisKeyConstants.MDE_WEB_CONTENT+ "#1h", key = "#id",
+            unless = "#result == null")
     public WebContentDO getWebContent(Long id) {
         return webContentMapper.selectById(id);
     }