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 ad29d3c..b48be0b 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 @@ -65,10 +65,7 @@ public class CMSJournalController { @RequestMapping(value = "/{id}", method = RequestMethod.PUT) 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_SONG_LIST, id); - cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalService.findJournalNoById(id)); + cleanCache(id); return journalService.update(id, updateModel); } @@ -76,34 +73,31 @@ public class CMSJournalController { @RequestMapping(value="/publish/{id}",method= RequestMethod.PUT) public Result publish(@ApiParam(value = "期刊ID", required = true) @PathVariable String id, @ApiParam(value = "期刊发布请求对象", required = true) @RequestBody JournalPublishReq queryModel){ + cleanCache(id); + return journalService.publish(id, queryModel); + } + + private void cleanCache(String id) { 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_SONG_LIST, id); - cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalService.findJournalNoById(id)); - return journalService.publish(id, queryModel); - } + String journalNo=journalService.findJournalNoById(id); + cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_SONG_LIST, journalNo); + cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalNo); + } - @ApiOperation(value = "更新期刊启停状态", notes = "更新期刊启停状态") + @ApiOperation(value = "更新期刊启停状态", notes = "更新期刊启停状态") @RequestMapping(value="/update/state/{id}",method= RequestMethod.PUT) 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_SONG_LIST, id); - cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalService.findJournalNoById(id)); - cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE); + cleanCache(id); return journalService.updateJournalState(id, state); } @ApiOperation(value = "删除单条期刊", notes = "物理删除") @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_SONG_LIST, id); - cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalService.findJournalNoById(id)); - cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE); + cleanCache(id); return journalService.deleteById(id); }