From 5de88ed184cc1b483e5a564fabbe7cdf3ae70af6 Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Sat, 7 Oct 2023 15:31:51 +0800 Subject: [PATCH] 20231007 --- .../BookClockinPunchController.java | 47 +++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/peanut/modules/book/controller/BookClockinPunchController.java b/src/main/java/com/peanut/modules/book/controller/BookClockinPunchController.java index e969e07a..ef3a7871 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookClockinPunchController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookClockinPunchController.java @@ -1,11 +1,12 @@ 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.extension.plugins.pagination.Page; +import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.peanut.common.utils.PageUtils; import com.peanut.common.utils.R; -import com.peanut.modules.book.entity.BookClockinCommentEntity; -import com.peanut.modules.book.entity.BookClockinPunchEntity; -import com.peanut.modules.book.entity.BookEntity; -import com.peanut.modules.book.entity.MyUserEntity; +import com.peanut.modules.book.dao.UserEbookBuyDao; +import com.peanut.modules.book.entity.*; import com.peanut.modules.book.service.BookClockinCommentService; import com.peanut.modules.book.service.BookClockinPunchService; import com.peanut.modules.book.service.BookService; @@ -25,6 +26,8 @@ private BookService bookService; private MyUserService myUserService; @Autowired private BookClockinCommentService bookClockinCommentService; +@Autowired +private UserEbookBuyDao userEbookBuyDao; @@ -136,6 +139,42 @@ private BookClockinCommentService bookClockinCommentService; } + /** + * 获取用户打卡已购图书 + * @param userId + * @return + */ + @RequestMapping("/myClockBooks") + public R myClockBooks(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); + wrapper.selectAll(BookEntity.class); + wrapper.leftJoin(BookEntity.class,BookEntity::getId,UserEbookBuyEntity::getBookId); + wrapper.eq(UserEbookBuyEntity::getUserId,userId); + wrapper.eq(BookEntity::getDelFlag,0); + wrapper.eq(BookEntity::getClockIn,1); + Page userBookEntityPage = userEbookBuyDao.selectJoinPage(new Page(page, limit), BookEntity.class, wrapper); + return R.ok().put("page",userBookEntityPage); + } + + /** + * 获取打卡推荐图书 + * @param userId + * @param limit + * @param page + * @return + */ + @RequestMapping("/getBestClockBooks") + public R getBestClockBooks(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){ + String not_ex_sql = "select 1 from user_ebook_buy where book.id = book_id and user_id = "+userId; + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(BookEntity::getDelFlag,0); + wrapper.eq(BookEntity::getClockIn,1); + wrapper.notExists(not_ex_sql); + Page bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper); + return R.ok().put("page",bookEntityPage); + } + + /** * 修改 */