|
|
|
@ -9,6 +9,7 @@ import com.luoo.music.dto.request.cms.JournalPublishReq;
|
|
|
|
|
import com.luoo.music.dto.request.cms.JournalQueryModel;
|
|
|
|
|
import com.luoo.music.dto.response.cms.JournalListRespDto;
|
|
|
|
|
import com.luoo.music.dto.response.cms.JournalRespDto;
|
|
|
|
|
import com.luoo.music.listener.CleanJournalCache;
|
|
|
|
|
import com.luoo.music.service.CMSJournalService;
|
|
|
|
|
import com.luoo.music.service.S3Service;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
@ -35,9 +36,8 @@ public class CMSJournalController {
|
|
|
|
|
private CMSJournalService journalService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private S3Service s3Service;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private CacheChannel cacheChannel;
|
|
|
|
|
private CleanJournalCache cleanJournalCache;
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "查询期刊列表", notes = "查询期刊列表")
|
|
|
|
|
@RequestMapping(value="/search/{page}/{size}", method= RequestMethod.POST)
|
|
|
|
@ -50,20 +50,10 @@ public class CMSJournalController {
|
|
|
|
|
@ApiOperation(value = "新增期刊", notes = "新增期刊")
|
|
|
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
|
|
|
|
public Result add(@ApiParam(value = "期刊信息", required = true) @Valid @RequestBody JournalAddModel addModel){
|
|
|
|
|
cleanCache();
|
|
|
|
|
cleanJournalCache.cleanCache();
|
|
|
|
|
return journalService.add(addModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cleanCache() {
|
|
|
|
|
try {
|
|
|
|
|
cacheChannel.evict("default", "journal_filter");
|
|
|
|
|
cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE);
|
|
|
|
|
cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_COUNT);
|
|
|
|
|
}catch(Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "查询期刊详情", notes = "查询期刊详情")
|
|
|
|
|
@RequestMapping(value="/{id}",method= RequestMethod.GET)
|
|
|
|
|
public Result<JournalRespDto> findOne(@ApiParam(value = "期刊ID", required = true) @PathVariable String id){
|
|
|
|
@ -74,7 +64,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){
|
|
|
|
|
cleanCache(id);
|
|
|
|
|
cleanJournalCache.cleanCache(id);
|
|
|
|
|
return journalService.update(id, updateModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -82,36 +72,22 @@ 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);
|
|
|
|
|
cleanJournalCache.cleanCache(id);
|
|
|
|
|
return journalService.publish(id, queryModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cleanCache(String id) {
|
|
|
|
|
try {
|
|
|
|
|
cacheChannel.evict("default", "journal_filter");
|
|
|
|
|
cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE);
|
|
|
|
|
cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_COUNT);
|
|
|
|
|
cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, id);
|
|
|
|
|
String journalNo=journalService.findJournalNoById(id);
|
|
|
|
|
cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_SONG_LIST, journalNo);
|
|
|
|
|
cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalNo);
|
|
|
|
|
}catch(Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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){
|
|
|
|
|
cleanCache(id);
|
|
|
|
|
cleanJournalCache.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){
|
|
|
|
|
cleanCache(id);
|
|
|
|
|
cleanJournalCache.cleanCache(id);
|
|
|
|
|
return journalService.deleteById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|