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.
cloudnote_server/src/main/java/com/bupt/note/Repository/PaperRepository.java

22 lines
973 B

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 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> recommend();
}