rename the file

This commit is contained in:
Cauchy
2023-10-11 16:51:29 +08:00
parent d80d598529
commit a356cceb62
20 changed files with 566 additions and 683 deletions

View File

@@ -2,7 +2,6 @@ package com.peanut.modules.book.controller;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.InputStream;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@@ -16,7 +15,6 @@ import com.peanut.modules.book.service.*;
import com.peanut.modules.oss.service.OssService; import com.peanut.modules.oss.service.OssService;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockMultipartFile; import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@@ -31,8 +29,6 @@ import org.springframework.web.multipart.MultipartFile;
/** /**
*
*
* @author yl * @author yl
* @email yl328572838@163.com * @email yl328572838@163.com
* @date 2022-08-16 14:32:06 * @date 2022-08-16 14:32:06
@@ -53,25 +49,22 @@ public class BookChapterContentController {
@Autowired @Autowired
private UserEbookBuyService userEbookBuyService; private UserEbookBuyService userEbookBuyService;
@Autowired @Autowired
private ShopProudictBookService shopProudictBookService; private ShopProductBookService shopProductBookService;
/** /**
* 列表 * 列表
*/ */
@RequestMapping("/list") @RequestMapping("/list")
// @RequiresPermissions("book:bookchaptercontent:list")
public R list(@RequestParam Map<String, Object> params) { public R list(@RequestParam Map<String, Object> params) {
PageUtils page = bookChapterContentService.queryPage(params); PageUtils page = bookChapterContentService.queryPage(params);
return R.ok().put("page", page); return R.ok().put("page", page);
} }
/** /**
* 信息 * 信息
*/ */
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
// @RequiresPermissions("book:bookchaptercontent:info")
public R info(@PathVariable("id") Integer id) { public R info(@PathVariable("id") Integer id) {
BookChapterContentEntity bookChapterContent = bookChapterContentService.getById(id); BookChapterContentEntity bookChapterContent = bookChapterContentService.getById(id);
@@ -82,7 +75,6 @@ public class BookChapterContentController {
* 保存 * 保存
*/ */
@RequestMapping("/save") @RequestMapping("/save")
// @RequiresPermissions("book:bookchaptercontent:save")
public R save(@RequestBody BookChapterContentEntity bookChapterContent) { public R save(@RequestBody BookChapterContentEntity bookChapterContent) {
bookChapterContentService.save(bookChapterContent); bookChapterContentService.save(bookChapterContent);
@@ -93,7 +85,6 @@ public class BookChapterContentController {
* 修改 * 修改
*/ */
@RequestMapping("/update") @RequestMapping("/update")
// @RequiresPermissions("book:bookchaptercontent:update")
public R update(@RequestBody BookChapterContentEntity bookChapterContent) { public R update(@RequestBody BookChapterContentEntity bookChapterContent) {
bookChapterContentService.updateById(bookChapterContent); bookChapterContentService.updateById(bookChapterContent);
@@ -104,7 +95,6 @@ public class BookChapterContentController {
* 删除 * 删除
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
// @RequiresPermissions("book:bookchaptercontent:delete")
public R delete(@RequestBody Integer[] ids) { public R delete(@RequestBody Integer[] ids) {
bookChapterContentService.removeByIds(Arrays.asList(ids)); bookChapterContentService.removeByIds(Arrays.asList(ids));
@@ -116,17 +106,10 @@ public class BookChapterContentController {
* 章节拆分转换单句 * 章节拆分转换单句
*/ */
@RequestMapping("/getBookVoices") @RequestMapping("/getBookVoices")
// @RequiresPermissions("book:bookchaptercontent:delete")
public R getBookVoices(@RequestParam("id") Integer id) { public R getBookVoices(@RequestParam("id") Integer id) {
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
singleThreadExecutor.execute(new Runnable() { singleThreadExecutor.execute(() -> bookChapterContentService.getWordChapterParagraph(id));
@Override
public void run() {
bookChapterContentService.getWordChapterParagraph(id);
}
});
BookEntity bookEntity = bookService.getBaseMapper().selectById(id); BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
bookEntity.setContentStatus("2"); bookEntity.setContentStatus("2");
@@ -134,6 +117,7 @@ public class BookChapterContentController {
return R.ok(); return R.ok();
} }
/** /**
* 章节单句 转成音频 * 章节单句 转成音频
*/ */
@@ -146,14 +130,9 @@ public class BookChapterContentController {
return R.error("语音文件未生成"); return R.error("语音文件未生成");
} }
FileInputStream fileInputStream = new FileInputStream(file); FileInputStream fileInputStream = new FileInputStream(file);
MultipartFile multipartFile = new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(fileInputStream)); MultipartFile multipartFile = new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(fileInputStream));
String path = ossService.uploadFileAvatar(multipartFile); String path = ossService.uploadFileAvatar(multipartFile);
fileInputStream.close(); fileInputStream.close();
file.delete(); file.delete();
if (StringUtils.isEmpty(path)) { if (StringUtils.isEmpty(path)) {
@@ -271,6 +250,7 @@ public class BookChapterContentController {
/** /**
* 鉴权获取章节 * 鉴权获取章节
*
* @param bookid * @param bookid
* @param userId * @param userId
* @return * @return
@@ -335,7 +315,6 @@ public class BookChapterContentController {
} }
List<BookChapterEntity> book = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>() List<BookChapterEntity> book = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
.eq("book_id", bookid)); .eq("book_id", bookid));
ArrayList<Object> chapterList = new ArrayList<>(); ArrayList<Object> chapterList = new ArrayList<>();
@@ -351,6 +330,7 @@ public class BookChapterContentController {
/** /**
* 获取章节音频地址 * 获取章节音频地址
*
* @return * @return
*/ */
@RequestMapping("/getBooksCatalogue") @RequestMapping("/getBooksCatalogue")
@@ -364,12 +344,11 @@ public class BookChapterContentController {
UserEbookBuyEntity userEbookBuyEntity = userEbookBuyService.getBaseMapper().selectOne(new LambdaQueryWrapper<UserEbookBuyEntity>(). UserEbookBuyEntity userEbookBuyEntity = userEbookBuyService.getBaseMapper().selectOne(new LambdaQueryWrapper<UserEbookBuyEntity>().
eq(UserEbookBuyEntity::getUserId, userId).eq(UserEbookBuyEntity::getBookId, bookId)); eq(UserEbookBuyEntity::getUserId, userId).eq(UserEbookBuyEntity::getBookId, bookId));
if (chapter_info.getNumber() > book_info.getFreeChapterCount() && userEbookBuyEntity == null) { if (chapter_info.getNumber() > book_info.getFreeChapterCount() && userEbookBuyEntity == null) {
Integer productByBookId = shopProudictBookService.getProductByBookId(bookId); Integer productByBookId = shopProductBookService.getProductByBookId(bookId);
return R.ok().put("jq", false).put("product", productByBookId); return R.ok().put("jq", false).put("product", productByBookId);
} }
return R.ok().put("chapter", chapter_info); return R.ok().put("chapter", chapter_info);
} }
@@ -421,13 +400,9 @@ public R getBooksCatalogue1(@RequestParam("chapterid") Integer id,
} }
} }
if (isVip == 2) { if (isVip == 2) {
// 鉴权 查询权限表中 用户是否开通 // 鉴权 查询权限表中 用户是否开通
boolean b = myUserService.bookAuthenticate(bookid, userId); boolean b = myUserService.bookAuthenticate(bookid, userId);
@@ -439,11 +414,9 @@ public R getBooksCatalogue1(@RequestParam("chapterid") Integer id,
} }
ArrayList<Object> chapterList = new ArrayList<>(); ArrayList<Object> chapterList = new ArrayList<>();
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("name", bookChapterEntity.getChapter()); map.put("name", bookChapterEntity.getChapter());
map.put("url", bookChapterEntity.getVoices()); map.put("url", bookChapterEntity.getVoices());
@@ -458,14 +431,6 @@ public R getBooksCatalogue1(@RequestParam("chapterid") Integer id,
} }
/** /**
* app 获取电子书章节内容 * app 获取电子书章节内容
*/ */
@@ -499,7 +464,6 @@ public R getBooksCatalogue1(@RequestParam("chapterid") Integer id,
} }
ArrayList<Object> list = new ArrayList<>(); ArrayList<Object> list = new ArrayList<>();
List<BookChapterContentEntity> bookChapterContentEntities = bookChapterContentService.getBaseMapper().selectList(new QueryWrapper<BookChapterContentEntity>() List<BookChapterContentEntity> bookChapterContentEntities = bookChapterContentService.getBaseMapper().selectList(new QueryWrapper<BookChapterContentEntity>()
.eq("book_id", bookid) .eq("book_id", bookid)

View File

@@ -7,13 +7,11 @@ import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.ReadProvinceUtil; import com.peanut.common.utils.ReadProvinceUtil;
import com.peanut.modules.book.dao.BookDao; import com.peanut.modules.book.dao.BookDao;
import com.peanut.modules.book.entity.*; import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.*; import com.peanut.modules.book.service.*;
import com.peanut.modules.book.vo.BookIndexVo; import com.peanut.modules.book.vo.BookIndexVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -58,7 +56,7 @@ public class BookController {
@Autowired @Autowired
private ShopProductService shopProductService; private ShopProductService shopProductService;
@Autowired @Autowired
private ShopProudictBookService shopProudictBookService; private ShopProductBookService shopProductBookService;
@Autowired @Autowired
private ShopProductToLabelService shopProductToLabelService; private ShopProductToLabelService shopProductToLabelService;
final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10); final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
@@ -123,7 +121,7 @@ public class BookController {
BookEntity book_info = bookService.getById(bookId); BookEntity book_info = bookService.getById(bookId);
book_info.setAuthor(authorService.getById(book_info.getAuthorId())); book_info.setAuthor(authorService.getById(book_info.getAuthorId()));
book_info.setPublisher(publisherService.getById(book_info.getPublisherId())); book_info.setPublisher(publisherService.getById(book_info.getPublisherId()));
book_info.setProductId(shopProudictBookService.getProductByBookId(bookId)); book_info.setProductId(shopProductBookService.getProductByBookId(bookId));
LambdaQueryWrapper<UserEbookBuyEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<UserEbookBuyEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(UserEbookBuyEntity::getUserId,userId); wrapper.eq(UserEbookBuyEntity::getUserId,userId);
@@ -715,7 +713,7 @@ public class BookController {
} }
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper1); Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper1);
for (BookEntity b : bookEntityPage.getRecords()){ for (BookEntity b : bookEntityPage.getRecords()){
b.setProductId(shopProudictBookService.getProductByBookId(b.getId())); b.setProductId(shopProductBookService.getProductByBookId(b.getId()));
} }
return R.ok().put("page",bookEntityPage); return R.ok().put("page",bookEntityPage);

View File

@@ -7,16 +7,13 @@ import com.peanut.modules.book.entity.BookEntity;
import com.peanut.modules.book.entity.BookTeachEntity; import com.peanut.modules.book.entity.BookTeachEntity;
import com.peanut.modules.book.service.BookService; import com.peanut.modules.book.service.BookService;
import com.peanut.modules.book.service.BookTeachService; import com.peanut.modules.book.service.BookTeachService;
import com.peanut.modules.book.service.ShopProudictBookService; import com.peanut.modules.book.service.ShopProductBookService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@RestController @RestController
@RequestMapping("book/teach") @RequestMapping("book/teach")
public class BookTeachController { public class BookTeachController {
@@ -25,10 +22,11 @@ public class BookTeachController {
@Autowired @Autowired
private BookService bookService; private BookService bookService;
@Autowired @Autowired
private ShopProudictBookService shopProudictBookService; private ShopProductBookService shopProductBookService;
/** /**
* 获取讲书列表 * 获取讲书列表
*
* @return * @return
*/ */
@RequestMapping("/getTeachBooks") @RequestMapping("/getTeachBooks")
@@ -43,6 +41,7 @@ public class BookTeachController {
/** /**
* 获取讲书目录 * 获取讲书目录
*
* @return * @return
*/ */
@RequestMapping("/getBookTeachItems") @RequestMapping("/getBookTeachItems")
@@ -57,41 +56,20 @@ public class BookTeachController {
/** /**
* 获取讲书的详情 * 获取讲书的详情
*
* @param teachId * @param teachId
* @return * @return
*/ */
@RequestMapping("/getTeachDetail") @RequestMapping("/getTeachDetail")
public R getTeachDetail(@RequestParam Integer teachId) { public R getTeachDetail(@RequestParam Integer teachId) {
BookTeachEntity teach_info = bookTeachService.getById(teachId); BookTeachEntity teach_info = bookTeachService.getById(teachId);
Integer productByBookId = shopProudictBookService.getProductByBookId(teach_info.getBookId()); Integer productByBookId = shopProductBookService.getProductByBookId(teach_info.getBookId());
return R.ok().put("bookTeach", teach_info).put("product", productByBookId); return R.ok().put("bookTeach", teach_info).put("product", productByBookId);
} }
/**
* 添加讲书
* @return
*/
// @RequestMapping("/addTeach")
// public R addTeach(@RequestParam Integer bookId,
// @RequestParam Integer chapter,
// @RequestParam String title,
// @RequestParam String voices,
// @RequestParam String content){
// BookTeachEntity bookTeachEntity = new BookTeachEntity();
// bookTeachEntity.setBookId(bookId);
// bookTeachEntity.setChapter(chapter);
// bookTeachEntity.setTitle(title);
// bookTeachEntity.setVoices(voices);
// bookTeachEntity.setContent(content);
// bookTeachService.save(bookTeachEntity);
//
// return R.ok();
// }
/** /**
* 添加讲书的章节 * 添加讲书的章节
*
* @param bookTeach * @param bookTeach
* @return * @return
*/ */
@@ -103,6 +81,7 @@ public class BookTeachController {
/** /**
* 删除讲书章节 * 删除讲书章节
*
* @return * @return
*/ */
@RequestMapping("/delTeach") @RequestMapping("/delTeach")
@@ -113,27 +92,7 @@ public class BookTeachController {
/** /**
* 编辑讲书的章节 * 编辑讲书的章节
* @return *
*/
// @RequestMapping("/updateTeach")
// public R updateTeach(@RequestParam Integer teachId,
// @RequestParam Integer chapter,
// @RequestParam String title,
// @RequestParam String voices,
// @RequestParam String content){
//
// BookTeachEntity bookTeachEntity = new BookTeachEntity();
// bookTeachEntity.setTeachId(teachId);
// bookTeachEntity.setTitle(title);
// bookTeachEntity.setVoices(voices);
// bookTeachEntity.setContent(content);
// bookTeachService.updateById(bookTeachEntity);
// return R.ok();
//
// }
/**
* 编辑讲书的章节
* @return * @return
*/ */
@RequestMapping("/updateTeach") @RequestMapping("/updateTeach")
@@ -141,7 +100,4 @@ public class BookTeachController {
bookTeachService.updateById(bookTeach); bookTeachService.updateById(bookTeach);
return R.ok(); return R.ok();
} }
} }

View File

@@ -63,7 +63,7 @@ public class BuyOrderController {
private RabbitTemplate rabbitTemplate; private RabbitTemplate rabbitTemplate;
@Autowired @Autowired
private ShopProudictBookService shopProudictBookService; private ShopProductBookService shopProductBookService;
/** /**
* 列表 * 列表
@@ -523,9 +523,9 @@ public class BuyOrderController {
private void addEbookToUser(List<BuyOrderDetailEntity> products, BuyOrderEntity buyOrder) { private void addEbookToUser(List<BuyOrderDetailEntity> products, BuyOrderEntity buyOrder) {
List<Integer> productIds = products.stream().map(BuyOrderDetailEntity::getProductId).collect(Collectors.toList()); List<Integer> productIds = products.stream().map(BuyOrderDetailEntity::getProductId).collect(Collectors.toList());
for (Integer productId : productIds) { for (Integer productId : productIds) {
List<Integer> collect = shopProudictBookService.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProudictBookEntity>() List<Integer> collect = shopProductBookService.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProductBookEntity>()
.eq(ShopProudictBookEntity::getProudictId, productId) .eq(ShopProductBookEntity::getProductId, productId)
.eq(ShopProudictBookEntity::getDelFlag, 0)).stream().map(ShopProudictBookEntity::getBookId).collect(Collectors.toList()); .eq(ShopProductBookEntity::getDelFlag, 0)).stream().map(ShopProductBookEntity::getBookId).collect(Collectors.toList());
userEbookBuyService.addBookForUser(buyOrder.getUserId(), collect); userEbookBuyService.addBookForUser(buyOrder.getUserId(), collect);
} }
} }

View File

@@ -0,0 +1,75 @@
package com.peanut.modules.book.controller;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.ShopProductBookEntity;
import com.peanut.modules.book.service.ShopProductBookService;
import com.peanut.modules.book.vo.ProductBookQueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("book/shopProudictBook")
public class ShopProductBookController {
@Autowired
private ShopProductBookService shopProductBookService;
/**
* 列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = shopProductBookService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 图书与商品信息
*/
// 根据商品id查询图书信息查询到图书信息反向查找包含该图书id的所有商品返回
@RequestMapping("/proudictBooklist")
public R productBookList(@RequestParam Integer productId) {
List<ProductBookQueryVO> cartList = shopProductBookService.getCartList(productId);
return R.ok().put("cartList", cartList);
}
/**
* 保存
*/
@RequestMapping("/save")
public R save(@RequestBody ShopProductBookEntity shopProductBookEntity) {
for (Integer s : shopProductBookEntity.getBookIdList()) {
if (s != null) {
Integer productId = shopProductBookEntity.getProductId();
shopProductBookEntity.setProductId(productId);
shopProductBookEntity.setBookId(s);
shopProductBookService.save(shopProductBookEntity);
}
}
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody ShopProductBookEntity shopProductBookEntity) {
shopProductBookService.updateById(shopProductBookEntity);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestParam Integer id) {
shopProductBookService.removeById(id);
return R.ok();
}
}

View File

@@ -1,6 +1,8 @@
package com.peanut.modules.book.controller; package com.peanut.modules.book.controller;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.modules.book.entity.*; import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.*; import com.peanut.modules.book.service.*;
@@ -15,7 +17,6 @@ import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R; import com.peanut.common.utils.R;
/** /**
* 商品表 * 商品表
* *
@@ -35,27 +36,25 @@ public class ShopProductController {
@Autowired @Autowired
private BookService bookService; private BookService bookService;
@Autowired @Autowired
private ShopProudictBookService shopProudictBookService; private ShopProductBookService shopProductBookService;
@Autowired @Autowired
private ShopProductToLabelService shopProductToLabelService; private ShopProductToLabelService shopProductToLabelService;
@Autowired
private ShopProductLabelService shopProductLabelService;
/** /**
* 精选商品 列表 * 精选商品 列表
*/ */
@RequestMapping("/listproductSales") @RequestMapping("/listproductSales")
// @RequiresPermissions("book:shopproduct:list") public R listProductSales(@RequestParam Map<String, Object> params) {
public R listproductSales(@RequestParam Map<String, Object> params){
PageUtils page = shopProductService.queryPageproductSales(params); PageUtils page = shopProductService.queryPageproductSales(params);
return R.ok().put("page", page); return R.ok().put("page", page);
} }
/** /**
* 折扣商品 * 折扣商品
*/ */
@RequestMapping("/listactivityprice") @RequestMapping("/listactivityprice")
public R listactivityprice(@RequestParam Map<String, Object> params){ public R listActivityPrice(@RequestParam Map<String, Object> params) {
PageUtils page = shopProductService.queryPageactivityprice(params); PageUtils page = shopProductService.queryPageactivityprice(params);
return R.ok().put("page", page); return R.ok().put("page", page);
@@ -65,7 +64,6 @@ public class ShopProductController {
* 列表 * 列表
*/ */
@RequestMapping("/list") @RequestMapping("/list")
// @RequiresPermissions("book:shopproduct:list")
public R list(@RequestParam Map<String, Object> params) { public R list(@RequestParam Map<String, Object> params) {
PageUtils page = shopProductService.appQueryPage(params); PageUtils page = shopProductService.appQueryPage(params);
return R.ok().put("page", page); return R.ok().put("page", page);
@@ -90,18 +88,14 @@ public class ShopProductController {
} }
/** /**
* 未购买书列表 * 未购买书列表
*
* @param userId 用户id * @param userId 用户id
* @return * @return
*/ */
@RequestMapping("/booklist") @RequestMapping("/booklist")
public R booklistss(@RequestParam("userId") Integer userId public R bookList(@RequestParam("userId") Integer userId
) { ) {
//查询已购买的书籍 //查询已购买的书籍
List<BuyOrderDetailEntity> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>() List<BuyOrderDetailEntity> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
@@ -137,20 +131,17 @@ public class ShopProductController {
} }
@RequestMapping("/bookinfo/{productId}") @RequestMapping("/bookinfo/{productId}")
public R bookinfo(@PathVariable("productId") Integer productId){ public R bookInfo(@PathVariable("productId") Integer productId) {
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String, String>>(); ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String, String>>();
List<ShopProudictBookEntity> bookEntityList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>().eq("book_id", productId)); List<ShopProductBookEntity> bookEntityList = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>().eq("book_id", productId));
List<Object> list = new ArrayList<>(); List<Object> list = new ArrayList<>();
ArrayList<String> booklist = new ArrayList<>(); ArrayList<String> booklist = new ArrayList<>();
ShopProductEntity shopProductEntity = null; ShopProductEntity shopProductEntity = null;
for (ShopProudictBookEntity shopProudictBookEntity : bookEntityList) { for (ShopProductBookEntity shopProductBookEntity : bookEntityList) {
Integer proudictId = shopProudictBookEntity.getProudictId(); Integer proudictId = shopProductBookEntity.getProductId();
shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", proudictId)); shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", proudictId));
Integer bookId = shopProudictBookEntity.getBookId(); Integer bookId = shopProductBookEntity.getBookId();
BookEntity byId = bookService.getById(bookId); BookEntity byId = bookService.getById(bookId);
booklist.add(String.valueOf(bookId)); booklist.add(String.valueOf(bookId));
list.add(byId); list.add(byId);
@@ -163,8 +154,6 @@ public class ShopProductController {
} }
@RequestMapping("/bookinfolists/{productId}") @RequestMapping("/bookinfolists/{productId}")
public R bookinfolists(@PathVariable("productId") Integer productId) { public R bookinfolists(@PathVariable("productId") Integer productId) {
//查询商品 //查询商品
@@ -176,31 +165,31 @@ public class ShopProductController {
Integer productId1 = shopProductEntity.getProductId(); Integer productId1 = shopProductEntity.getProductId();
//分类信息 //分类信息
List<Integer> poids = shopCategoryService.findPoid(poid); List<Integer> poids = shopCategoryService.findPoid(poid);
List<ShopProudictBookEntity> proudict = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>() List<ShopProductBookEntity> product = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
.eq("proudict_id", productId1)); .eq("product_id", productId1));
List<ShopProductEntity> result = new ArrayList<>(); List<ShopProductEntity> result = new ArrayList<>();
//获取商品id //获取商品id
Set<Integer> productIds = new HashSet<>(); Set<Integer> productIds = new HashSet<>();
productIds.add(productId); productIds.add(productId);
for (ShopProudictBookEntity shopProudictBookEntity : proudict) { for (ShopProductBookEntity shopProductBookEntity : product) {
Integer bookId = shopProudictBookEntity.getBookId(); Integer bookId = shopProductBookEntity.getBookId();
BookEntity byId = bookService.getById(bookId); BookEntity byId = bookService.getById(bookId);
List<ShopProudictBookEntity> entityByBookId = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>() List<ShopProductBookEntity> entityByBookId = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
.eq("book_id", bookId)); .eq("book_id", bookId));
for(ShopProudictBookEntity entity : entityByBookId){ for (ShopProductBookEntity entity : entityByBookId) {
productIds.add(entity.getProudictId()); productIds.add(entity.getProductId());
} }
} }
for (Integer pId : productIds) { for (Integer pId : productIds) {
ShopProductEntity proEntity = null; ShopProductEntity proEntity = null;
proEntity = shopProductService.getById(pId); proEntity = shopProductService.getById(pId);
List<ShopProudictBookEntity> pbookEntitys = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>() List<ShopProductBookEntity> pbookEntitys = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
.eq("proudict_id", pId)); .eq("product_id", pId));
ArrayList<String> booklist = new ArrayList<>(); ArrayList<String> booklist = new ArrayList<>();
List<Object> list = new ArrayList<>(); List<Object> list = new ArrayList<>();
for (ShopProudictBookEntity shopProudictBookEntity : pbookEntitys) { for (ShopProductBookEntity shopProductBookEntity : pbookEntitys) {
booklist.add(String.valueOf(shopProudictBookEntity.getBookId())); booklist.add(String.valueOf(shopProductBookEntity.getBookId()));
BookEntity byId = bookService.getById(shopProudictBookEntity.getBookId()); BookEntity byId = bookService.getById(shopProductBookEntity.getBookId());
list.add(byId); list.add(byId);
} }
proEntity.setPoids(poids); proEntity.setPoids(poids);
@@ -214,6 +203,7 @@ public class ShopProductController {
/** /**
* 获取关联订单列表 * 获取关联订单列表
*
* @param productId * @param productId
* @return * @return
*/ */
@@ -221,17 +211,17 @@ public class ShopProductController {
public R getGlProductList(@RequestParam int productId) { public R getGlProductList(@RequestParam int productId) {
//获取此商品下的books //获取此商品下的books
List<Integer> ids = shopProudictBookService.getBookidsByProductId(productId); List<Integer> ids = shopProductBookService.getBookIdsByProductId(productId);
if (ids.size() == 0) { if (ids.size() == 0) {
return R.ok(); return R.ok();
} }
List<ShopProudictBookEntity> ss = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>() List<ShopProductBookEntity> ss = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
.eq("del_flag", 0) .eq("del_flag", 0)
.in("book_id", ids) .in("book_id", ids)
.groupBy("proudict_id") .groupBy("product_id")
.having("count(proudict_id) >="+ids.size()) .having("count(product_id) >=" + ids.size())
); );
List<ShopProductEntity> frag = new ArrayList<>(); List<ShopProductEntity> frag = new ArrayList<>();
@@ -239,8 +229,8 @@ public class ShopProductController {
if (ids.size() == 0) { if (ids.size() == 0) {
return R.ok(); return R.ok();
} }
for (ShopProudictBookEntity spbe : ss){ for (ShopProductBookEntity spbe : ss) {
ShopProductEntity ca_sp = shopProductService.getById(spbe.getProudictId()); ShopProductEntity ca_sp = shopProductService.getById(spbe.getProductId());
frag.add(ca_sp); frag.add(ca_sp);
} }
@@ -250,6 +240,7 @@ public class ShopProductController {
/** /**
* 信息 * 信息
*
* @param productId * @param productId
* @return * @return
*/ */
@@ -268,11 +259,11 @@ public class ShopProductController {
List<Object> list = new ArrayList<>(); List<Object> list = new ArrayList<>();
List<Object> bookIdlist = new ArrayList<>(); List<Object> bookIdlist = new ArrayList<>();
ArrayList<String> booklist = new ArrayList<>(); ArrayList<String> booklist = new ArrayList<>();
List<ShopProudictBookEntity> proudict = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>() List<ShopProductBookEntity> product = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
.eq("proudict_id", productId1)); .eq("product_id", productId1));
for (ShopProudictBookEntity shopProudictBookEntity : proudict) { for (ShopProductBookEntity shopProductBookEntity : product) {
Integer id = shopProudictBookEntity.getId(); Integer id = shopProductBookEntity.getId();
Integer bookId = shopProudictBookEntity.getBookId(); Integer bookId = shopProductBookEntity.getBookId();
BookEntity byId = bookService.getById(bookId); BookEntity byId = bookService.getById(bookId);
bookIdlist.add(id); bookIdlist.add(id);
@@ -296,28 +287,27 @@ public class ShopProductController {
} }
/** /**
* 根据传入商品id反向查询图书id然后查询图书id下包含的商品 * 根据传入商品id反向查询图书id然后查询图书id下包含的商品
*
* @param productId * @param productId
* @return * @return
*/ */
@RequestMapping("/infobook/{productId}") @RequestMapping("/infobook/{productId}")
public R infobook(@PathVariable("productId") Integer productId) { public R infobook(@PathVariable("productId") Integer productId) {
List<ShopProudictBookEntity> proudict = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>() List<ShopProductBookEntity> proudict = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
.eq("proudict_id", productId)); .eq("product_id", productId));
List<Object> list = new ArrayList<>(); List<Object> list = new ArrayList<>();
for (ShopProudictBookEntity shopProudictBookEntity : proudict) { for (ShopProductBookEntity shopProductBookEntity : proudict) {
Integer bookId = shopProudictBookEntity.getBookId(); Integer bookId = shopProductBookEntity.getBookId();
List<ShopProudictBookEntity> bookIds = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>() List<ShopProductBookEntity> bookIds = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
.eq("book_id", bookId)); .eq("book_id", bookId));
for (ShopProudictBookEntity shopProudict : bookIds) { for (ShopProductBookEntity shopProduct : bookIds) {
Integer proudictId = shopProudict.getProudictId(); Integer shopProductId = shopProduct.getProductId();
List<ShopProductEntity> shopProductEntities = shopProductService.getBaseMapper().selectList(new QueryWrapper<ShopProductEntity>() List<ShopProductEntity> shopProductEntities = shopProductService.getBaseMapper().selectList(new QueryWrapper<ShopProductEntity>()
.eq("proudict_id",proudictId)); .eq("product_id", shopProductId));
list.add(shopProductEntities); list.add(shopProductEntities);
} }
} }
@@ -344,18 +334,19 @@ public class ShopProductController {
shopProduct.setBookId(""); shopProduct.setBookId("");
} }
shopProductService.save(shopProduct); shopProductService.save(shopProduct);
ShopProudictBookEntity shopProudictBookEntity = new ShopProudictBookEntity(); ShopProductBookEntity shopProductBookEntity = new ShopProductBookEntity();
for (String s : shopProduct.getBookids()) { for (String s : shopProduct.getBookids()) {
String bookidlist = s; String bookidlist = s;
if (bookidlist != null) { if (bookidlist != null) {
Integer proudict = shopProduct.getProductId(); Integer proudict = shopProduct.getProductId();
shopProudictBookEntity.setProudictId(proudict); shopProductBookEntity.setProductId(proudict);
shopProudictBookEntity.setBookId(Integer.valueOf(bookidlist)); shopProductBookEntity.setBookId(Integer.valueOf(bookidlist));
shopProudictBookService.save(shopProudictBookEntity); shopProductBookService.save(shopProductBookEntity);
} }
} }
return R.ok(); return R.ok();
} }
/** /**
* 修改 * 修改
*/ */
@@ -377,24 +368,24 @@ public class ShopProductController {
shopProduct.setBookId(""); shopProduct.setBookId("");
} }
//传过来的proudictid只有一个但是bookid可能有多个对应的一个proudictid一个bookid为一条数据一对多存储 //传过来的proudictid只有一个但是bookid可能有多个对应的一个proudictid一个bookid为一条数据一对多存储
List<ShopProudictBookEntity> bookyList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>() List<ShopProductBookEntity> bookyList = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
.eq("proudict_id", productId)); .eq("product_id", productId));
Integer shop_book_ids[] = new Integer[bookyList.size()]; Integer shop_book_ids[] = new Integer[bookyList.size()];
for (int i = 0; i < bookyList.size(); i++) { for (int i = 0; i < bookyList.size(); i++) {
shop_book_ids[i] = bookyList.get(i).getId(); shop_book_ids[i] = bookyList.get(i).getId();
} }
if (null != shop_book_ids && shop_book_ids.length > 0) { if (null != shop_book_ids && shop_book_ids.length > 0) {
shopProudictBookService.getBaseMapper().deleteBatchIds(Arrays.asList(shop_book_ids)); shopProductBookService.getBaseMapper().deleteBatchIds(Arrays.asList(shop_book_ids));
} }
ShopProudictBookEntity shopProudictBookEntity = new ShopProudictBookEntity(); ShopProductBookEntity shopProductBookEntity = new ShopProductBookEntity();
for (String s : shopProduct.getBookids()) { for (String s : shopProduct.getBookids()) {
String bookidlist = s; String bookidlist = s;
if (bookidlist != null) { if (bookidlist != null) {
Integer proudict = shopProduct.getProductId(); Integer proudict = shopProduct.getProductId();
shopProudictBookEntity.setProudictId(proudict); shopProductBookEntity.setProductId(proudict);
shopProudictBookEntity.setBookId(Integer.valueOf(bookidlist)); shopProductBookEntity.setBookId(Integer.valueOf(bookidlist));
shopProudictBookService.save(shopProudictBookEntity); shopProductBookService.save(shopProductBookEntity);
} }
} }
@@ -432,23 +423,18 @@ public class ShopProductController {
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Integer[] productIds) { public R delete(@RequestBody Integer[] productIds) {
List<ShopProudictBookEntity> bookEntityList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>() List<ShopProductBookEntity> bookEntityList = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
.in("proudict_id", productIds) .in("product_id", productIds)
); );
for (ShopProudictBookEntity shopProudictBookEntity : bookEntityList) { for (ShopProductBookEntity shopProductBookEntity : bookEntityList) {
Integer id = shopProudictBookEntity.getId(); Integer id = shopProductBookEntity.getId();
shopProudictBookService.removeById(id); shopProductBookService.removeById(id);
} }
shopProductService.removeByIds(Arrays.asList(productIds)); shopProductService.removeByIds(Arrays.asList(productIds));
return R.ok(); return R.ok();
} }
/** /**
* 列表 * 列表
*/ */
@@ -460,11 +446,6 @@ public class ShopProductController {
} }
/** /**
* 获取分类下商品列表 * 获取分类下商品列表
*/ */
@@ -506,5 +487,4 @@ public class ShopProductController {
.like("product_name", productName)); .like("product_name", productName));
return R.ok().put("list", list); return R.ok().put("list", list);
} }
} }

View File

@@ -1,95 +0,0 @@
package com.peanut.modules.book.controller;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.ShopProudictBookEntity;
import com.peanut.modules.book.service.ShopProudictBookService;
import com.peanut.modules.book.vo.ProudictBookqueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("book/shopProudictBook")
public class ShopProudictBookController {
@Autowired
private ShopProudictBookService shopProudictBookService;
/**
* 列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params ){
PageUtils page = shopProudictBookService.queryPage(params);
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);
}
/**
* 保存
*/
@RequestMapping("/save")
public R save(@RequestBody ShopProudictBookEntity shopProudictBookEntity){
for(Integer s : shopProudictBookEntity.getBookidlist()){
Integer bookidlist = s;
if (bookidlist!=null){
Integer proudict = shopProudictBookEntity.getProudictId();
shopProudictBookEntity.setProudictId(proudict);
shopProudictBookEntity.setBookId(bookidlist);
shopProudictBookService.save(shopProudictBookEntity);
}
}
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody ShopProudictBookEntity shopProudictBookEntity){
shopProudictBookService.updateById(shopProudictBookEntity);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestParam Integer id){
shopProudictBookService.removeById(id);
return R.ok();
}
}

View File

@@ -1,13 +1,13 @@
package com.peanut.modules.book.dao; package com.peanut.modules.book.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.peanut.modules.book.entity.ShopProudictBookEntity; import com.peanut.modules.book.entity.ShopProductBookEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface ShopProudictBookDao extends BaseMapper<ShopProudictBookEntity> { public interface ShopProductBookDao extends BaseMapper<ShopProductBookEntity> {
List<Integer> getOrderBookId(String orderSn); List<Integer> getOrderBookId(String orderSn);
} }

View File

@@ -1,19 +1,25 @@
package com.peanut.modules.book.entity; package com.peanut.modules.book.entity;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import lombok.Data; import lombok.Data;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@Data
@TableName("shop_proudict_book")
public class ShopProudictBookEntity {
@Data
@TableName("shop_product_book")
public class ShopProductBookEntity {
/**
* 主键 id
*/
@TableId @TableId
private Integer id; private Integer id;
/** /**
* 商品id * 商品id
*/ */
@TableField("proudict_id") @TableField("product_id")
private Integer proudictId; private Integer productId;
/** /**
* 图书id * 图书id
*/ */
@@ -23,9 +29,10 @@ public class ShopProudictBookEntity {
* 多个图书id (备用) * 多个图书id (备用)
*/ */
@TableField("book_ids") @TableField("book_ids")
private Integer bookdIds; private Integer bookIds;
/**
* 删除标记
*/
@TableField("del_flag") @TableField("del_flag")
@TableLogic @TableLogic
private Integer delFlag; private Integer delFlag;
@@ -34,7 +41,9 @@ public class ShopProudictBookEntity {
*/ */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Date createTime; private Date createTime;
// /**
* 书籍列表
*/
@TableField(exist = false) @TableField(exist = false)
private ArrayList<Integer> bookidlist; private ArrayList<Integer> bookIdList;
} }

View File

@@ -0,0 +1,24 @@
package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.PageUtils;
import com.peanut.modules.book.entity.ShopProductBookEntity;
import com.peanut.modules.book.vo.ProductBookQueryVO;
import java.util.List;
import java.util.Map;
public interface ShopProductBookService extends IService<ShopProductBookEntity> {
PageUtils queryPage(Map<String, Object> params);
PageUtils productBookQueryPage(Map<String, Object> params);
List<ProductBookQueryVO> getCartList(Integer productId);
List<Integer> getBookIdsByProductId(Integer productId);
Integer getProductByBookId(Integer bookId);
List<Integer> getOrderBookId(String orderSn);
}

View File

@@ -1,24 +0,0 @@
package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.PageUtils;
import com.peanut.modules.book.entity.ShopProudictBookEntity;
import com.peanut.modules.book.vo.ProudictBookqueryVO;
import java.util.List;
import java.util.Map;
public interface ShopProudictBookService extends IService<ShopProudictBookEntity> {
PageUtils queryPage(Map<String, Object> params);
PageUtils proudictBookqueryPage(Map<String, Object> params);
List<ProudictBookqueryVO> getCartList(Integer proudictId);
List<Integer> getBookidsByProductId(Integer productId);
Integer getProductByBookId(Integer bookId);
List<Integer> getOrderBookId(String orderSn);
}

View File

@@ -6,14 +6,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.PageUtils; import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query; import com.peanut.common.utils.Query;
import com.peanut.modules.book.dao.ShopProudictBookDao; import com.peanut.modules.book.dao.ShopProductBookDao;
import com.peanut.modules.book.entity.BookEntity; import com.peanut.modules.book.entity.BookEntity;
import com.peanut.modules.book.entity.ShopProductEntity; import com.peanut.modules.book.entity.ShopProductEntity;
import com.peanut.modules.book.entity.ShopProudictBookEntity; import com.peanut.modules.book.entity.ShopProductBookEntity;
import com.peanut.modules.book.service.BookService; import com.peanut.modules.book.service.BookService;
import com.peanut.modules.book.service.ShopProductService; import com.peanut.modules.book.service.ShopProductService;
import com.peanut.modules.book.service.ShopProudictBookService; import com.peanut.modules.book.service.ShopProductBookService;
import com.peanut.modules.book.vo.ProudictBookqueryVO; import com.peanut.modules.book.vo.ProductBookQueryVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -22,50 +22,50 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Service("shopProudictBookService") @Service("shopProductBookService")
public class ShopProudictBookServiceImpl extends ServiceImpl<ShopProudictBookDao, ShopProudictBookEntity> implements ShopProudictBookService { public class ShopProductBookServiceImpl extends ServiceImpl<ShopProductBookDao, ShopProductBookEntity> implements ShopProductBookService {
@Autowired @Autowired
private ShopProductService shopProductService; private ShopProductService shopProductService;
@Autowired @Autowired
private BookService bookService; private BookService bookService;
@Autowired @Autowired
private ShopProudictBookDao shopProudictBookDao; private ShopProductBookDao shopProductBookDao;
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
IPage<ShopProudictBookEntity> page = this.page( IPage<ShopProductBookEntity> page = this.page(
new Query<ShopProudictBookEntity>().getPage(params), new Query<ShopProductBookEntity>().getPage(params),
new QueryWrapper<ShopProudictBookEntity>() new QueryWrapper<>()
); );
return new PageUtils(page); return new PageUtils(page);
} }
@Override @Override
public PageUtils proudictBookqueryPage(Map<String, Object> params) { public PageUtils productBookQueryPage(Map<String, Object> params) {
Object proudictId = params.get("proudictId"); Object proudictId = params.get("proudictId");
IPage<ShopProudictBookEntity> page = this.page( IPage<ShopProductBookEntity> page = this.page(
new Query<ShopProudictBookEntity>().getPage(params), new Query<ShopProductBookEntity>().getPage(params),
new QueryWrapper<ShopProudictBookEntity>().eq("proudict_id", proudictId) new QueryWrapper<ShopProductBookEntity>().eq("product_id", proudictId)
); );
List<ShopProudictBookEntity> records = page.getRecords(); List<ShopProductBookEntity> records = page.getRecords();
return new PageUtils(page); return new PageUtils(page);
} }
@Override @Override
public List<ProudictBookqueryVO> getCartList(Integer proudictId) { public List<ProductBookQueryVO> getCartList(Integer productId) {
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("proudict_id", proudictId)); ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", productId));
List<ShopProudictBookEntity> proudictBooklist = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("proudict_id", proudictId)); List<ShopProductBookEntity> proudictBooklist = this.list(new QueryWrapper<ShopProductBookEntity>().eq("product_id", productId));
List prList = new ArrayList<>(); List prList = new ArrayList<>();
List prLists = new ArrayList<>(); List prLists = new ArrayList<>();
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
for (ShopProudictBookEntity shopProudictBookEntity : proudictBooklist) { for (ShopProductBookEntity shopProductBookEntity : proudictBooklist) {
Integer bookId = shopProudictBookEntity.getBookId(); Integer bookId = shopProductBookEntity.getBookId();
List<ShopProudictBookEntity> booklist = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("book_id", bookId)); List<ShopProductBookEntity> booklist = this.list(new QueryWrapper<ShopProductBookEntity>().eq("book_id", bookId));
for (ShopProudictBookEntity shopProudictBook : booklist) { for (ShopProductBookEntity shopProudictBook : booklist) {
Integer proudictId1 = shopProudictBook.getProudictId(); Integer proudictId1 = shopProudictBook.getProductId();
Integer bookId1 = shopProudictBook.getBookId(); Integer bookId1 = shopProudictBook.getBookId();
BookEntity bookbyId = bookService.getById(bookId1); BookEntity bookbyId = bookService.getById(bookId1);
prList.add(bookbyId); prList.add(bookbyId);
@@ -78,10 +78,10 @@ public class ShopProudictBookServiceImpl extends ServiceImpl<ShopProudictBookDao
} }
@Override @Override
public List<Integer> getBookidsByProductId(Integer productId) { public List<Integer> getBookIdsByProductId(Integer productId) {
List<ShopProudictBookEntity> spbs = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("del_flag", 0).eq("proudict_id", productId)); List<ShopProductBookEntity> spbs = this.list(new QueryWrapper<ShopProductBookEntity>().eq("del_flag", 0).eq("proudict_id", productId));
List<Integer> ids = new ArrayList(); List<Integer> ids = new ArrayList();
for (ShopProudictBookEntity s : spbs) { for (ShopProductBookEntity s : spbs) {
ids.add(s.getBookId()); ids.add(s.getBookId());
} }
return ids; return ids;
@@ -89,14 +89,14 @@ public class ShopProudictBookServiceImpl extends ServiceImpl<ShopProudictBookDao
@Override @Override
public Integer getProductByBookId(Integer bookId) { public Integer getProductByBookId(Integer bookId) {
LambdaQueryWrapper<ShopProudictBookEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ShopProductBookEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ShopProudictBookEntity::getBookId, bookId); wrapper.eq(ShopProductBookEntity::getBookId, bookId);
wrapper.eq(ShopProudictBookEntity::getDelFlag, 0); wrapper.eq(ShopProductBookEntity::getDelFlag, 0);
wrapper.groupBy(ShopProudictBookEntity::getProudictId); wrapper.groupBy(ShopProductBookEntity::getProductId);
List<ShopProudictBookEntity> shopProudictBookEntities = this.getBaseMapper().selectList(wrapper); List<ShopProductBookEntity> shopProudictBookEntities = this.getBaseMapper().selectList(wrapper);
List ids = new ArrayList(); List ids = new ArrayList();
for (ShopProudictBookEntity s : shopProudictBookEntities) { for (ShopProductBookEntity s : shopProudictBookEntities) {
ids.add(s.getProudictId()); ids.add(s.getProductId());
} }
if (ids.size() == 0) { if (ids.size() == 0) {
return null; return null;
@@ -114,7 +114,7 @@ public class ShopProudictBookServiceImpl extends ServiceImpl<ShopProudictBookDao
@Override @Override
public List<Integer> getOrderBookId(String orderSn) { public List<Integer> getOrderBookId(String orderSn) {
return shopProudictBookDao.getOrderBookId(orderSn); return shopProductBookDao.getOrderBookId(orderSn);
} }

View File

@@ -1,14 +1,7 @@
package com.peanut.modules.book.service.impl; package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.peanut.common.utils.ExcludeEmptyQueryWrapper; import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
import com.peanut.modules.book.entity.ShopCategoryEntity;
import com.peanut.modules.book.entity.ShopProudictBookEntity;
import com.peanut.modules.book.service.ShopProudictBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

View File

@@ -0,0 +1,29 @@
package com.peanut.modules.book.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 返回图书与商品基本信息vo,
*/
@Data
public class ProductBookQueryVO {
private Integer bookId;
private String bookName;
private Boolean canListen;
private Integer clockIn;
private String images;
private List<String> products;
private Integer productId;
private String productName;
private BigDecimal price;
private BigDecimal activityPrice;
private Integer sumSales;
private String productImages;
}

View File

@@ -1,40 +0,0 @@
package com.peanut.modules.book.vo;
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 {
/**
*图书基本信息
*/
private Integer bookId;
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;
}

View File

@@ -53,7 +53,7 @@ public class WeChatPayController {
private TransactionDetailsService transactionDetailsService; private TransactionDetailsService transactionDetailsService;
@Autowired @Autowired
private ShopProudictBookService shopProudictBookService; private ShopProductBookService shopProudictBookService;
@Autowired @Autowired
private UserEbookBuyService userEbookBuyService; private UserEbookBuyService userEbookBuyService;

View File

@@ -1,5 +1,18 @@
spring: spring:
redis:
open: false # 是否开启redis缓存 true开启 false关闭
database: 0
host: 39.106.36.183
port: 6379
password: Jgll2015 # 密码(默认为空)
timeout: 6000000ms # 连接超时时长(毫秒)
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 5 # 连接池中的最小空闲连接
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
druid: druid:
@@ -37,7 +50,7 @@ spring:
initSQL: SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci initSQL: SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci
rabbitmq: rabbitmq:
host: 59.110.212.44 host: 39.106.36.183
port: 5672 port: 5672
username: admin username: admin
password: 751019 password: 751019

View File

@@ -1,5 +1,18 @@
spring: spring:
redis:
open: false # 是否开启redis缓存 true开启 false关闭
database: 0
host: 59.110.212.44
port: 6379
password: Jgll2015 # 密码(默认为空)
timeout: 6000000ms # 连接超时时长(毫秒)
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 5 # 连接池中的最小空闲连接
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
druid: druid:

View File

@@ -11,7 +11,7 @@ connection-timeout: 6000000ms
spring: spring:
# 环境 dev|test|prod # 环境 dev|test|prod
profiles: profiles:
active: prod active: dev
# jackson时间格式化 # jackson时间格式化
jackson: jackson:
time-zone: GMT+8 time-zone: GMT+8
@@ -21,19 +21,6 @@ spring:
max-file-size: 100MB max-file-size: 100MB
max-request-size: 100MB max-request-size: 100MB
enabled: true enabled: true
redis:
open: false # 是否开启redis缓存 true开启 false关闭
database: 0
host: 59.110.212.44
port: 6379
password: Jgll2015 # 密码(默认为空)
timeout: 6000000ms # 连接超时时长(毫秒)
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 5 # 连接池中的最小空闲连接
mvc: mvc:
throw-exception-if-no-handler-found: true throw-exception-if-no-handler-found: true
pathmatch: pathmatch:

View File

@@ -1,24 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.peanut.modules.book.dao.ShopProudictBookDao"> <mapper namespace="com.peanut.modules.book.dao.ShopProductBookDao">
<!-- 可根据自己的需求,是否要使用 --> <!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.peanut.modules.book.entity.ShopProudictBookEntity" id="ProudictBookMap"> <resultMap type="com.peanut.modules.book.entity.ShopProductBookEntity" id="ProductBookMap">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="proudictId" column="proudict_id"/> <result property="productId" column="product_id"/>
<result property="delFlag" column="del_flag"/> <result property="delFlag" column="del_flag"/>
<result property="bookId" column="book_id"/> <result property="bookId" column="book_id"/>
<result property="bookdIds" column="book_ids"/> <result property="bookIds" column="book_ids"/>
</resultMap> </resultMap>
<select id="getOrderBookId" parameterType="string" resultType="int"> <select id="getOrderBookId" parameterType="string" resultType="int">
SELECT spb.book_id SELECT spb.book_id
FROM shop_proudict_book spb FROM shop_product_book spb
LEFT JOIN buy_order_detail bod ON spb.proudict_id = bod.product_id LEFT JOIN buy_order_detail bod ON spb.product_id = bod.product_id
LEFT JOIN buy_order bo ON bo.order_id = bod.order_id LEFT JOIN buy_order bo ON bo.order_id = bod.order_id
WHERE bo.order_sn = #{orderSn} AND spb.del_flag != -1 WHERE bo.order_sn = #{orderSn}
AND spb.del_flag != -1
</select> </select>