diff --git a/luoo_music/src/main/java/com/luoo/music/config/SaticScheduleTask.java b/luoo_music/src/main/java/com/luoo/music/config/SaticScheduleTask.java index 0f7efd7..16b5514 100644 --- a/luoo_music/src/main/java/com/luoo/music/config/SaticScheduleTask.java +++ b/luoo_music/src/main/java/com/luoo/music/config/SaticScheduleTask.java @@ -107,6 +107,7 @@ public class SaticScheduleTask { journal.setNameChTags(tagStr); journalDao.save(journal); this.cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, journal.getId()); + this.cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journal.getJournalNo()); updateCounter.incrementAndGet(); } } diff --git a/luoo_music/src/main/java/com/luoo/music/controller/CMSJournalController.java b/luoo_music/src/main/java/com/luoo/music/controller/CMSJournalController.java index 561af8e..28a57ab 100644 --- a/luoo_music/src/main/java/com/luoo/music/controller/CMSJournalController.java +++ b/luoo_music/src/main/java/com/luoo/music/controller/CMSJournalController.java @@ -66,6 +66,8 @@ public class CMSJournalController { public Result update(@ApiParam(value = "期刊ID", required = true) @PathVariable String id, @ApiParam(value = "期刊信息", required = true) @RequestBody JournalAddModel updateModel){ cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE); + cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, id); + cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalService.findJournalNoById(id)); return journalService.update(id, updateModel); } @@ -75,6 +77,8 @@ public class CMSJournalController { @ApiParam(value = "期刊发布请求对象", required = true) @RequestBody JournalPublishReq queryModel){ cacheChannel.evict("default", "journal_filter"); cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE); + cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, id); + cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalService.findJournalNoById(id)); return journalService.publish(id, queryModel); } @@ -83,6 +87,8 @@ public class CMSJournalController { public Result updateColumnState(@ApiParam(value = "期刊ID", required = true) @PathVariable String id, @ApiParam(value = "期刊启停状态,0:停用,1:启用", required = true) @RequestBody String state){ cacheChannel.evict("default", "journal_filter"); + cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, id); + cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalService.findJournalNoById(id)); cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE); return journalService.updateJournalState(id, state); } @@ -91,6 +97,8 @@ public class CMSJournalController { @RequestMapping(value="/{id}", method= RequestMethod.DELETE) public Result delete(@ApiParam(value = "期刊ID", required = true) @PathVariable String id){ cacheChannel.evict("default", "journal_filter"); + cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, id); + cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalService.findJournalNoById(id)); cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE); return journalService.deleteById(id); } diff --git a/luoo_music/src/main/java/com/luoo/music/dao/JournalDao.java b/luoo_music/src/main/java/com/luoo/music/dao/JournalDao.java index 4d756de..3882e3d 100644 --- a/luoo_music/src/main/java/com/luoo/music/dao/JournalDao.java +++ b/luoo_music/src/main/java/com/luoo/music/dao/JournalDao.java @@ -88,5 +88,8 @@ public interface JournalDao extends JpaRepository,JpaSpecificati @Query(value = "select * from tb_journal where match(journal_no, title) against(?1 IN BOOLEAN MODE) limit ?2,?3 ", nativeQuery = true) List fuzzySearch(String keyword, int offset, int limit); + + @Query(value = "select journal_no FROM tb_journal where id=?1", nativeQuery = true) + String findJournalNoById(String journalId); } diff --git a/luoo_music/src/main/java/com/luoo/music/listener/CleanJournalQueryPageListener.java b/luoo_music/src/main/java/com/luoo/music/listener/CleanJournalQueryPageListener.java index df60096..3d00ef9 100644 --- a/luoo_music/src/main/java/com/luoo/music/listener/CleanJournalQueryPageListener.java +++ b/luoo_music/src/main/java/com/luoo/music/listener/CleanJournalQueryPageListener.java @@ -34,6 +34,7 @@ public class CleanJournalQueryPageListener { String journalQueryPageKey = getJournalQueryPageKey(optional.get()); cacheChannel.evict(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE, journalQueryPageKey); cacheChannel.evict(Constants.J2CACHE_REGION_JOURNAL_ID,journalId); + cacheChannel.evict(Constants.J2CACHE_REGION_JOURNAL_NO,optional.get().getJournalNo()); } private String getJournalQueryPageKey(Journal journal) { diff --git a/luoo_music/src/main/java/com/luoo/music/service/CMSJournalService.java b/luoo_music/src/main/java/com/luoo/music/service/CMSJournalService.java index 3a00060..f80dde3 100644 --- a/luoo_music/src/main/java/com/luoo/music/service/CMSJournalService.java +++ b/luoo_music/src/main/java/com/luoo/music/service/CMSJournalService.java @@ -424,6 +424,7 @@ public class CMSJournalService { newJournal.setPubTime(oldJournal.getPubTime()); Journal journal = journalDao.save(newJournal); this.cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, id); + this.cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journal.getJournalNo()); // 删除旧的关联信息,更新的关联信息 batchDeleteJournalRelatesInfo(id, oldJournal.getJournalNo()); batchSaveJournalRelatesInfo(id, param); @@ -485,4 +486,9 @@ public class CMSJournalService { } return Result.success(); } + + public String findJournalNoById(String journalId) { + String journalNo = journalDao.findJournalNoById(journalId); + return null==journalNo?"invalidJournalNo":journalNo; + } }