This commit is contained in:
wangjinlei
2023-10-07 15:31:51 +08:00
parent ca919c55cd
commit 5de88ed184

View File

@@ -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<UserEbookBuyEntity> 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<BookEntity> userBookEntityPage = userEbookBuyDao.selectJoinPage(new Page<BookEntity>(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<BookEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BookEntity::getDelFlag,0);
wrapper.eq(BookEntity::getClockIn,1);
wrapper.notExists(not_ex_sql);
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
return R.ok().put("page",bookEntityPage);
}
/**
* 修改
*/