You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1.2 KiB
27 lines
1.2 KiB
package com.bupt.note.Repository;
|
|
|
|
import com.bupt.note.Model.Paper;
|
|
import org.springframework.data.jpa.repository.JpaRepository;
|
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
import org.springframework.data.jpa.repository.Query;
|
|
import org.springframework.data.repository.query.Param;
|
|
|
|
import java.util.List;
|
|
|
|
public interface PaperRepository extends JpaRepository<Paper, Long>, JpaSpecificationExecutor<Paper> {
|
|
|
|
@Query(value = "select *\n" +
|
|
"from sys_paper\n" +
|
|
"where id in (select a.id\n" +
|
|
" from (select p.id, sum(r.score1 + r.score2 + r.score3) as score\n" +
|
|
" from sys_paper p,\n" +
|
|
" sys_paper_rating r\n" +
|
|
" where p.id = r.paper_id\n" +
|
|
" group by p.id\n" +
|
|
" order by score desc\n" +
|
|
" limit 10) a)",nativeQuery = true)
|
|
List<Paper> recommendWithScore();
|
|
|
|
@Query(value = "select * from sys_paper where id in (:ids) order by FIELD(`id`,:ids)",nativeQuery = true)
|
|
List<Paper> recommendWithSim(@Param("ids") List<Long> ids);
|
|
}
|
|
|