--9.19
This commit is contained in:
@@ -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>() {
|
||||
|
||||
@@ -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");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
|
||||
@@ -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("余额不足!");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.peanut.modules.book.entity.ShopProudictBookEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ShopProudictBookDao extends BaseMapper<ShopProudictBookEntity> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -160,6 +160,9 @@ public class ShopProductEntity implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private List<Object> shoproudBook;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<Object> shoproudIds;
|
||||
|
||||
|
||||
// private Object bookidsimages;
|
||||
//
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.peanut.modules.book.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("shop_proudict_book")
|
||||
public class ShopProudictBookEntity {
|
||||
@@ -32,14 +29,12 @@ public class ShopProudictBookEntity {
|
||||
@TableField("del_flag")
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
|
||||
//
|
||||
@TableField(exist = false)
|
||||
private ArrayList<Integer> bookidlist;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,6 @@ public interface BookService extends IService<BookEntity> {
|
||||
boolean getWordSection (Integer bookId);
|
||||
|
||||
|
||||
|
||||
PageUtils queryPagebooks(Map<String, Object> params);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,5 +29,7 @@ public interface ShopProductService extends IService<ShopProductEntity> {
|
||||
PageUtils selectListqueryPage(Map<String, Object> params);
|
||||
|
||||
PageUtils queryPageproductSales(Map<String, Object> params);
|
||||
|
||||
PageUtils queryPageactivityprice(Map<String, Object> params);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,4 +14,5 @@ public interface ShopProudictBookService extends IService<ShopProudictBookEntity
|
||||
PageUtils proudictBookqueryPage(Map<String, Object> params);
|
||||
|
||||
List<ProudictBookqueryVO> getCartList(Integer proudictId);
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class BookChapterServiceImpl extends ServiceImpl<BookChapterDao, BookChap
|
||||
IPage<BookChapterEntity> page = this.page(
|
||||
new Query<BookChapterEntity>().getPage(params),
|
||||
//8.24修改根据number升序 排序
|
||||
new QueryWrapper<BookChapterEntity>().eq("book_id",bookid).orderByDesc("number")
|
||||
new QueryWrapper<BookChapterEntity>().eq("book_id",bookid).orderByAsc("number")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
|
||||
@@ -561,16 +561,13 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
Map<String,List<String[]>> paraMap = new HashMap<>();
|
||||
Map<String,String> headMap = new HashMap<>();
|
||||
List<String> title_list = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < doc.getSections().getCount(); i++) {
|
||||
String currentTitle = "";
|
||||
Section section = doc.getSections().get(i);
|
||||
for (int j = 0; j < section.getParagraphs().getCount() - 1; j++) {
|
||||
Paragraph paragraph = section.getParagraphs().get(j);
|
||||
if (paragraph.getStyleName().equals("Heading1") ) {
|
||||
//
|
||||
String textq = paragraph.getText();
|
||||
|
||||
currentTitle = textq;
|
||||
title_list.add(currentTitle);
|
||||
List<String[]> secondTitleList = new ArrayList<>();
|
||||
@@ -578,7 +575,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
if(!section.getParagraphs().get(j+1).getStyleName().matches("Heading2")){
|
||||
int head_index = j ;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
do {
|
||||
builder.append(section.getParagraphs().get(head_index).getText());
|
||||
head_index++;
|
||||
@@ -660,6 +656,55 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPagebooks(Map<String, Object> params) {
|
||||
IPage<BookEntity> page = this.page(
|
||||
new Query<BookEntity>().getPage(params),
|
||||
new QueryWrapper<BookEntity>()
|
||||
.eq("state", "1")
|
||||
.orderByDesc("create_time")
|
||||
|
||||
);
|
||||
for (BookEntity book : page.getRecords()) {
|
||||
String authorName = "";
|
||||
String publisherName = "";
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
|
||||
|
||||
String authorId = book.getAuthorId();
|
||||
String publisherId = book.getPublisherId();
|
||||
|
||||
String[] authorIds = authorId.split(",");
|
||||
String[] publisherIds = publisherId.split(",");
|
||||
|
||||
List<String> authorList = Arrays.asList(authorIds);
|
||||
List<String> publisherList = Arrays.asList(publisherIds);
|
||||
|
||||
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>().in("id", publisherList));
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
|
||||
for (AuthorEntity authorEntity : authorEntities) {
|
||||
authorName += "," + authorEntity.getAuthorName();
|
||||
}
|
||||
for (PublisherEntity publisherEntity : publisherEntities) {
|
||||
publisherName += "," + publisherEntity.getPublisherName();
|
||||
}
|
||||
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
|
||||
publisherName = publisherName.startsWith(",") ? publisherName.substring(1) : publisherName;
|
||||
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
book.setType(Joiner.on(",").join(list));
|
||||
}
|
||||
if (!StringUtils.isEmpty(authorName)) {
|
||||
book.setAuthorName(authorName);
|
||||
}
|
||||
if (!StringUtils.isEmpty(publisherName)) {
|
||||
book.setPublisherName(publisherName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class BookTaskServiceImpl extends ServiceImpl<BookTaskDao, BookTaskEntity
|
||||
Object bookid = params.get("bookid");
|
||||
IPage<BookTaskEntity> page = this.page(
|
||||
new Query<BookTaskEntity>().getPage(params),
|
||||
new QueryWrapper<BookTaskEntity>().eq("book_id",bookid).orderByDesc("days")
|
||||
new QueryWrapper<BookTaskEntity>().eq("book_id",bookid).orderByAsc("days")
|
||||
|
||||
);
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEnt
|
||||
Integer productId = orderCartEntity.getProductId();
|
||||
|
||||
ShopProductEntity productEntity = shopProductService.getById(productId);
|
||||
// shopProductService.getBaseMapper().selectList()
|
||||
ShopCartVo shopCartVo = new ShopCartVo();
|
||||
|
||||
BeanUtils.copyProperties(orderCartEntity, shopCartVo);
|
||||
@@ -62,7 +63,7 @@ public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEnt
|
||||
shopCartVo.setWeight(productEntity.getWeight().doubleValue());
|
||||
|
||||
shopCartVo.setProductStock(productEntity.getProductStock());
|
||||
shopCartVo.setProudictBook(Integer.valueOf(productEntity.getBookId()));
|
||||
// shopCartVo.setProudictBook(Integer.valueOf(productEntity.getBookId()));
|
||||
|
||||
BigDecimal activityPrice = productEntity.getActivityPrice();
|
||||
BigDecimal big = new BigDecimal(0);
|
||||
|
||||
@@ -76,4 +76,13 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPageactivityprice(Map<String, Object> params) {
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProductEntity>().ne("activity_price", "").ne("activity_price", 0)
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -8,7 +6,6 @@ import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.book.dao.ShopProudictBookDao;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.ShopCategoryEntity;
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import com.peanut.modules.book.entity.ShopProudictBookEntity;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
@@ -17,8 +14,8 @@ import com.peanut.modules.book.service.ShopProudictBookService;
|
||||
import com.peanut.modules.book.vo.ProudictBookqueryVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -53,33 +50,25 @@ public class ShopProudictBookServiceImpl extends ServiceImpl<ShopProudictBookDa
|
||||
@Override
|
||||
public List<ProudictBookqueryVO> getCartList(Integer proudictId) {
|
||||
|
||||
|
||||
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("proudict_id", proudictId));
|
||||
List<ShopProudictBookEntity> proudictBooklist = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("proudict_id", proudictId));
|
||||
|
||||
List prList = new ArrayList<>();
|
||||
List prLists = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
for (ShopProudictBookEntity shopProudictBookEntity : proudictBooklist) {
|
||||
Integer proudictId1 = shopProudictBookEntity.getProudictId();
|
||||
Integer bookId = shopProudictBookEntity.getBookId();
|
||||
|
||||
System.out.println("proudictId1======="+proudictId1);
|
||||
System.out.println("bookId======="+bookId);
|
||||
BookEntity bookbyId = bookService.getById(bookId);
|
||||
ShopProductEntity shopProductbyId = shopProductService.getById(proudictId1);
|
||||
ProudictBookqueryVO queryVO = new ProudictBookqueryVO();
|
||||
queryVO.setBookId(bookbyId.getId());
|
||||
queryVO.setName(bookbyId.getName());
|
||||
queryVO.setCanListen(bookbyId.getCanListen());
|
||||
queryVO.setImages(bookbyId.getImages());
|
||||
queryVO.setClockIn(bookbyId.getClockIn());
|
||||
queryVO.setProudictId(shopProductbyId.getProductId());
|
||||
queryVO.setProductName(shopProductbyId.getProductName());
|
||||
queryVO.setPrice(shopProductbyId.getPrice());
|
||||
queryVO.setActivityPrice(shopProductbyId.getActivityPrice());
|
||||
queryVO.setSumSales(shopProductbyId.getSumSales());
|
||||
prList.add(queryVO);
|
||||
System.out.println("queryVO======="+queryVO);
|
||||
List<ShopProudictBookEntity> booklist = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("book_id", bookId));
|
||||
for (ShopProudictBookEntity shopProudictBook : booklist) {
|
||||
Integer proudictId1 = shopProudictBook.getProudictId();
|
||||
Integer bookId1 = shopProudictBook.getBookId();
|
||||
BookEntity bookbyId = bookService.getById(bookId1);
|
||||
prList.add(bookbyId);
|
||||
ShopProductEntity shopProductbyId = shopProductService.getById(proudictId1);
|
||||
shopProductbyId.setBookidsimages(prList);
|
||||
}
|
||||
}
|
||||
|
||||
return prList;
|
||||
shopProductEntity.setBookidsimages(prList);
|
||||
return prLists;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,28 +4,37 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 返回图书与商品基本信息vo,
|
||||
|
||||
*/
|
||||
@Data
|
||||
public class ProudictBookqueryVO {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*图书id
|
||||
*图书基本信息
|
||||
*/
|
||||
private Integer bookId;
|
||||
private String name;
|
||||
private String bookname;
|
||||
private Boolean canListen;
|
||||
private Integer clockIn;
|
||||
private String images;
|
||||
private List<String> proudicts;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商品基本信息
|
||||
*/
|
||||
private Integer proudictId;
|
||||
private String productName;
|
||||
private BigDecimal price;
|
||||
private BigDecimal activityPrice;
|
||||
private Integer sumSales;
|
||||
private String proudictimages;
|
||||
|
||||
}
|
||||
|
||||
@@ -14,4 +14,6 @@
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user