Commit 2abb920c authored by 刘基明's avatar 刘基明

删除主题缓存

parent 55148357
...@@ -175,13 +175,14 @@ public class ThemeManager { ...@@ -175,13 +175,14 @@ public class ThemeManager {
//附件校验 //附件校验
checkAttachment(req.getContent()); checkAttachment(req.getContent());
if (StringUtils.isEmpty(req.getEditThemeId())) { if (StringUtils.isBlank(req.getEditThemeId())) {
// 新建 // 新建
themeService.insertTheme(themeEntity); themeService.insertTheme(themeEntity);
} else { } else {
// 修改 // 修改
themeService.update(themeEntity, req.getEditThemeId()); themeService.update(themeEntity, req.getEditThemeId());
themeEntity.setThemeId(req.getEditThemeId()); themeEntity.setThemeId(req.getEditThemeId());
this.evictThemeCache(req.getEditThemeId());
} }
// 保存附件表 // 保存附件表
List<ThemeAttachmentEntity> themeAttachments = ConvertUtil.themeReqToAttachmentList(req, themeEntity.getThemeId()); List<ThemeAttachmentEntity> themeAttachments = ConvertUtil.themeReqToAttachmentList(req, themeEntity.getThemeId());
...@@ -230,13 +231,14 @@ public class ThemeManager { ...@@ -230,13 +231,14 @@ public class ThemeManager {
.themeType(ThemeTypeEnum.FORWARD.getCode()) .themeType(ThemeTypeEnum.FORWARD.getCode())
.build(); .build();
if (StringUtils.isEmpty(req.getEditThemeId()) || req.getEditThemeId().equals(req.getFormerThemeId())) { if (StringUtils.isBlank(req.getEditThemeId()) || req.getEditThemeId().equals(req.getFormerThemeId())) {
// 新建 // 新建
themeService.insertTheme(themeEntity); themeService.insertTheme(themeEntity);
} else { } else {
// 修改 // 修改
themeService.update(themeEntity, req.getEditThemeId()); themeService.update(themeEntity, req.getEditThemeId());
themeEntity.setThemeId(req.getEditThemeId()); themeEntity.setThemeId(req.getEditThemeId());
this.evictThemeCache(req.getEditThemeId());
} }
try { try {
...@@ -537,6 +539,8 @@ public class ThemeManager { ...@@ -537,6 +539,8 @@ public class ThemeManager {
// 逻辑删除主题,校验用户 // 逻辑删除主题,校验用户
public void delete(String themeId, String userId) { public void delete(String themeId, String userId) {
themeService.deleteById(themeId, userId); themeService.deleteById(themeId, userId);
this.evictThemeCache(themeId);
} }
...@@ -685,4 +689,9 @@ public class ThemeManager { ...@@ -685,4 +689,9 @@ public class ThemeManager {
themeQo.setWorkshopIntroduction(userInfo.getWorkshopIntroduction()); themeQo.setWorkshopIntroduction(userInfo.getWorkshopIntroduction());
} }
private void evictThemeCache(String themeId){
redisCache.evict(StringUtils.joinWith("_", CACHE_FORMER_THEME_ID, themeId));
redisCache.evict(StringUtils.joinWith("_", CACHE_THEME_ID, themeId));
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment