1.fix recommend issue

main
Gary 10 months ago
parent 7ec1a49b79
commit c3352ac700

@ -76,5 +76,8 @@ public interface JournalDao extends JpaRepository<Journal,String>,JpaSpecificati
@Query(value = "select id from tb_journal where id not in ?2 order by rand() limit ?1", nativeQuery = true)
List<String> random(int limit, List<String> recommendIds);
@Query(value = "select id from tb_journal order by rand() limit ?1", nativeQuery = true)
List<String> random(int limit);
}

@ -306,7 +306,7 @@ public class JournalService {
List<String> recommendIds=journalTagDao.recommendByJournalId(id);
List<String> extraIds=Collections.emptyList();
if(recommendIds.size()<6) {
extraIds=journalDao.random(6-recommendIds.size(),recommendIds);
extraIds=recommendIds.isEmpty()?journalDao.random(6):journalDao.random(6-recommendIds.size(),recommendIds);
}
if(!extraIds.isEmpty()) {
recommendIds.addAll(extraIds);

Loading…
Cancel
Save