医案推荐书籍
This commit is contained in:
@@ -59,9 +59,10 @@ public class BookMedicalRecordsController {
|
||||
@RequestMapping("/recommendBookList")
|
||||
public R recommendBookList(@RequestBody Map<String, Object> params){
|
||||
List<BookEntity> list = bookMedicalRecordsService.getBooks(params);
|
||||
int count = bookMedicalRecordsService.getCount((Integer) params.get("userId"));
|
||||
Page<BookEntity> page = new Page<>();
|
||||
page.setRecords(list);
|
||||
page.setTotal(list.size());
|
||||
page.setTotal(count);
|
||||
page.setPages((int)Math.ceil(list.size()/page.getSize()));
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
@@ -15,4 +15,6 @@ public interface BookMedicalRecordsDao extends MPJBaseMapper<BookMedicalRecordsE
|
||||
|
||||
List<BookEntity> getBooks(Integer page,Integer limit,Integer userId);
|
||||
|
||||
int getCount(Integer userId);
|
||||
|
||||
}
|
||||
|
||||
@@ -14,4 +14,6 @@ public interface BookMedicalRecordsService extends IService<BookMedicalRecordsEn
|
||||
|
||||
List<BookEntity> getBooks(Map<String, Object> params);
|
||||
|
||||
int getCount(Integer userId);
|
||||
|
||||
}
|
||||
|
||||
@@ -30,4 +30,9 @@ public class BookMedicalRecordsServiceImpl extends ServiceImpl<BookMedicalRecord
|
||||
return dao.getBooks((page-1)*limit,limit
|
||||
,(Integer)params.get("userId"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount(Integer userId) {
|
||||
return dao.getCount(userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,12 @@
|
||||
limit #{page},#{limit}
|
||||
</select>
|
||||
|
||||
<select id="getCount" parameterType="int" resultType="int">
|
||||
select count(*) from (
|
||||
select distinct book_id from book_medical_records bmr
|
||||
left join book b on bmr.book_id = b.id
|
||||
where bmr.book_id not in (select book_id from user_ebook_buy where user_id = #{userId})
|
||||
and b.del_flag = 0 and b.state = 1) t
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user