医案推荐图书
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
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.metadata.IPage;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
|
||||
import com.peanut.modules.book.entity.UserEbookBuyEntity;
|
||||
import com.peanut.modules.book.service.BookMedicalRecordsService;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.UserEbookBuyService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -22,12 +28,46 @@ public class BookMedicalRecordsController {
|
||||
|
||||
@Autowired
|
||||
private BookMedicalRecordsService bookMedicalRecordsService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private UserEbookBuyService userEbookBuyService;
|
||||
|
||||
/**
|
||||
* 已购图书列表
|
||||
*/
|
||||
@RequestMapping("/userEbookBuyList")
|
||||
public R userEbookBuyList(@RequestBody Map<String, Object> params){
|
||||
MPJLambdaWrapper<BookEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(BookEntity.class);
|
||||
wrapper.leftJoin(UserEbookBuyEntity.class, UserEbookBuyEntity::getBookId,BookEntity::getId);
|
||||
wrapper.leftJoin(BookMedicalRecordsEntity.class,BookMedicalRecordsEntity::getBookId,BookEntity::getId);
|
||||
wrapper.eq(BookMedicalRecordsEntity::getDelFlag,0);
|
||||
wrapper.eq(BookEntity::getDelFlag,0);
|
||||
wrapper.eq(BookEntity::getState,1);
|
||||
wrapper.eq(UserEbookBuyEntity::getUserId,params.get("userId"));
|
||||
wrapper.groupBy(BookMedicalRecordsEntity::getBookId);
|
||||
IPage<BookEntity> page = bookService.page(
|
||||
new Query<BookEntity>().getPage(params),wrapper);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
/**
|
||||
* 推荐图书列表
|
||||
*/
|
||||
@RequestMapping("/recommendBookList")
|
||||
public R recommendBookList(@RequestBody Map<String, Object> params){
|
||||
List<BookEntity> list = bookMedicalRecordsService.getBooks((Integer) params.get("userId"));
|
||||
MPJLambdaWrapper<BookEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
IPage<BookEntity> page = bookService.page(
|
||||
new Query<BookEntity>().getPage(params),wrapper);
|
||||
page.setRecords(list);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
public R list(@RequestBody Map<String, Object> params){
|
||||
IPage<BookMedicalRecordsEntity> page = bookMedicalRecordsService.page(
|
||||
new Query<BookMedicalRecordsEntity>().getPage(params),
|
||||
new QueryWrapper<BookMedicalRecordsEntity>()
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
package com.peanut.modules.book.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface BookMedicalRecordsDao extends MPJBaseMapper<BookMedicalRecordsEntity> {
|
||||
|
||||
|
||||
|
||||
List<BookEntity> getBooks(Integer userId);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
|
||||
|
||||
import java.util.List;
|
||||
@@ -10,4 +11,7 @@ import java.util.Map;
|
||||
|
||||
public interface BookMedicalRecordsService extends IService<BookMedicalRecordsEntity> {
|
||||
|
||||
|
||||
List<BookEntity> getBooks(Integer userId);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.book.dao.BookMedicalRecordsDao;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
|
||||
import com.peanut.modules.book.service.BookMedicalRecordsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,5 +20,11 @@ import java.util.Map;
|
||||
@Service
|
||||
public class BookMedicalRecordsServiceImpl extends ServiceImpl<BookMedicalRecordsDao, BookMedicalRecordsEntity> implements BookMedicalRecordsService {
|
||||
|
||||
@Autowired
|
||||
private BookMedicalRecordsDao dao;
|
||||
|
||||
@Override
|
||||
public List<BookEntity> getBooks(Integer userId) {
|
||||
return dao.getBooks(userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,12 @@
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getBooks" parameterType="int" resultType="com.peanut.modules.book.entity.BookEntity">
|
||||
select b.* 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
|
||||
GROUP BY bmr.book_id
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user