first commit
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
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;
|
||||
|
||||
import com.peanut.modules.book.entity.BookReadRateEntity;
|
||||
import com.peanut.modules.book.service.BookReadRateService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 阅读进度表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/bookreadrate")
|
||||
public class BookReadRateController {
|
||||
|
||||
@Autowired private BookReadRateService bookReadRateService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:bookreadrate:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = bookReadRateService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:bookreadrate:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
BookReadRateEntity bookReadRate = bookReadRateService.getById(id);
|
||||
|
||||
return R.ok().put("bookReadRate", bookReadRate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("book/bookreadrate/save")
|
||||
// @RequiresPermissions("book:bookreadrate:save")
|
||||
public R save(@RequestBody BookReadRateEntity bookReadRate){
|
||||
|
||||
Integer bookId = bookReadRate.getBookId();
|
||||
Integer userId = bookReadRate.getUserId();
|
||||
BookReadRateEntity bookReadRateEntity = bookReadRateService.getBaseMapper().selectOne(new QueryWrapper<BookReadRateEntity>().eq("book_id", bookId)
|
||||
.eq("user_id", userId));
|
||||
|
||||
if (bookReadRateEntity != null) {
|
||||
return R.ok().put("bookReadId",bookReadRateEntity.getId());
|
||||
}
|
||||
|
||||
bookReadRateService.save(bookReadRate);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:bookreadrate:update")
|
||||
public R update(@RequestBody BookReadRateEntity bookReadRate){
|
||||
bookReadRateService.updateById(bookReadRate);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:bookreadrate:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
bookReadRateService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取阅读进度
|
||||
*/
|
||||
@RequestMapping("/getReadRate")
|
||||
// @RequiresPermissions("book:bookreadrate:delete")
|
||||
public R getReadRate(@RequestBody BookReadRateEntity bookReadRate){
|
||||
BookReadRateEntity one = bookReadRateService.getOne(new QueryWrapper<BookReadRateEntity>().eq("user_id", bookReadRate.getUserId()).eq("book_id", bookReadRate.getBookId()));
|
||||
return R.ok().put("readRate",one);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user