This commit is contained in:
yc13649764453
2023-09-19 15:00:15 +08:00
parent 9ada233eb7
commit 5a43a5020b
21 changed files with 745 additions and 582 deletions

View File

@@ -109,10 +109,8 @@ public class BookChapterController {
public R contentupdate(@RequestBody BookChapterEntity bookChapter) {
Integer id = bookChapter.getId();
String content = bookChapter.getContent();
//
// bookChapterService.updateById(bookChapter); // 更新对象的属性
//
// return R.ok();
Integer number = bookChapter.getNumber();
Integer bookId = bookChapter.getBookId();
BookChapterEntity byId = bookChapterService.getById(id);
String content1 = byId.getContent();
@@ -123,6 +121,17 @@ public class BookChapterController {
bookChapter.setVoices(""); // 设置voices字段为空
}
List<BookChapterEntity> bookChapterEntities = this.bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
.eq("book_id", bookId)
.ge("number", number));
for(BookChapterEntity entity: bookChapterEntities){
entity.setNumber(entity.getNumber() + 1);
this.bookChapterService.updateById(entity);
}
bookChapterService.updateById(bookChapter); // 更新对象的属性
return R.ok();
@@ -133,11 +142,78 @@ public class BookChapterController {
*/
@RequestMapping("/update")
public R update(@RequestBody BookChapterEntity bookChapter) {
bookChapterService.updateById(bookChapter); // 更新对象的属性
Integer id = bookChapter.getId();
String content = bookChapter.getContent();
Integer number = bookChapter.getNumber();
Integer bookId = bookChapter.getBookId();
BookChapterEntity byId = bookChapterService.getById(id);
String content1 = byId.getContent();
if (content.equals(content1)) {
} else {
// 如果content字段和原来数据库的content内容不同则voices字段为空
bookChapter.setVoices(""); // 设置voices字段为空
}
List<BookChapterEntity> bookChapterEntities = this.bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
.eq("book_id", bookId)
.ge("number", number));
System.out.println("bookChapterEntitiesbookChapterEntitiesbookChapterEntities"+bookChapterEntities);
BookChapterEntity bookChapterEntity = null;
for (BookChapterEntity entity : bookChapterEntities) {
if (entity.getNumber() == number) {
bookChapterEntity = entity;
break;
}
}
// if (bookChapterEntity != null) {
// bookChapterEntity.setNumber(1); // 设置新的章节编号为1
// bookChapterService.updateById(bookChapterEntity); // 更新章节编号为1的章节
// }
List<BookChapterEntity> bookChapterEntitiesCopy = new ArrayList<>(bookChapterEntities); // 复制章节列表
Collections.sort(bookChapterEntitiesCopy, new Comparator<BookChapterEntity>() {
@Override
public int compare(BookChapterEntity o1, BookChapterEntity o2) {
return o1.getNumber() - o2.getNumber(); // 根据章节编号进行排序
}
});
// bookChapterService.updateById(bookChapter);
// List<BookChapterEntity> bookChapterEntities = this.bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
// .eq("book_id", bookId)
// .ge("number", number));
//
// for(BookChapterEntity entity: bookChapterEntities){
// if (bookChapter.getNumber()>=) {
// }
// entity.setNumber(entity.getNumber() - 1);
//
// bookChapterService.updateById(entity);
// }
// List<BookChapterEntity> tempEntity = this.bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
// .eq("book_id", bookChapter.getBookId()).orderByAsc("number")
// );
// int index = 0;
// for(BookChapterEntity entity: tempEntity){
// index ++;
// entity.setNumber(index);
// this.bookChapterService.updateById(entity);
// }
//
return R.ok();
}
public static List<BookChapterEntity> sort(List<BookChapterEntity> list){
//根据指定比较器产生的顺序对指定列表进行排序。
Collections.sort(list, new Comparator<BookChapterEntity>() {

View File

@@ -35,7 +35,6 @@ private BookClockinCommentService bookClockinCommentService;
@RequestMapping("/applist")
public R applist(@RequestParam Map<String, Object> params) {
PageUtils page = bookClockinPunchService.queryPage(params);
return R.ok().put("page", page);
}
@@ -49,25 +48,20 @@ private BookClockinCommentService bookClockinCommentService;
public R applists(@RequestParam("bookId") String bookid,
@RequestParam("userId") String userid) {
ArrayList<Object> list = new ArrayList<>();
//查询用户id图书id 根据第一天打卡天数开始计算
BookClockinPunchEntity bookClockinEntity = bookClockinPunchService.getBaseMapper().selectOne(new QueryWrapper<BookClockinPunchEntity>()
.eq("book_id", bookid)
.eq("user_id", userid)
.eq("days",1)
);
List<BookClockinPunchEntity> bookClockinEntityList = bookClockinPunchService.getBaseMapper().selectList(new QueryWrapper<BookClockinPunchEntity>()
.eq("book_id", bookid)
.eq("user_id", userid)
);
for (BookClockinPunchEntity bookClock : bookClockinEntityList) {
Integer days = bookClock.getDays();
list.add(days);
}
if (bookClockinEntity != null) {
Date createTime = bookClockinEntity.getCreateTime();
long createTimeMillis = createTime.getTime();
@@ -78,7 +72,6 @@ private BookClockinCommentService bookClockinCommentService;
} else if (bookClockinEntity == null) {
Date createTime = new Date();
long createTimeMillis = createTime.getTime();
//获取第一次打卡天数createTimeMillis毫秒数时间戳减并除以毫秒数24 * 60 * 60 * 1000计算打卡总天数+1
int daysBetween = (int) (System.currentTimeMillis() - createTimeMillis) / (24 * 60 * 60 * 1000)+1;
return R.ok().put("daysBetween", daysBetween).put("dayslist",list );
@@ -105,7 +98,6 @@ private BookClockinCommentService bookClockinCommentService;
* 保存
*/
@RequestMapping("/save")
//请求接口时是从task的info或者list中发出的理论上
public R save(@RequestBody BookClockinPunchEntity bookClockinPunchEntity) {
Integer bookid1 = bookClockinPunchEntity.getBookId();
Integer userId = bookClockinPunchEntity.getUserId();
@@ -126,18 +118,21 @@ private BookClockinCommentService bookClockinCommentService;
if(canListen == true){
boolean b = myUserService.bookAuthenticate(bookid1,userId);
boolean b = myUserService.bookAuthen(bookid1,userId);
if (b){
bookClockinPunchEntity.setDelFlag(0);
bookClockinPunchService.save(bookClockinPunchEntity);
return R.ok("签到成功");
}else {
return R.error("您还未购买此书,购买后即可签到");
}
}else {
return R.error("购买此书即可参与签到");
return R.error("该书暂未开放打卡权限");
}
return R.ok("跳方法001");
}

View File

@@ -53,12 +53,25 @@ public class BookController {
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("book:book:list")
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = bookService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 列表
*/
@RequestMapping("/listbooks")
public R listbooks(@RequestParam Map<String, Object> params) {
PageUtils page = bookService.queryPagebooks(params);
return R.ok().put("page", page);
}
/**
* 信息
*/

View File

@@ -419,6 +419,7 @@ public class BuyOrderController {
for (BuyOrderDetailEntity buyOrdr : produ) {
Integer pId = buyOrdr.getProductId();
ShopProductEntity product1 = shopProductService.getById(pId);
String productName = product1.getProductName();
// 如果是虚拟币购买 减少用户的虚拟币数量
if ("4".equals(buyOrder.getPaymentMethod())) {
MyUserEntity user = this.myUserService.getById(buyOrder.getUserId());
@@ -433,7 +434,7 @@ public class BuyOrderController {
transactionDetailsEntity.setChangeAmount(realMoney.negate());
transactionDetailsEntity.setUserBalance(user.getPeanutCoin());
transactionDetailsEntity.setTel(user.getTel());
transactionDetailsEntity.setOrderType("赠送本书听书图书");
transactionDetailsEntity.setOrderType("购买《"+productName+"赠送本书听书功能");
transactionDetailsService.save(transactionDetailsEntity);
} else {
return R.error("余额不足!");

View File

@@ -1,6 +1,4 @@
package com.peanut.modules.book.controller;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -36,12 +34,9 @@ public class ShopProductController {
private BuyOrderDetailService buyOrderDetailService;
@Autowired
private BookService bookService;
@Autowired
private ShopProudictBookService shopProudictBookService;
/**
* 精选商品 列表
*/
@@ -52,10 +47,15 @@ public class ShopProductController {
return R.ok().put("page", page);
}
/**
* 折扣商品
*/
@RequestMapping("/listactivityprice")
public R listactivityprice(@RequestParam Map<String, Object> params){
PageUtils page = shopProductService.queryPageactivityprice(params);
return R.ok().put("page", page);
}
/**
* 列表
@@ -68,9 +68,8 @@ public class ShopProductController {
}
/**
* 列表
* 查询列表
*/
@RequestMapping("/selectList")
public R selectList(@RequestParam Map<String, Object> params){
@@ -79,16 +78,6 @@ public class ShopProductController {
return R.ok().put("page", page);
}
//新书
@RequestMapping("/getNewBook")
public R getNewBook(@RequestParam Map<String, Object> params) {
@@ -102,19 +91,11 @@ public class ShopProductController {
/**
* 未购买书列表
* @param userId 用户id
* @return
*/
//todo 9.7未调试
@RequestMapping("/booklist")
public R booklistss(@RequestParam("userId") Integer userId
) {
@@ -151,29 +132,28 @@ public class ShopProductController {
return R.ok().put("pages", lists); // 返回未购买的书籍分页
}
@RequestMapping("/bookinfo/{productId}")
public R bookinfo(@PathVariable("productId") Integer productId){
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String,String>>();
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", productId));
Integer poid = shopProductEntity.getProductPid();
List<Integer> poids = shopCategoryService.findPoid(poid);
Integer productId1 = shopProductEntity.getProductId();
shopProductEntity.setPoids(poids);
List<ShopProudictBookEntity> bookEntityList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>().eq("book_id", productId));
List<Object> list = new ArrayList<>();
ArrayList<String> booklist = new ArrayList<>();
List<ShopProudictBookEntity> proudict = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("proudict_id", productId1));
for (ShopProudictBookEntity shopProudictBookEntity : proudict) {
ShopProductEntity shopProductEntity=null;
for (ShopProudictBookEntity shopProudictBookEntity : bookEntityList) {
Integer proudictId = shopProudictBookEntity.getProudictId();
shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", proudictId));
Integer bookId = shopProudictBookEntity.getBookId();
BookEntity byId = bookService.getById(bookId);
booklist.add(String.valueOf(bookId));
list.add(byId);
shopProductEntity.setBookidsimages(list);
shopProductEntity.setBookids(booklist);
}
shopProductEntity.setBookidsimages(list);
shopProductEntity.setBookids(booklist);
return R.ok().put("shopProduct", shopProductEntity);
}
@@ -181,10 +161,54 @@ public class ShopProductController {
@RequestMapping("/bookinfolists/{productId}")
public R bookinfolists(@PathVariable("productId") Integer productId) {
//查询商品
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", productId));
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String, String>>();
//分类
Integer poid = shopProductEntity.getProductPid();
//商品id
Integer productId1 = shopProductEntity.getProductId();
//分类信息
List<Integer> poids = shopCategoryService.findPoid(poid);
List<ShopProudictBookEntity> proudict = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("proudict_id", productId1));
List<ShopProductEntity> result = new ArrayList<>();
//获取商品id
Set<Integer> productIds = new HashSet<>();
productIds.add(productId);
for (ShopProudictBookEntity shopProudictBookEntity : proudict) {
Integer bookId = shopProudictBookEntity.getBookId();
BookEntity byId = bookService.getById(bookId);
List<ShopProudictBookEntity> entityByBookId = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("book_id", bookId));
for(ShopProudictBookEntity entity : entityByBookId){
productIds.add(entity.getProudictId());
}
}
for(Integer pId : productIds){
ShopProductEntity proEntity =null;
proEntity = shopProductService.getById(pId);
List<ShopProudictBookEntity> pbookEntitys = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("proudict_id", pId));
ArrayList<String> booklist = new ArrayList<>();
List<Object> list = new ArrayList<>();
for (ShopProudictBookEntity shopProudictBookEntity : pbookEntitys) {
booklist.add(String.valueOf(shopProudictBookEntity.getBookId()));
BookEntity byId = bookService.getById(shopProudictBookEntity.getBookId());
list.add(byId);
}
proEntity.setPoids(poids);
proEntity.setBookidsimages(list);
proEntity.setBookids(booklist);
result.add(proEntity);
}
return R.ok().put("result", result);
}
/**
* 信息
* @param productId 9.13商品详情原接口
* @param productId
* @return
*/
@RequestMapping("/info/{productId}")
@@ -194,34 +218,52 @@ public class ShopProductController {
Integer poid = shopProductEntity.getProductPid();
Integer productId1 = shopProductEntity.getProductId();
System.out.println("productId1=============================="+productId1);
List<Integer> poids = shopCategoryService.findPoid(poid);
shopProductEntity.setPoids(poids);
List<Object> list = new ArrayList<>();
List<Object> bookIdlist = new ArrayList<>();
ArrayList<String> booklist = new ArrayList<>();
List<ShopProudictBookEntity> proudict = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("proudict_id", productId1));
for (ShopProudictBookEntity shopProudictBookEntity : proudict) {
Integer id = shopProudictBookEntity.getId();
Integer bookId = shopProudictBookEntity.getBookId();
BookEntity byId = bookService.getById(bookId);
bookIdlist.add(id);
booklist.add(String.valueOf(bookId));
list.add(byId);
}
shopProductEntity.setBookidsimages(list);
shopProductEntity.setBookids(booklist);
shopProductEntity.setShoproudIds(bookIdlist);
return R.ok().put("shopProduct", shopProductEntity);
}
/**
* 根据传入商品id反向查询图书id然后查询图书id下包含的商品
* @param productId
* @return
*/
@RequestMapping("/infobook/{productId}")
public R infobook(@PathVariable("productId") Integer productId) {
List<ShopProudictBookEntity> proudict = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("proudict_id", productId));
List<Object> list = new ArrayList<>();
for (ShopProudictBookEntity shopProudictBookEntity : proudict) {
Integer bookId = shopProudictBookEntity.getBookId();
List<ShopProudictBookEntity> bookIds = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("book_id", bookId));
for (ShopProudictBookEntity shopProudict : bookIds) {
Integer proudictId = shopProudict.getProudictId();
List<ShopProductEntity> shopProductEntities = shopProductService.getBaseMapper().selectList(new QueryWrapper<ShopProductEntity>()
.eq("proudict_id",proudictId));
list.add(shopProductEntities);
}
}
return R.ok();
}
/**
@@ -231,20 +273,18 @@ public class ShopProductController {
public R save(@RequestBody ShopProductEntity shopProduct) {
shopProduct.setCreateTime(new Date());
// //用list集合接收数组转String类型字符串
// String bkids = "";
// for(String s : shopProduct.getBookids()){
// bkids += s+",";
// }
// if (bkids!=null &&!bkids.isEmpty()){
// String substring = bkids.substring(0, bkids.length() - 1);
// shopProduct.setBookId(substring);
// }else {
// shopProduct.setBookId("");
// }
String bkids = "";
for(String s : shopProduct.getBookids()){
bkids += s+",";
}
if (bkids!=null &&!bkids.isEmpty()){
String substring = bkids.substring(0, bkids.length() - 1);
shopProduct.setBookId(substring);
}else {
shopProduct.setBookId("");
}
shopProductService.save(shopProduct);
ShopProudictBookEntity shopProudictBookEntity = new ShopProudictBookEntity();
for (String s : shopProduct.getBookids()) {
String bookidlist = s;
@@ -253,49 +293,80 @@ public class ShopProductController {
shopProudictBookEntity.setProudictId(proudict);
shopProudictBookEntity.setBookId(Integer.valueOf(bookidlist));
shopProudictBookService.save(shopProudictBookEntity);
}
}
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody ShopProductEntity shopProduct) {
ShopProudictBookEntity shopProudictBookEntity = new ShopProudictBookEntity();
Integer productId = shopProduct.getProductId();
//多个图书id
ArrayList<String> bookId = shopProduct.getBookids();
shopProduct.setCreateTime(new Date());
//用list集合接收数组转String类型字符串
String bkids = "";
for (String s : shopProduct.getBookids()) {
bkids += s + ",";
}
if (bkids != null && !bkids.isEmpty()) {
String substring = bkids.substring(0, bkids.length() - 1);
shopProduct.setBookId(substring);
} else {
shopProduct.setBookId("");
}
//查询proudict中不包含传过来的bookid
List<ShopProudictBookEntity> bookEntityList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("proudict_id", productId)
.notIn("book_id", bookId)
);
System.out.println("bookEntityList==========" + bookEntityList);
for (ShopProudictBookEntity shopProudictBookEntity : bookEntityList) {
Integer id = shopProudictBookEntity.getId();
shopProudictBookService.removeById(id);
}
shopProductService.updateById(shopProduct);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("book:shopproduct:delete")
public R delete(@RequestBody Integer[] productIds){
shopProductService.removeByIds(Arrays.asList(productIds));
List<ShopProudictBookEntity> bookEntityList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.in("proudict_id", productIds)
);
for (ShopProudictBookEntity shopProudictBookEntity : bookEntityList) {
Integer id = shopProudictBookEntity.getId();
shopProudictBookService.removeById(id);
}
shopProductService.removeByIds(Arrays.asList(productIds));
return R.ok();
}
/**
* 列表
*/
@@ -306,23 +377,25 @@ public class ShopProductController {
return R.ok().put("page", page);
}
/**
* 获取分类下商品列表
*/
@RequestMapping("/appGetCategoryList")
public R appGetCategoryList(@RequestParam("catId") Integer catId){
System.out.println("catId======================"+catId);
List<ShopCategoryEntity> list1 = shopCategoryService.getBaseMapper().selectList(new QueryWrapper<ShopCategoryEntity>()
.eq("cat_id",catId));
if (catId == null) {
}
if(catId == 0){
catId = null;
}
List<ShopProductEntity> list = shopProductService.appGetCategoryList(catId);
System.out.println("list==========================="+list);
return R.ok().put("list", list);
}
@@ -338,8 +411,6 @@ public class ShopProductController {
shopProductVo.setValue(shopProductEntity.getProductName());
return shopProductVo;
}).collect(Collectors.toList());
return R.ok().put("list", collect);
}
@@ -348,12 +419,9 @@ public class ShopProductController {
*/
@RequestMapping("/backProdSearch")
public R backProdSearch(@RequestParam Map<String, Object> params){
String productName = (String) params.get("productName");
List<ShopProductEntity> list = shopProductService.list(new QueryWrapper<ShopProductEntity>()
.like("product_name",productName));
return R.ok().put("list", list);
}

View File

@@ -1,5 +1,4 @@
package com.peanut.modules.book.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.ShopProudictBookEntity;
@@ -13,15 +12,8 @@ import java.util.Map;
@RestController
@RequestMapping("book/shopProudictBook")
public class ShopProudictBookController {
@Autowired
private ShopProudictBookService shopProudictBookService;
/**
* 列表
*/
@@ -31,20 +23,16 @@ public class ShopProudictBookController {
return R.ok().put("page", page);
}
/**
* 图书与商品信息
*/
// 根据商品id查询图书信息查询到图书信息反向查找包含该图书id的所有商品返回
@RequestMapping("/proudictBooklist")
public R proudictBooklist(@RequestParam Integer proudictId){
List<ProudictBookqueryVO> cartList = shopProudictBookService.getCartList(proudictId);
return R.ok().put("cartList", cartList);
}
/**
* 保存
*/
@@ -61,10 +49,6 @@ public class ShopProudictBookController {
}
}
return R.ok();
}
@@ -77,7 +61,6 @@ public class ShopProudictBookController {
shopProudictBookService.updateById(shopProudictBookEntity);
return R.ok();
}
/**
* 删除
*/