117 lines
3.9 KiB
Java
117 lines
3.9 KiB
Java
package com.peanut.modules.book.controller;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.peanut.common.utils.R;
|
|
import com.peanut.modules.book.entity.BookClockEntryEntity;
|
|
import com.peanut.modules.book.entity.BookEntity;
|
|
import com.peanut.modules.book.service.BookClockEntryChatService;
|
|
import com.peanut.modules.book.service.BookClockEntryService;
|
|
import com.peanut.modules.book.service.BookService;
|
|
import com.peanut.modules.book.service.UserBookClockService;
|
|
import com.peanut.modules.book.to.PageIdDto;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
@RestController
|
|
@RequestMapping("book/clock")
|
|
public class UserClockController {
|
|
|
|
@Autowired
|
|
private UserBookClockService userBookClockService;
|
|
@Autowired
|
|
private BookClockEntryService bookClockEntryService;
|
|
@Autowired
|
|
private BookClockEntryChatService bookClockEntryChatService;
|
|
@Autowired
|
|
private BookService bookService;
|
|
|
|
/**
|
|
* 获取书打卡列表
|
|
* @return
|
|
*/
|
|
@RequestMapping("/getBookClocks")
|
|
public R getBookClocks(@RequestBody PageIdDto page){
|
|
LambdaQueryWrapper<BookClockEntryEntity> wrapper = new LambdaQueryWrapper<>();
|
|
wrapper.eq(BookClockEntryEntity::getBookId,page.getId());
|
|
wrapper.eq(BookClockEntryEntity::getDelFlag,0);
|
|
wrapper.orderByAsc(BookClockEntryEntity::getDay);
|
|
Page<BookClockEntryEntity> bookClockEntryEntityPage = bookClockEntryService.getBaseMapper().selectPage(new Page<BookClockEntryEntity>(page.getPage(), page.getLimit()), wrapper);
|
|
return R.ok().put("page",bookClockEntryEntityPage);
|
|
}
|
|
|
|
/**
|
|
* 获取读书打卡详情
|
|
* @param entryId
|
|
* @return
|
|
*/
|
|
@RequestMapping("/getBookClockDetail")
|
|
public R getBookClockDetail(@RequestParam Integer entryId){
|
|
BookClockEntryEntity byId = bookClockEntryService.getById(entryId);
|
|
return R.ok().put("entry",byId);
|
|
}
|
|
|
|
/**
|
|
* 新增读书打卡
|
|
* @param bookClockEntry
|
|
* @return
|
|
*/
|
|
@RequestMapping("/addBookClock")
|
|
public R addBookClock(@RequestBody BookClockEntryEntity bookClockEntry){
|
|
bookClockEntryService.save(bookClockEntry);
|
|
return R.ok();
|
|
}
|
|
|
|
/**
|
|
* 删除读书打卡
|
|
* @param entryId
|
|
* @return
|
|
*/
|
|
@RequestMapping("/delBookClock")
|
|
public R delBookClock(@RequestParam Integer entryId){
|
|
bookClockEntryService.removeById(entryId);
|
|
return R.ok();
|
|
}
|
|
|
|
/**
|
|
* 修改读书打卡
|
|
* @return
|
|
*/
|
|
@RequestMapping("/updateBookClock")
|
|
public R updateBookClock(@RequestBody BookClockEntryEntity bookClockEntry){
|
|
bookClockEntryService.updateById(bookClockEntry);
|
|
return R.ok();
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取用户已购打卡书列表
|
|
* @param userId
|
|
* @param limit
|
|
* @param page
|
|
* @return
|
|
*/
|
|
@RequestMapping("/getUserClockBooks")
|
|
public R getUserClockBooks(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){
|
|
Page<BookEntity> userClockBooks = bookService.getUserClockBooks(userId, limit, page);
|
|
return R.ok().put("page",userClockBooks);
|
|
}
|
|
|
|
/**
|
|
* 获取用户推荐打卡图书列表
|
|
* @param userId
|
|
* @param limit
|
|
* @param page
|
|
* @return
|
|
*/
|
|
@RequestMapping("/getUserClockBestBooks")
|
|
public R getUserClockBestBooks(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){
|
|
Page<BookEntity> userClockBestBooks = bookService.getUserClockBestBooks(userId, limit, page);
|
|
return R.ok().put("page",userClockBestBooks);
|
|
}
|
|
|
|
}
|