1.add interface of recommend journal by user collect count

main
Gary 10 months ago
parent 75ff660319
commit df6dcab4d8

@ -268,12 +268,19 @@ public class JournalController {
List<String> ids=journals.stream().map(Journal::getId).collect(Collectors.toList());
Set<String> journalCollectSet = null == user ? Collections.emptySet()
: userCollectInfoService.getCollectSet(user.getUserId(),ids, CollectTypeEnum.JOURNAL);
List<JournalRespDTO> list = journals.stream().map(a -> JournalMapper.getJournalRespDTO(a, journalCollectSet))
List<JournalRespDTO> list = journals.stream().sorted(Comparator.comparing(Journal::getUserCollectCount).reversed()).map(a -> JournalMapper.getJournalRespDTO(a, journalCollectSet))
.collect(Collectors.toList());
return Result.success(list);
}
@ApiOperation(value = "5.1 根据收藏数推荐8期",notes="web 端用收藏数前50中随机取8期返回")
@GetMapping(value="/recommend")
@GlobalInterceptor
public Result<List<JournalRespDTO>> recommend() {
List<Journal> journals = journalService.recommend();
List<JournalRespDTO> list = journals.stream().sorted(Comparator.comparing(Journal::getUserCollectCount).reversed()).map(a -> JournalMapper.getJournalRespDTO(a))
.collect(Collectors.toList());
// list = list.stream().map(journalRespDTO -> randomCDN(journalRespDTO)).collect(Collectors.toList());
return Result.success(list);
}
@ApiOperation(value = "统计期刊的浏览数", notes = "APP端打开期刊调用一次统计接口")
@PutMapping("/stat/visits/{id}")

@ -91,5 +91,8 @@ public interface JournalDao extends JpaRepository<Journal,String>,JpaSpecificati
@Query(value = "select journal_no FROM tb_journal where id=?1", nativeQuery = true)
String findJournalNoById(String journalId);
@Query(value = "select tbl.* from (select tbl1.* from indie_music.tb_journal tbl1 order by user_collect_count DESC LIMIT 50) tbl order by rand() limit 8", nativeQuery = true)
List<Journal> recommend();
}

@ -43,6 +43,7 @@ public class JournalMapper {
journalRespDTO.setDate(getPublishDate(journal));
journalRespDTO.setHaveCollect(journalCollectSet.contains(journalRespDTO.getId()));
journalRespDTO.setIpLocation("广东");
journalRespDTO.setUserCollectCount(journal.getUserCollectCount());
String nameChTags=journal.getNameChTags();
if(!StringTools.isEmpty(nameChTags)) {

@ -429,4 +429,9 @@ public class JournalService {
public List<String> findImageByIds(List<String> objectIds) {
return objectIds.stream().map(this::queryJournalById).filter(Objects::nonNull).map(JournalRespDTO::getImage).collect(Collectors.toList());
}
public List<Journal> recommend() {
return journalDao.recommend();
}
}

Loading…
Cancel
Save