@ -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.request.cms.JournalQueryModel ;
import com.luoo.music.dto.response.cms.JournalListRespDto ;
import com.luoo.music.dto.response.cms.JournalListRespDto ;
import com.luoo.music.dto.response.cms.JournalRespDto ;
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.CMSJournalService ;
import com.luoo.music.service.S3Service ;
import com.luoo.music.service.S3Service ;
import io.swagger.annotations.Api ;
import io.swagger.annotations.Api ;
@ -35,9 +36,8 @@ public class CMSJournalController {
private CMSJournalService journalService ;
private CMSJournalService journalService ;
@Autowired
@Autowired
private S3Service s3Service ;
private S3Service s3Service ;
@Autowired
@Autowired
private C acheChannel cacheChannel ;
private C leanJournalCache cleanJournalCache ;
@ApiOperation ( value = "查询期刊列表" , notes = "查询期刊列表" )
@ApiOperation ( value = "查询期刊列表" , notes = "查询期刊列表" )
@RequestMapping ( value = "/search/{page}/{size}" , method = RequestMethod . POST )
@RequestMapping ( value = "/search/{page}/{size}" , method = RequestMethod . POST )
@ -50,20 +50,10 @@ public class CMSJournalController {
@ApiOperation ( value = "新增期刊" , notes = "新增期刊" )
@ApiOperation ( value = "新增期刊" , notes = "新增期刊" )
@RequestMapping ( value = "/add" , method = RequestMethod . POST )
@RequestMapping ( value = "/add" , method = RequestMethod . POST )
public Result add ( @ApiParam ( value = "期刊信息" , required = true ) @Valid @RequestBody JournalAddModel addModel ) {
public Result add ( @ApiParam ( value = "期刊信息" , required = true ) @Valid @RequestBody JournalAddModel addModel ) {
clean Cache( ) ;
clean JournalCache. clean Cache( ) ;
return journalService . add ( addModel ) ;
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 = "查询期刊详情" )
@ApiOperation ( value = "查询期刊详情" , notes = "查询期刊详情" )
@RequestMapping ( value = "/{id}" , method = RequestMethod . GET )
@RequestMapping ( value = "/{id}" , method = RequestMethod . GET )
public Result < JournalRespDto > findOne ( @ApiParam ( value = "期刊ID" , required = true ) @PathVariable String id ) {
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 )
@RequestMapping ( value = "/{id}" , method = RequestMethod . PUT )
public Result update ( @ApiParam ( value = "期刊ID" , required = true ) @PathVariable String id ,
public Result update ( @ApiParam ( value = "期刊ID" , required = true ) @PathVariable String id ,
@ApiParam ( value = "期刊信息" , required = true ) @RequestBody JournalAddModel updateModel ) {
@ApiParam ( value = "期刊信息" , required = true ) @RequestBody JournalAddModel updateModel ) {
clean Cache( id ) ;
clean JournalCache. clean Cache( id ) ;
return journalService . update ( id , updateModel ) ;
return journalService . update ( id , updateModel ) ;
}
}
@ -82,36 +72,22 @@ public class CMSJournalController {
@RequestMapping ( value = "/publish/{id}" , method = RequestMethod . PUT )
@RequestMapping ( value = "/publish/{id}" , method = RequestMethod . PUT )
public Result publish ( @ApiParam ( value = "期刊ID" , required = true ) @PathVariable String id ,
public Result publish ( @ApiParam ( value = "期刊ID" , required = true ) @PathVariable String id ,
@ApiParam ( value = "期刊发布请求对象" , required = true ) @RequestBody JournalPublishReq queryModel ) {
@ApiParam ( value = "期刊发布请求对象" , required = true ) @RequestBody JournalPublishReq queryModel ) {
clean Cache( id ) ;
clean JournalCache. clean Cache( id ) ;
return journalService . publish ( id , queryModel ) ;
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 = "更新期刊启停状态" )
@ApiOperation ( value = "更新期刊启停状态" , notes = "更新期刊启停状态" )
@RequestMapping ( value = "/update/state/{id}" , method = RequestMethod . PUT )
@RequestMapping ( value = "/update/state/{id}" , method = RequestMethod . PUT )
public Result updateColumnState ( @ApiParam ( value = "期刊ID" , required = true ) @PathVariable String id ,
public Result updateColumnState ( @ApiParam ( value = "期刊ID" , required = true ) @PathVariable String id ,
@ApiParam ( value = "期刊启停状态, 0:停用, 1:启用" , required = true ) @RequestBody String state ) {
@ApiParam ( value = "期刊启停状态, 0:停用, 1:启用" , required = true ) @RequestBody String state ) {
clean Cache( id ) ;
cleanJournalCache . cleanCache ( id ) ;
return journalService . updateJournalState ( id , state ) ;
return journalService . updateJournalState ( id , state ) ;
}
}
@ApiOperation ( value = "删除单条期刊" , notes = "物理删除" )
@ApiOperation ( value = "删除单条期刊" , notes = "物理删除" )
@RequestMapping ( value = "/{id}" , method = RequestMethod . DELETE )
@RequestMapping ( value = "/{id}" , method = RequestMethod . DELETE )
public Result delete ( @ApiParam ( value = "期刊ID" , required = true ) @PathVariable String id ) {
public Result delete ( @ApiParam ( value = "期刊ID" , required = true ) @PathVariable String id ) {
clean Cache( id ) ;
cleanJournalCache . cleanCache ( id ) ;
return journalService . deleteById ( id ) ;
return journalService . deleteById ( id ) ;
}
}