Merge remote-tracking branch 'origin/zcc'

This commit is contained in:
wangjinlei
2023-11-27 15:37:51 +08:00
5 changed files with 25 additions and 18 deletions

View File

@@ -59,35 +59,25 @@ public class BookMedicalRecordsController {
@RequestMapping("/recommendBookList") @RequestMapping("/recommendBookList")
public R recommendBookList(@RequestBody Map<String, Object> params){ public R recommendBookList(@RequestBody Map<String, Object> params){
List<BookEntity> list = bookMedicalRecordsService.getBooks(params); List<BookEntity> list = bookMedicalRecordsService.getBooks(params);
int count = bookMedicalRecordsService.getCount((Integer) params.get("userId"));
Page<BookEntity> page = new Page<>(); Page<BookEntity> page = new Page<>();
page.setRecords(list); page.setRecords(list);
page.setTotal(list.size()); page.setTotal(count);
page.setPages((int)Math.ceil(list.size()/page.getSize())); page.setPages((int)Math.ceil(list.size()/page.getSize()));
return R.ok().put("page", page); return R.ok().put("page", page);
} }
/**
* 列表
*/
@RequestMapping("/list")
public R list(@RequestBody Map<String, Object> params){
IPage<BookMedicalRecordsEntity> page = bookMedicalRecordsService.page(
new Query<BookMedicalRecordsEntity>().getPage(params),
new QueryWrapper<BookMedicalRecordsEntity>()
.orderByDesc("sort")
.eq("del_flag","0"));
return R.ok().put("page", page);
}
/** /**
* 根据图书id查询列表 * 根据图书id查询列表
*/ */
@RequestMapping("/listByBookId") @RequestMapping("/listByBookId")
public R listByBookId(Integer bookId){ public R listByBookId(@RequestBody Map<String, Object> params){
List list = bookMedicalRecordsService.list( IPage<BookMedicalRecordsEntity> page = bookMedicalRecordsService.page(
new Query<BookMedicalRecordsEntity>().getPage(params),
new QueryWrapper<BookMedicalRecordsEntity>() new QueryWrapper<BookMedicalRecordsEntity>()
.eq("book_id", bookId) .eq("book_id", params.get("bookId"))
.eq("del_flag","0") .eq("del_flag","0")
.orderByDesc("sort")); .orderByDesc("sort"));
return R.ok().put("list", list); return R.ok().put("page", page);
} }
/** /**
* 根据id查询医案 * 根据id查询医案

View File

@@ -15,4 +15,6 @@ public interface BookMedicalRecordsDao extends MPJBaseMapper<BookMedicalRecordsE
List<BookEntity> getBooks(Integer page,Integer limit,Integer userId); List<BookEntity> getBooks(Integer page,Integer limit,Integer userId);
int getCount(Integer userId);
} }

View File

@@ -14,4 +14,6 @@ public interface BookMedicalRecordsService extends IService<BookMedicalRecordsEn
List<BookEntity> getBooks(Map<String, Object> params); List<BookEntity> getBooks(Map<String, Object> params);
int getCount(Integer userId);
} }

View File

@@ -30,4 +30,9 @@ public class BookMedicalRecordsServiceImpl extends ServiceImpl<BookMedicalRecord
return dao.getBooks((page-1)*limit,limit return dao.getBooks((page-1)*limit,limit
,(Integer)params.get("userId")); ,(Integer)params.get("userId"));
} }
@Override
public int getCount(Integer userId) {
return dao.getCount(userId);
}
} }

View File

@@ -18,9 +18,17 @@
select b.* from book_medical_records bmr select b.* from book_medical_records bmr
left join book b on bmr.book_id = b.id 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}) 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 and bmr.del_flag = 0 and b.del_flag = 0 and b.state = 1
GROUP BY bmr.book_id GROUP BY bmr.book_id
limit #{page},#{limit} limit #{page},#{limit}
</select> </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 bmr.del_flag = 0 and b.del_flag = 0 and b.state = 1) t
</select>
</mapper> </mapper>