@ -84,27 +84,6 @@ public class JournalController {
return Result . success ( new PageResult < JournalRespDTO > ( Long . valueOf ( pageList . size ( ) ) , pageList ) ) ;
return Result . success ( new PageResult < JournalRespDTO > ( Long . valueOf ( pageList . size ( ) ) , pageList ) ) ;
}
}
private JournalRespDTO randomCDN1 ( JournalRespDTO journalRespDTO ) {
// Random random = new Random();
// int randomNum = random.nextInt(2)+1;
Random random = new Random ( ) ;
int rate = random . nextInt ( 100 ) ;
// int randomNum = random.nextInt(2)+1;
int randomNum = 1 ;
if ( rate > 20 ) {
randomNum = 2 ;
}
if ( StringUtils . isNotEmpty ( journalRespDTO . getImage ( ) ) ) {
journalRespDTO . setImage ( journalRespDTO . getImage ( ) . replaceFirst ( "cdn1" , "cdn" + randomNum ) ) ;
journalRespDTO . setImage ( journalRespDTO . getImage ( ) . replaceFirst ( "cdn2" , "cdn" + randomNum ) ) ;
}
return journalRespDTO ;
}
private void updateCollectStatus ( List < JournalRespDTO > pageList , Set < String > journalCollectSet ) {
private void updateCollectStatus ( List < JournalRespDTO > pageList , Set < String > journalCollectSet ) {
pageList . forEach ( j - > {
pageList . forEach ( j - > {
j . setHaveCollect ( journalCollectSet . contains ( j . getId ( ) ) ) ;
j . setHaveCollect ( journalCollectSet . contains ( j . getId ( ) ) ) ;
@ -272,18 +251,20 @@ public class JournalController {
return Result . success ( journalService . getJournalFilterDTO ( ) ) ;
return Result . success ( journalService . getJournalFilterDTO ( ) ) ;
}
}
@ApiOperation ( value = "5.根据当前期刊的标签推荐 6期 类似期刊")
@ApiOperation ( value = "5.根据当前期刊的标签推荐 类似期刊, 默认6期 ")
@GetMapping ( "/recommend/{id}" )
@GetMapping ( value = { "/recommend/{id}" , "/recommend/{id}/{limit}" } )
@GlobalInterceptor
@GlobalInterceptor
public Result < List < JournalRespDTO > > recommendById (
public Result < List < JournalRespDTO > > recommendById (
@RequestHeader ( value = "Authorization" , required = false ) String authorization ,
@RequestHeader ( value = "Authorization" , required = false ) String authorization ,
@PathVariable @VerifyParam ( required = true ) String id ) {
@PathVariable @VerifyParam ( required = true ) String id ,@PathVariable ( required = false ) Integer limit ) {
UserLoginDto user = jwtUtil . getUserLoginDto ( authorization ) ;
UserLoginDto user = jwtUtil . getUserLoginDto ( authorization ) ;
if ( null = = user & & ! journalService . isLatest10ByJournalId ( id ) ) {
if ( null = = user & & ! journalService . isLatest10ByJournalId ( id ) ) {
return Result . unauthorized ( null ) ;
return Result . unauthorized ( null ) ;
}
}
if ( null = = limit ) {
List < Journal > journals = journalService . recommendById ( id ) ;
limit = 6 ;
}
List < Journal > journals = journalService . recommendById ( id , limit ) ;
List < String > ids = journals . stream ( ) . map ( Journal : : getId ) . collect ( Collectors . toList ( ) ) ;
List < String > ids = journals . stream ( ) . map ( Journal : : getId ) . collect ( Collectors . toList ( ) ) ;
Set < String > journalCollectSet = null = = user ? Collections . emptySet ( )
Set < String > journalCollectSet = null = = user ? Collections . emptySet ( )
: userCollectInfoService . getCollectSet ( user . getUserId ( ) , ids , CollectTypeEnum . JOURNAL ) ;
: userCollectInfoService . getCollectSet ( user . getUserId ( ) , ids , CollectTypeEnum . JOURNAL ) ;
@ -295,14 +276,14 @@ public class JournalController {
@ApiOperation ( value = "统计期刊的浏览数" , notes = "APP端打开期刊调用一次统计接口" )
@ApiOperation ( value = "统计期刊的浏览数" , notes = "APP端打开期刊调用一次统计接口" )
@ RequestMapping( value = "/stat/visits/{id}" , method = RequestMethod . PUT )
@ PutMapping( "/stat/visits/{id}" )
public Result statVisitsCount ( @ApiParam ( value = "期刊ID" , required = true ) @PathVariable String id ) {
public Result statVisitsCount ( @ApiParam ( value = "期刊ID" , required = true ) @PathVariable String id ) {
return journalService . statVisitsCount ( id ) ;
return journalService . statVisitsCount ( id ) ;
}
}
@GlobalInterceptor ( checkAppUserLogin = true )
@GlobalInterceptor ( checkAppUserLogin = true )
@ApiOperation ( value = "统计期刊的评论数" , notes = "APP端增加期刊时或删除评论时调用一次该接口, status根据操作类型对应传参" )
@ApiOperation ( value = "统计期刊的评论数" , notes = "APP端增加期刊时或删除评论时调用一次该接口, status根据操作类型对应传参" )
@ RequestMapping( value = "/stat/comment/{id}" , method = RequestMethod . PUT )
@ PutMapping( "/stat/comment/{id}" )
public Result statCommentCount ( @ApiParam ( value = "期刊ID" , required = true ) @PathVariable String id ,
public Result statCommentCount ( @ApiParam ( value = "期刊ID" , required = true ) @PathVariable String id ,
@ApiParam ( value = "状态, 1:增加评论, 0: 删除评论" , required = true ) @RequestBody String status ) {
@ApiParam ( value = "状态, 1:增加评论, 0: 删除评论" , required = true ) @RequestBody String status ) {
return journalService . statCommentCount ( id , status ) ;
return journalService . statCommentCount ( id , status ) ;