医案-推荐图书

This commit is contained in:
wuchunlei
2023-11-27 16:53:51 +08:00
parent fdf84e52b9
commit b1224eb9f4

View File

@@ -1,9 +1,7 @@
package com.peanut.modules.book.controller; package com.peanut.modules.book.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.Query; import com.peanut.common.utils.Query;
import com.peanut.common.utils.R; import com.peanut.common.utils.R;
@@ -12,15 +10,11 @@ import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
import com.peanut.modules.book.entity.UserEbookBuyEntity; import com.peanut.modules.book.entity.UserEbookBuyEntity;
import com.peanut.modules.book.service.BookMedicalRecordsService; import com.peanut.modules.book.service.BookMedicalRecordsService;
import com.peanut.modules.book.service.BookService; import com.peanut.modules.book.service.BookService;
import com.peanut.modules.book.service.UserEbookBuyService;
import com.peanut.modules.book.vo.UserOrderVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map; import java.util.Map;
@Slf4j @Slf4j
@@ -32,8 +26,6 @@ public class BookMedicalRecordsController {
private BookMedicalRecordsService bookMedicalRecordsService; private BookMedicalRecordsService bookMedicalRecordsService;
@Autowired @Autowired
private BookService bookService; private BookService bookService;
@Autowired
private UserEbookBuyService userEbookBuyService;
/** /**
* 已购图书列表 * 已购图书列表
@@ -58,12 +50,22 @@ 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")); // 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(count); // 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);
MPJLambdaWrapper<BookEntity> wrapper = new MPJLambdaWrapper<>();
String exsql = "SELECT 1 FROM book_medical_records bmr WHERE bmr.book_id = id";
String notsql = "select 1 from user_ebook_buy b where b.book_id = id and user_id = "+params.get("userId");
wrapper.selectAll(BookEntity.class);
wrapper.exists(exsql);
wrapper.notExists(notsql);
wrapper.eq("state",1);
IPage<BookEntity> page = bookService.page(
new Query<BookEntity>().getPage(params),wrapper);
return R.ok().put("page", page); return R.ok().put("page", page);
} }
/** /**