rename the file
This commit is contained in:
@@ -2,7 +2,6 @@ package com.peanut.modules.book.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -16,7 +15,6 @@ import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.oss.service.OssService;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -31,8 +29,6 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-16 14:32:06
|
||||
@@ -53,27 +49,24 @@ public class BookChapterContentController {
|
||||
@Autowired
|
||||
private UserEbookBuyService userEbookBuyService;
|
||||
@Autowired
|
||||
private ShopProudictBookService shopProudictBookService;
|
||||
private ShopProductBookService shopProductBookService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@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);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:bookchaptercontent:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
BookChapterContentEntity bookChapterContent = bookChapterContentService.getById(id);
|
||||
public R info(@PathVariable("id") Integer id) {
|
||||
BookChapterContentEntity bookChapterContent = bookChapterContentService.getById(id);
|
||||
|
||||
return R.ok().put("bookChapterContent", bookChapterContent);
|
||||
}
|
||||
@@ -82,9 +75,8 @@ public class BookChapterContentController {
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:bookchaptercontent:save")
|
||||
public R save(@RequestBody BookChapterContentEntity bookChapterContent){
|
||||
bookChapterContentService.save(bookChapterContent);
|
||||
public R save(@RequestBody BookChapterContentEntity bookChapterContent) {
|
||||
bookChapterContentService.save(bookChapterContent);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
@@ -93,9 +85,8 @@ public class BookChapterContentController {
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:bookchaptercontent:update")
|
||||
public R update(@RequestBody BookChapterContentEntity bookChapterContent){
|
||||
bookChapterContentService.updateById(bookChapterContent);
|
||||
public R update(@RequestBody BookChapterContentEntity bookChapterContent) {
|
||||
bookChapterContentService.updateById(bookChapterContent);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
@@ -104,9 +95,8 @@ public class BookChapterContentController {
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:bookchaptercontent:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
bookChapterContentService.removeByIds(Arrays.asList(ids));
|
||||
public R delete(@RequestBody Integer[] ids) {
|
||||
bookChapterContentService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
@@ -116,17 +106,10 @@ public class BookChapterContentController {
|
||||
* 章节拆分转换单句
|
||||
*/
|
||||
@RequestMapping("/getBookVoices")
|
||||
// @RequiresPermissions("book:bookchaptercontent:delete")
|
||||
public R getBookVoices(@RequestParam("id") Integer id){
|
||||
public R getBookVoices(@RequestParam("id") Integer id) {
|
||||
|
||||
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
|
||||
singleThreadExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bookChapterContentService.getWordChapterParagraph(id);
|
||||
|
||||
}
|
||||
});
|
||||
singleThreadExecutor.execute(() -> bookChapterContentService.getWordChapterParagraph(id));
|
||||
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||||
bookEntity.setContentStatus("2");
|
||||
@@ -134,6 +117,7 @@ public class BookChapterContentController {
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 章节单句 转成音频
|
||||
*/
|
||||
@@ -146,21 +130,16 @@ public class BookChapterContentController {
|
||||
return R.error("语音文件未生成");
|
||||
}
|
||||
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);
|
||||
|
||||
fileInputStream.close();
|
||||
|
||||
file.delete();
|
||||
|
||||
if (StringUtils.isEmpty(path)){
|
||||
if (StringUtils.isEmpty(path)) {
|
||||
return R.error("语音上传失败");
|
||||
}
|
||||
|
||||
return R.ok().put("voices",path);
|
||||
return R.ok().put("voices", path);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +159,7 @@ public class BookChapterContentController {
|
||||
List<BookChapterContentEntity> book_id = bookChapterContentService.getBaseMapper().selectList(new QueryWrapper<BookChapterContentEntity>()
|
||||
.eq("book_id", id));
|
||||
|
||||
for (BookChapterContentEntity bookContent:book_id) {
|
||||
for (BookChapterContentEntity bookContent : book_id) {
|
||||
String content = bookContent.getContent();
|
||||
//生成相应的语音文件
|
||||
String voices = BaiduVoicesUtils.run(content);
|
||||
@@ -193,9 +172,9 @@ public class BookChapterContentController {
|
||||
|
||||
//把 voices 音频文件读入到内存中并将其转换成MultipartFile格式文件 multipartFile 用于OSS上传
|
||||
// application/x-www-form-urlencoded form表单数据被编码为key/value格式发送到服务器
|
||||
// text/plain 纯文本格式
|
||||
// text/plain 纯文本格式
|
||||
// MultipartFile multipartFile =new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(fileInputStream));
|
||||
MultipartFile multipartFile =new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(fileInputStream));
|
||||
MultipartFile multipartFile = new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(fileInputStream));
|
||||
//上传 multipartFile 文件到阿里云OSS上
|
||||
String path = ossService.uploadFileAvatar(multipartFile);
|
||||
|
||||
@@ -206,7 +185,7 @@ public class BookChapterContentController {
|
||||
file.delete();
|
||||
|
||||
bookChapterContentService.updateById(bookContent);
|
||||
if (StringUtils.isEmpty(path)){
|
||||
if (StringUtils.isEmpty(path)) {
|
||||
bookEntity.setVoicesStatus("3");
|
||||
}
|
||||
}
|
||||
@@ -235,7 +214,7 @@ public class BookChapterContentController {
|
||||
List<BookChapterEntity> book_id = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
|
||||
|
||||
|
||||
for (BookChapterEntity bookChapter:book_id) {
|
||||
for (BookChapterEntity bookChapter : book_id) {
|
||||
String content = bookChapter.getContent();
|
||||
//生成相应的语音文件
|
||||
String voices = BaiduVoicesUtils.run(content);
|
||||
@@ -245,7 +224,7 @@ public class BookChapterContentController {
|
||||
bookEntity.setVoicesStatus("3");
|
||||
}
|
||||
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));
|
||||
//上传 multipartFile 文件到阿里云OSS上
|
||||
String path = ossService.uploadFileAvatar(multipartFile);
|
||||
|
||||
@@ -256,7 +235,7 @@ public class BookChapterContentController {
|
||||
file.delete();
|
||||
|
||||
bookChapterService.updateById(bookChapter);
|
||||
if (StringUtils.isEmpty(path)){
|
||||
if (StringUtils.isEmpty(path)) {
|
||||
bookEntity.setVoicesStatus("3");
|
||||
}
|
||||
}
|
||||
@@ -271,14 +250,15 @@ public class BookChapterContentController {
|
||||
|
||||
/**
|
||||
* 鉴权获取章节
|
||||
*
|
||||
* @param bookid
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getBooksCatal")
|
||||
public R getBooksCatal(@RequestParam("id") Integer id,
|
||||
@RequestParam("bookid") Integer bookid,
|
||||
@RequestParam("userId") Integer userId) {
|
||||
@RequestParam("bookid") Integer bookid,
|
||||
@RequestParam("userId") Integer userId) {
|
||||
// TODO 验证 当前请求的书 是否存在免费章节数
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
|
||||
Integer freeChapterCount = bookEntity.getFreeChapterCount();
|
||||
@@ -294,7 +274,7 @@ public class BookChapterContentController {
|
||||
String vip = user.getVip();
|
||||
if (!"1".equals(vip)) {
|
||||
|
||||
return R.error("当前为VIP");
|
||||
return R.error("当前为VIP");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -308,14 +288,14 @@ public class BookChapterContentController {
|
||||
return R.error(500, "请购买书籍!");
|
||||
}
|
||||
}
|
||||
if(isVip == 3){
|
||||
boolean b = myUserService.bookAuthenticate(bookid,userId);
|
||||
if (!b){
|
||||
if (isVip == 3) {
|
||||
boolean b = myUserService.bookAuthenticate(bookid, userId);
|
||||
if (!b) {
|
||||
|
||||
List<BookChapterEntity> book = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
|
||||
.eq("book_id", bookid));
|
||||
ArrayList<Object> chapterList = new ArrayList<>();
|
||||
int chapterIndex=0;
|
||||
int chapterIndex = 0;
|
||||
for (BookChapterEntity chapter : book) {
|
||||
if (chapterIndex >= freeChapterCount) {
|
||||
break; // 取出前freeChapterCount条记录后,退出循环
|
||||
@@ -330,19 +310,18 @@ public class BookChapterContentController {
|
||||
chapterIndex++;
|
||||
|
||||
}
|
||||
return R.ok("当前为试听章节:"+chapterList).put("bookCatalogue", chapterList).put("image", bookEntity.getImages()).put("chapterIndex",chapterIndex);
|
||||
return R.ok("当前为试听章节:" + chapterList).put("bookCatalogue", chapterList).put("image", bookEntity.getImages()).put("chapterIndex", chapterIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<BookChapterEntity> book = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
|
||||
.eq("book_id", bookid));
|
||||
ArrayList<Object> chapterList = new ArrayList<>();
|
||||
for (BookChapterEntity chapter : book) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name",chapter.getChapter());
|
||||
map.put("url",chapter.getVoices());
|
||||
map.put("name", chapter.getChapter());
|
||||
map.put("url", chapter.getVoices());
|
||||
chapterList.add(map);
|
||||
}
|
||||
return R.ok().put("bookCatalogue", chapterList).put("image", bookEntity.getImages());
|
||||
@@ -351,128 +330,114 @@ public class BookChapterContentController {
|
||||
|
||||
/**
|
||||
* 获取章节音频地址
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getBooksCatalogue")
|
||||
public R getBooksCatalogue(@RequestParam Integer chapterId,
|
||||
@RequestParam Integer bookId,
|
||||
@RequestParam Integer userId){
|
||||
@RequestParam Integer userId) {
|
||||
//鉴权阶段
|
||||
BookEntity book_info = bookService.getById(bookId);
|
||||
BookChapterEntity chapter_info = bookChapterService.getById(chapterId);
|
||||
|
||||
UserEbookBuyEntity userEbookBuyEntity = userEbookBuyService.getBaseMapper().selectOne(new LambdaQueryWrapper<UserEbookBuyEntity>().
|
||||
eq(UserEbookBuyEntity::getUserId,userId).eq(UserEbookBuyEntity::getBookId,bookId));
|
||||
if(chapter_info.getNumber()>book_info.getFreeChapterCount()&&userEbookBuyEntity==null){
|
||||
Integer productByBookId = shopProudictBookService.getProductByBookId(bookId);
|
||||
return R.ok().put("jq",false).put("product",productByBookId);
|
||||
eq(UserEbookBuyEntity::getUserId, userId).eq(UserEbookBuyEntity::getBookId, bookId));
|
||||
if (chapter_info.getNumber() > book_info.getFreeChapterCount() && userEbookBuyEntity == null) {
|
||||
Integer productByBookId = shopProductBookService.getProductByBookId(bookId);
|
||||
return R.ok().put("jq", false).put("product", productByBookId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return R.ok().put("chapter",chapter_info);
|
||||
return R.ok().put("chapter", chapter_info);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* app 获取电子书章节内容 2.0 (在用鉴权)
|
||||
*/
|
||||
@RequestMapping("/appBooksChapterContent1")
|
||||
public R getBooksCatalogue1(@RequestParam("chapterid") Integer id,
|
||||
@RequestParam("bookid") Integer bookid,
|
||||
@RequestParam("userId") Integer userId) {
|
||||
// TODO 验证 当前请求的书 是否存在免费章节数
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
|
||||
Integer freeChapterCount = bookEntity.getFreeChapterCount();
|
||||
/**
|
||||
* app 获取电子书章节内容 2.0 (在用鉴权)
|
||||
*/
|
||||
@RequestMapping("/appBooksChapterContent1")
|
||||
public R getBooksCatalogue1(@RequestParam("chapterid") Integer id,
|
||||
@RequestParam("bookid") Integer bookid,
|
||||
@RequestParam("userId") Integer userId) {
|
||||
// TODO 验证 当前请求的书 是否存在免费章节数
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
|
||||
Integer freeChapterCount = bookEntity.getFreeChapterCount();
|
||||
|
||||
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(id);
|
||||
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(id);
|
||||
|
||||
Integer number = bookChapterEntity.getNumber();
|
||||
Integer number = bookChapterEntity.getNumber();
|
||||
|
||||
//TODO 0-免费 1-会免(改为电子书听书) 2-付费 // 阅读章节数 大于 免费章节数
|
||||
Integer isVip = bookEntity.getIsVip();
|
||||
Boolean canListen = bookEntity.getCanListen();
|
||||
//TODO 0-免费 1-会免(改为电子书听书) 2-付费 // 阅读章节数 大于 免费章节数
|
||||
Integer isVip = bookEntity.getIsVip();
|
||||
Boolean canListen = bookEntity.getCanListen();
|
||||
|
||||
//todo 暂未开通听书功能
|
||||
//todo 暂未开通听书功能
|
||||
// if (canListen==false) {
|
||||
// return R.error1("暂未开通听书功能");
|
||||
// }
|
||||
|
||||
if ((number > freeChapterCount) || freeChapterCount == 0) {
|
||||
// 书籍为 会免
|
||||
if ((number > freeChapterCount) || freeChapterCount == 0) {
|
||||
// 书籍为 会免
|
||||
|
||||
if (isVip == 1) {
|
||||
//查询用户身份
|
||||
MyUserEntity user = myUserService.getById(userId);
|
||||
String vip = user.getVip();
|
||||
if (!"1".equals(vip)) {
|
||||
if (isVip == 1) {
|
||||
//查询用户身份
|
||||
MyUserEntity user = myUserService.getById(userId);
|
||||
String vip = user.getVip();
|
||||
if (!"1".equals(vip)) {
|
||||
|
||||
return R.error("当前为VIP");
|
||||
return R.error("当前为VIP");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(canListen == true){
|
||||
boolean b = myUserService.bookAuthenticate(bookid,userId);
|
||||
if (!b) {
|
||||
if (canListen == true) {
|
||||
boolean b = myUserService.bookAuthenticate(bookid, userId);
|
||||
if (!b) {
|
||||
|
||||
return R.error("未购买书籍!");
|
||||
return R.error("未购买书籍!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (isVip == 2) {
|
||||
if (isVip == 2) {
|
||||
// 鉴权 查询权限表中 用户是否开通
|
||||
boolean b = myUserService.bookAuthenticate(bookid, userId);
|
||||
|
||||
if (!b) {
|
||||
return R.error(500, "请购买书籍!").put("code",500);
|
||||
return R.error(500, "请购买书籍!").put("code", 500);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ArrayList<Object> chapterList = new ArrayList<>();
|
||||
|
||||
ArrayList<Object> chapterList = new ArrayList<>();
|
||||
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name",bookChapterEntity.getChapter());
|
||||
map.put("url",bookChapterEntity.getVoices());
|
||||
map.put("bookid",bookChapterEntity.getBookId());
|
||||
map.put("chapterid",bookChapterEntity.getId());
|
||||
map.put("name", bookChapterEntity.getChapter());
|
||||
map.put("url", bookChapterEntity.getVoices());
|
||||
map.put("bookid", bookChapterEntity.getBookId());
|
||||
map.put("chapterid", bookChapterEntity.getId());
|
||||
//todo sort先注释调
|
||||
// map.put("sort",bookChapterEntity.getSort());
|
||||
chapterList.add(map);
|
||||
|
||||
return R.ok().put("bookCatalogue", chapterList).put("image", bookEntity.getImages());
|
||||
return R.ok().put("bookCatalogue", chapterList).put("image", bookEntity.getImages());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* app 获取电子书章节内容
|
||||
*/
|
||||
@RequestMapping("/appGetBookChapterContent")
|
||||
public R getBookCatalogue(@RequestParam("chapterid") Integer chapterid,
|
||||
@RequestParam("bookid") Integer bookid,
|
||||
@RequestParam("userId") Integer userId){
|
||||
@RequestParam("userId") Integer userId) {
|
||||
|
||||
// TODO 验证 当前请求的书 是否存在免费章节数
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
|
||||
@@ -481,57 +446,56 @@ public R getBooksCatalogue1(@RequestParam("chapterid") Integer id,
|
||||
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(chapterid);
|
||||
Integer number = bookChapterEntity.getNumber();
|
||||
// 阅读章节数 大于 免费章节数
|
||||
if ((number > freeChapterCount) || freeChapterCount ==0){
|
||||
if ((number > freeChapterCount) || freeChapterCount == 0) {
|
||||
if (isVip == 1) {
|
||||
MyUserEntity user = myUserService.getById(userId);
|
||||
String vip = user.getVip();
|
||||
if (!"1".equals(vip)) {
|
||||
return R.error(500,"当前书籍为会员书籍,请开通会员或购买!");
|
||||
return R.error(500, "当前书籍为会员书籍,请开通会员或购买!");
|
||||
}
|
||||
|
||||
}
|
||||
if (isVip == 2) {
|
||||
boolean b = myUserService.bookAuthenticate(bookid, userId);
|
||||
if (!b) {
|
||||
return R.error(500,"请购买此书籍!");
|
||||
return R.error(500, "请购买此书籍!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
List<BookChapterContentEntity> bookChapterContentEntities = bookChapterContentService.getBaseMapper().selectList(new QueryWrapper<BookChapterContentEntity>()
|
||||
.eq("book_id",bookid)
|
||||
.eq("book_chatper_id",chapterid));
|
||||
.eq("book_id", bookid)
|
||||
.eq("book_chatper_id", chapterid));
|
||||
for (BookChapterContentEntity bookChapterContentEntity : bookChapterContentEntities) {
|
||||
|
||||
String content = bookChapterContentEntity.getContent();
|
||||
|
||||
String substring = "";
|
||||
if (bookChapterContentEntity.getOtherContent() != null){
|
||||
substring = bookChapterContentEntity.getOtherContent().replace("<p>","").replace("</p>","");
|
||||
if (bookChapterContentEntity.getOtherContent() != null) {
|
||||
substring = bookChapterContentEntity.getOtherContent().replace("<p>", "").replace("</p>", "");
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer(substring);
|
||||
if(stringBuffer.indexOf("title") != -1){
|
||||
stringBuffer.insert(stringBuffer.indexOf("title"),"width=\"100%\"");
|
||||
if (stringBuffer.indexOf("title") != -1) {
|
||||
stringBuffer.insert(stringBuffer.indexOf("title"), "width=\"100%\"");
|
||||
}
|
||||
if (bookChapterContentEntity.getNumber() == 1){
|
||||
if (bookChapterContentEntity.getNumber() == 1) {
|
||||
Integer bookChatperId = bookChapterContentEntity.getBookChatperId();
|
||||
BookChapterEntity chapterEntity = bookChapterService.getById(bookChatperId);
|
||||
String chapter = chapterEntity.getChapter();
|
||||
content = bookChapterContentEntity.getContent().replace(chapter, "");
|
||||
}
|
||||
bookChapterContentEntity.setPicAndWord(content.replaceAll(" ","") + stringBuffer);
|
||||
bookChapterContentEntity.setPicAndWord(content.replaceAll(" ", "") + stringBuffer);
|
||||
list.add(bookChapterContentEntity);
|
||||
}
|
||||
|
||||
return R.ok().put("bookCatalogue",list);
|
||||
return R.ok().put("bookCatalogue", list);
|
||||
}
|
||||
|
||||
//生成电子书 目录
|
||||
@RequestMapping("/getWordChapterParagraph")
|
||||
public R getWordChapterParagraph(@RequestParam Map<String, Object> params){
|
||||
public R getWordChapterParagraph(@RequestParam Map<String, Object> params) {
|
||||
bookChapterContentService.getWordChapterParagraph(14);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -7,13 +7,11 @@ import java.util.stream.Collectors;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.ReadProvinceUtil;
|
||||
import com.peanut.modules.book.dao.BookDao;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.BookIndexVo;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -58,7 +56,7 @@ public class BookController {
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
private ShopProudictBookService shopProudictBookService;
|
||||
private ShopProductBookService shopProductBookService;
|
||||
@Autowired
|
||||
private ShopProductToLabelService shopProductToLabelService;
|
||||
final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
|
||||
@@ -123,7 +121,7 @@ public class BookController {
|
||||
BookEntity book_info = bookService.getById(bookId);
|
||||
book_info.setAuthor(authorService.getById(book_info.getAuthorId()));
|
||||
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<>();
|
||||
wrapper.eq(UserEbookBuyEntity::getUserId,userId);
|
||||
@@ -715,7 +713,7 @@ public class BookController {
|
||||
}
|
||||
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper1);
|
||||
for (BookEntity b : bookEntityPage.getRecords()){
|
||||
b.setProductId(shopProudictBookService.getProductByBookId(b.getId()));
|
||||
b.setProductId(shopProductBookService.getProductByBookId(b.getId()));
|
||||
}
|
||||
|
||||
return R.ok().put("page",bookEntityPage);
|
||||
|
||||
@@ -7,16 +7,13 @@ import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.BookTeachEntity;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
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.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("book/teach")
|
||||
public class BookTeachController {
|
||||
@@ -25,123 +22,82 @@ public class BookTeachController {
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private ShopProudictBookService shopProudictBookService;
|
||||
private ShopProductBookService shopProductBookService;
|
||||
|
||||
/**
|
||||
* 获取讲书列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getTeachBooks")
|
||||
public R getTeachBooks(@RequestParam Integer limit,@RequestParam Integer page){
|
||||
public R getTeachBooks(@RequestParam Integer limit, @RequestParam Integer page) {
|
||||
LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BookEntity::getDelFlag,0);
|
||||
wrapper.eq(BookEntity::getTeachIn,1);
|
||||
wrapper.eq(BookEntity::getDelFlag, 0);
|
||||
wrapper.eq(BookEntity::getTeachIn, 1);
|
||||
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<BookEntity>(page, limit), wrapper);
|
||||
|
||||
return R.ok().put("page",bookEntityPage);
|
||||
return R.ok().put("page", bookEntityPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取讲书目录
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getBookTeachItems")
|
||||
public R getBookTeachItems(@RequestParam Integer bookId,@RequestParam Integer limit,@RequestParam Integer page){
|
||||
public R getBookTeachItems(@RequestParam Integer bookId, @RequestParam Integer limit, @RequestParam Integer page) {
|
||||
LambdaQueryWrapper<BookTeachEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BookTeachEntity::getBookId,bookId);
|
||||
wrapper.eq(BookTeachEntity::getDelFlag,0);
|
||||
wrapper.eq(BookTeachEntity::getBookId, bookId);
|
||||
wrapper.eq(BookTeachEntity::getDelFlag, 0);
|
||||
wrapper.orderByAsc(BookTeachEntity::getChapter);
|
||||
Page<BookTeachEntity> bookTeachEntityPage = bookTeachService.getBaseMapper().selectPage(new Page<BookTeachEntity>(page, limit), wrapper);
|
||||
return R.ok().put("page",bookTeachEntityPage);
|
||||
return R.ok().put("page", bookTeachEntityPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取讲书的详情
|
||||
*
|
||||
* @param teachId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getTeachDetail")
|
||||
public R getTeachDetail(@RequestParam Integer teachId){
|
||||
public R getTeachDetail(@RequestParam Integer teachId) {
|
||||
BookTeachEntity teach_info = bookTeachService.getById(teachId);
|
||||
Integer productByBookId = shopProudictBookService.getProductByBookId(teach_info.getBookId());
|
||||
return R.ok().put("bookTeach",teach_info).put("product",productByBookId);
|
||||
Integer productByBookId = shopProductBookService.getProductByBookId(teach_info.getBookId());
|
||||
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
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/addTeach1")
|
||||
public R addTeach1(@RequestBody BookTeachEntity bookTeach){
|
||||
public R addTeach1(@RequestBody BookTeachEntity bookTeach) {
|
||||
bookTeachService.save(bookTeach);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除讲书章节
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/delTeach")
|
||||
public R delTeach(@RequestBody BookTeachEntity bookTeach){
|
||||
public R delTeach(@RequestBody BookTeachEntity bookTeach) {
|
||||
bookTeachService.removeById(bookTeach.getTeachId());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑讲书的章节
|
||||
* @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
|
||||
*/
|
||||
@RequestMapping("/updateTeach")
|
||||
public R updateTeach(@RequestBody BookTeachEntity bookTeach){
|
||||
public R updateTeach(@RequestBody BookTeachEntity bookTeach) {
|
||||
bookTeachService.updateById(bookTeach);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class BuyOrderController {
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Autowired
|
||||
private ShopProudictBookService shopProudictBookService;
|
||||
private ShopProductBookService shopProductBookService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
@@ -523,9 +523,9 @@ public class BuyOrderController {
|
||||
private void addEbookToUser(List<BuyOrderDetailEntity> products, BuyOrderEntity buyOrder) {
|
||||
List<Integer> productIds = products.stream().map(BuyOrderDetailEntity::getProductId).collect(Collectors.toList());
|
||||
for (Integer productId : productIds) {
|
||||
List<Integer> collect = shopProudictBookService.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProudictBookEntity>()
|
||||
.eq(ShopProudictBookEntity::getProudictId, productId)
|
||||
.eq(ShopProudictBookEntity::getDelFlag, 0)).stream().map(ShopProudictBookEntity::getBookId).collect(Collectors.toList());
|
||||
List<Integer> collect = shopProductBookService.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProductBookEntity>()
|
||||
.eq(ShopProductBookEntity::getProductId, productId)
|
||||
.eq(ShopProductBookEntity::getDelFlag, 0)).stream().map(ShopProductBookEntity::getBookId).collect(Collectors.toList());
|
||||
userEbookBuyService.addBookForUser(buyOrder.getUserId(), collect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
@@ -15,7 +17,6 @@ import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商品表
|
||||
*
|
||||
@@ -35,27 +36,25 @@ public class ShopProductController {
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private ShopProudictBookService shopProudictBookService;
|
||||
private ShopProductBookService shopProductBookService;
|
||||
@Autowired
|
||||
private ShopProductToLabelService shopProductToLabelService;
|
||||
@Autowired
|
||||
private ShopProductLabelService shopProductLabelService;
|
||||
|
||||
/**
|
||||
* 精选商品 列表
|
||||
* 精选商品 列表
|
||||
*/
|
||||
@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);
|
||||
return R.ok().put("page", page);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 折扣商品
|
||||
*/
|
||||
@RequestMapping("/listactivityprice")
|
||||
public R listactivityprice(@RequestParam Map<String, Object> params){
|
||||
public R listActivityPrice(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = shopProductService.queryPageactivityprice(params);
|
||||
return R.ok().put("page", page);
|
||||
|
||||
@@ -65,18 +64,17 @@ public class ShopProductController {
|
||||
* 列表
|
||||
*/
|
||||
@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);
|
||||
return R.ok().put("page", page);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
@RequestMapping("/selectList")
|
||||
public R selectList(@RequestParam Map<String, Object> params){
|
||||
public R selectList(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = shopProductService.selectListqueryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
@@ -90,19 +88,15 @@ public class ShopProductController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 未购买书列表
|
||||
* @param userId 用户id
|
||||
* 未购买书列表
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return
|
||||
*/
|
||||
@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>()
|
||||
.eq("user_id", userId));
|
||||
@@ -118,17 +112,17 @@ public class ShopProductController {
|
||||
}
|
||||
//查询商品表并过滤已购买商品id,根据时间倒叙展示
|
||||
List<ShopProductEntity> allProductEntities = shopProductService.getBaseMapper().selectList(new QueryWrapper<ShopProductEntity>()
|
||||
.notIn("product_id", purchasedProductIds)
|
||||
.orderByDesc("create_time")
|
||||
.notIn("product_id", purchasedProductIds)
|
||||
.orderByDesc("create_time")
|
||||
// .notLike("book_ids",",")
|
||||
.isNotNull("book_ids")
|
||||
.isNotNull("book_ids")
|
||||
|
||||
);
|
||||
List lists = new ArrayList<>();
|
||||
|
||||
for (ShopProductEntity product : allProductEntities) {
|
||||
Map<String, Object> productMap = new HashMap<>();
|
||||
productMap.put("product",product);
|
||||
productMap.put("product", product);
|
||||
lists.add(productMap);
|
||||
}
|
||||
|
||||
@@ -137,20 +131,17 @@ public class ShopProductController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping("/bookinfo/{productId}")
|
||||
public R bookinfo(@PathVariable("productId") Integer productId){
|
||||
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String,String>>();
|
||||
List<ShopProudictBookEntity> bookEntityList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>().eq("book_id", productId));
|
||||
public R bookInfo(@PathVariable("productId") Integer productId) {
|
||||
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String, String>>();
|
||||
List<ShopProductBookEntity> bookEntityList = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>().eq("book_id", productId));
|
||||
List<Object> list = new ArrayList<>();
|
||||
ArrayList<String> booklist = new ArrayList<>();
|
||||
ShopProductEntity shopProductEntity=null;
|
||||
for (ShopProudictBookEntity shopProudictBookEntity : bookEntityList) {
|
||||
Integer proudictId = shopProudictBookEntity.getProudictId();
|
||||
ShopProductEntity shopProductEntity = null;
|
||||
for (ShopProductBookEntity shopProductBookEntity : bookEntityList) {
|
||||
Integer proudictId = shopProductBookEntity.getProductId();
|
||||
shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", proudictId));
|
||||
Integer bookId = shopProudictBookEntity.getBookId();
|
||||
Integer bookId = shopProductBookEntity.getBookId();
|
||||
BookEntity byId = bookService.getById(bookId);
|
||||
booklist.add(String.valueOf(bookId));
|
||||
list.add(byId);
|
||||
@@ -163,8 +154,6 @@ public class ShopProductController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping("/bookinfolists/{productId}")
|
||||
public R bookinfolists(@PathVariable("productId") Integer productId) {
|
||||
//查询商品
|
||||
@@ -176,31 +165,31 @@ public class ShopProductController {
|
||||
Integer productId1 = shopProductEntity.getProductId();
|
||||
//分类信息
|
||||
List<Integer> poids = shopCategoryService.findPoid(poid);
|
||||
List<ShopProudictBookEntity> proudict = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
|
||||
.eq("proudict_id", productId1));
|
||||
List<ShopProductBookEntity> product = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
|
||||
.eq("product_id", productId1));
|
||||
List<ShopProductEntity> result = new ArrayList<>();
|
||||
//获取商品id
|
||||
Set<Integer> productIds = new HashSet<>();
|
||||
productIds.add(productId);
|
||||
for (ShopProudictBookEntity shopProudictBookEntity : proudict) {
|
||||
Integer bookId = shopProudictBookEntity.getBookId();
|
||||
for (ShopProductBookEntity shopProductBookEntity : product) {
|
||||
Integer bookId = shopProductBookEntity.getBookId();
|
||||
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));
|
||||
for(ShopProudictBookEntity entity : entityByBookId){
|
||||
productIds.add(entity.getProudictId());
|
||||
for (ShopProductBookEntity entity : entityByBookId) {
|
||||
productIds.add(entity.getProductId());
|
||||
}
|
||||
}
|
||||
for(Integer pId : productIds){
|
||||
ShopProductEntity proEntity =null;
|
||||
for (Integer pId : productIds) {
|
||||
ShopProductEntity proEntity = null;
|
||||
proEntity = shopProductService.getById(pId);
|
||||
List<ShopProudictBookEntity> pbookEntitys = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
|
||||
.eq("proudict_id", pId));
|
||||
List<ShopProductBookEntity> pbookEntitys = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
|
||||
.eq("product_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());
|
||||
for (ShopProductBookEntity shopProductBookEntity : pbookEntitys) {
|
||||
booklist.add(String.valueOf(shopProductBookEntity.getBookId()));
|
||||
BookEntity byId = bookService.getById(shopProductBookEntity.getBookId());
|
||||
list.add(byId);
|
||||
}
|
||||
proEntity.setPoids(poids);
|
||||
@@ -214,6 +203,7 @@ public class ShopProductController {
|
||||
|
||||
/**
|
||||
* 获取关联订单列表
|
||||
*
|
||||
* @param productId
|
||||
* @return
|
||||
*/
|
||||
@@ -221,45 +211,46 @@ public class ShopProductController {
|
||||
public R getGlProductList(@RequestParam int productId) {
|
||||
|
||||
//获取此商品下的books
|
||||
List<Integer> ids = shopProudictBookService.getBookidsByProductId(productId);
|
||||
List<Integer> ids = shopProductBookService.getBookIdsByProductId(productId);
|
||||
|
||||
if(ids.size()==0){
|
||||
if (ids.size() == 0) {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
List<ShopProudictBookEntity> ss = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
|
||||
.eq("del_flag",0)
|
||||
.in("book_id",ids)
|
||||
.groupBy("proudict_id")
|
||||
.having("count(proudict_id) >="+ids.size())
|
||||
List<ShopProductBookEntity> ss = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
|
||||
.eq("del_flag", 0)
|
||||
.in("book_id", ids)
|
||||
.groupBy("product_id")
|
||||
.having("count(product_id) >=" + ids.size())
|
||||
);
|
||||
|
||||
List<ShopProductEntity> frag = new ArrayList<>();
|
||||
//如果绑定的书为空,直接返回空值
|
||||
if(ids.size()==0){
|
||||
if (ids.size() == 0) {
|
||||
return R.ok();
|
||||
}
|
||||
for (ShopProudictBookEntity spbe : ss){
|
||||
ShopProductEntity ca_sp = shopProductService.getById(spbe.getProudictId());
|
||||
for (ShopProductBookEntity spbe : ss) {
|
||||
ShopProductEntity ca_sp = shopProductService.getById(spbe.getProductId());
|
||||
frag.add(ca_sp);
|
||||
}
|
||||
|
||||
return R.ok().put("result",frag);
|
||||
return R.ok().put("result", frag);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param productId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/info/{productId}")
|
||||
public R info(@PathVariable("productId") Integer productId){
|
||||
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", productId).eq("del_flag",0));
|
||||
if (shopProductEntity == null) {
|
||||
return R.error("该商品已下架,看看其他商品吧");
|
||||
}
|
||||
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String,String>>();
|
||||
public R info(@PathVariable("productId") Integer productId) {
|
||||
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", productId).eq("del_flag", 0));
|
||||
if (shopProductEntity == null) {
|
||||
return R.error("该商品已下架,看看其他商品吧");
|
||||
}
|
||||
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String, String>>();
|
||||
|
||||
Integer poid = shopProductEntity.getProductPid();
|
||||
Integer productId1 = shopProductEntity.getProductId();
|
||||
@@ -268,11 +259,11 @@ public class ShopProductController {
|
||||
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();
|
||||
List<ShopProductBookEntity> product = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
|
||||
.eq("product_id", productId1));
|
||||
for (ShopProductBookEntity shopProductBookEntity : product) {
|
||||
Integer id = shopProductBookEntity.getId();
|
||||
Integer bookId = shopProductBookEntity.getBookId();
|
||||
|
||||
BookEntity byId = bookService.getById(bookId);
|
||||
bookIdlist.add(id);
|
||||
@@ -282,9 +273,9 @@ public class ShopProductController {
|
||||
|
||||
//添加获取标签逻辑
|
||||
List<ShopProductToLabelEntity> shopProductToLabelEntities = shopProductToLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductToLabelEntity>()
|
||||
.eq("product_id",productId).eq("del_flag",0));
|
||||
.eq("product_id", productId).eq("del_flag", 0));
|
||||
List labelList = new ArrayList();
|
||||
for (ShopProductToLabelEntity sp : shopProductToLabelEntities){
|
||||
for (ShopProductToLabelEntity sp : shopProductToLabelEntities) {
|
||||
labelList.add(sp.getSplId());
|
||||
}
|
||||
|
||||
@@ -292,32 +283,31 @@ public class ShopProductController {
|
||||
shopProductEntity.setBookidsimages(list);
|
||||
shopProductEntity.setBookids(booklist);
|
||||
shopProductEntity.setShoproudIds(bookIdlist);
|
||||
return R.ok().put("shopProduct", shopProductEntity).put("labels",labelList);
|
||||
return R.ok().put("shopProduct", shopProductEntity).put("labels", labelList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据传入商品id反向查询图书id,然后查询图书id下包含的商品
|
||||
* 根据传入商品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<ShopProductBookEntity> proudict = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
|
||||
.eq("product_id", productId));
|
||||
List<Object> list = new ArrayList<>();
|
||||
for (ShopProudictBookEntity shopProudictBookEntity : proudict) {
|
||||
Integer bookId = shopProudictBookEntity.getBookId();
|
||||
for (ShopProductBookEntity shopProductBookEntity : proudict) {
|
||||
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));
|
||||
|
||||
for (ShopProudictBookEntity shopProudict : bookIds) {
|
||||
Integer proudictId = shopProudict.getProudictId();
|
||||
for (ShopProductBookEntity shopProduct : bookIds) {
|
||||
Integer shopProductId = shopProduct.getProductId();
|
||||
List<ShopProductEntity> shopProductEntities = shopProductService.getBaseMapper().selectList(new QueryWrapper<ShopProductEntity>()
|
||||
.eq("proudict_id",proudictId));
|
||||
.eq("product_id", shopProductId));
|
||||
list.add(shopProductEntities);
|
||||
}
|
||||
}
|
||||
@@ -334,147 +324,138 @@ public class ShopProductController {
|
||||
shopProduct.setCreateTime(new Date());
|
||||
|
||||
String bkids = "";
|
||||
for(String s : shopProduct.getBookids()){
|
||||
bkids += s+",";
|
||||
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("");
|
||||
}
|
||||
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();
|
||||
ShopProductBookEntity shopProductBookEntity = new ShopProductBookEntity();
|
||||
for (String s : shopProduct.getBookids()) {
|
||||
String bookidlist = s;
|
||||
if (bookidlist != null) {
|
||||
Integer proudict = shopProduct.getProductId();
|
||||
shopProudictBookEntity.setProudictId(proudict);
|
||||
shopProudictBookEntity.setBookId(Integer.valueOf(bookidlist));
|
||||
shopProudictBookService.save(shopProudictBookEntity);
|
||||
shopProductBookEntity.setProductId(proudict);
|
||||
shopProductBookEntity.setBookId(Integer.valueOf(bookidlist));
|
||||
shopProductBookService.save(shopProductBookEntity);
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody ShopProductEntity shopProduct) {
|
||||
|
||||
//商品id
|
||||
Integer productId = shopProduct.getProductId();
|
||||
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("");
|
||||
}
|
||||
//传过来的proudictid只有一个,但是bookid可能有多个,对应的一个proudictid一个bookid为一条数据,一对多存储
|
||||
List<ShopProudictBookEntity> bookyList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
|
||||
.eq("proudict_id", productId));
|
||||
Integer shop_book_ids [] = new Integer[bookyList.size()];
|
||||
for(int i=0; i<bookyList.size(); i++){
|
||||
shop_book_ids[i] = bookyList.get(i).getId();
|
||||
}
|
||||
if(null != shop_book_ids && shop_book_ids.length > 0){
|
||||
shopProudictBookService.getBaseMapper().deleteBatchIds(Arrays.asList(shop_book_ids));
|
||||
}
|
||||
|
||||
ShopProudictBookEntity shopProudictBookEntity = new ShopProudictBookEntity();
|
||||
for (String s : shopProduct.getBookids()) {
|
||||
String bookidlist = s;
|
||||
if (bookidlist != null) {
|
||||
Integer proudict = shopProduct.getProductId();
|
||||
shopProudictBookEntity.setProudictId(proudict);
|
||||
shopProudictBookEntity.setBookId(Integer.valueOf(bookidlist));
|
||||
shopProudictBookService.save(shopProudictBookEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//对于标签的增和删
|
||||
List<ShopProductToLabelEntity> shopProductToLabelEntities_now = shopProductToLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductToLabelEntity>()
|
||||
.eq("product_id", productId));
|
||||
List<String> m_spl_ids = shopProduct.getShoproudLabels();
|
||||
//删除
|
||||
for (ShopProductToLabelEntity sn:shopProductToLabelEntities_now){
|
||||
if(!m_spl_ids.contains(sn.getSplId())){
|
||||
shopProductToLabelService.removeById(sn.getPtlId());
|
||||
}
|
||||
}
|
||||
//添加
|
||||
for (String m:m_spl_ids){
|
||||
Integer spl_id = Integer.valueOf(m);
|
||||
ShopProductToLabelEntity byId = shopProductToLabelService.getBaseMapper().selectOne(new QueryWrapper<ShopProductToLabelEntity>()
|
||||
.eq("spl_id",spl_id).eq("product_id",productId));
|
||||
if(byId==null){
|
||||
ShopProductToLabelEntity shopProductToLabelEntity = new ShopProductToLabelEntity();
|
||||
shopProductToLabelEntity.setProductId(productId);
|
||||
shopProductToLabelEntity.setSplId(spl_id);
|
||||
shopProductToLabelService.save(shopProductToLabelEntity);
|
||||
}
|
||||
}
|
||||
|
||||
shopProductService.updateById(shopProduct);
|
||||
return R.ok();
|
||||
//商品id
|
||||
Integer productId = shopProduct.getProductId();
|
||||
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("");
|
||||
}
|
||||
//传过来的proudictid只有一个,但是bookid可能有多个,对应的一个proudictid一个bookid为一条数据,一对多存储
|
||||
List<ShopProductBookEntity> bookyList = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
|
||||
.eq("product_id", productId));
|
||||
Integer shop_book_ids[] = new Integer[bookyList.size()];
|
||||
for (int i = 0; i < bookyList.size(); i++) {
|
||||
shop_book_ids[i] = bookyList.get(i).getId();
|
||||
}
|
||||
if (null != shop_book_ids && shop_book_ids.length > 0) {
|
||||
shopProductBookService.getBaseMapper().deleteBatchIds(Arrays.asList(shop_book_ids));
|
||||
}
|
||||
|
||||
ShopProductBookEntity shopProductBookEntity = new ShopProductBookEntity();
|
||||
for (String s : shopProduct.getBookids()) {
|
||||
String bookidlist = s;
|
||||
if (bookidlist != null) {
|
||||
Integer proudict = shopProduct.getProductId();
|
||||
shopProductBookEntity.setProductId(proudict);
|
||||
shopProductBookEntity.setBookId(Integer.valueOf(bookidlist));
|
||||
shopProductBookService.save(shopProductBookEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//对于标签的增和删
|
||||
List<ShopProductToLabelEntity> shopProductToLabelEntities_now = shopProductToLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductToLabelEntity>()
|
||||
.eq("product_id", productId));
|
||||
List<String> m_spl_ids = shopProduct.getShoproudLabels();
|
||||
//删除
|
||||
for (ShopProductToLabelEntity sn : shopProductToLabelEntities_now) {
|
||||
if (!m_spl_ids.contains(sn.getSplId())) {
|
||||
shopProductToLabelService.removeById(sn.getPtlId());
|
||||
}
|
||||
}
|
||||
//添加
|
||||
for (String m : m_spl_ids) {
|
||||
Integer spl_id = Integer.valueOf(m);
|
||||
ShopProductToLabelEntity byId = shopProductToLabelService.getBaseMapper().selectOne(new QueryWrapper<ShopProductToLabelEntity>()
|
||||
.eq("spl_id", spl_id).eq("product_id", productId));
|
||||
if (byId == null) {
|
||||
ShopProductToLabelEntity shopProductToLabelEntity = new ShopProductToLabelEntity();
|
||||
shopProductToLabelEntity.setProductId(productId);
|
||||
shopProductToLabelEntity.setSplId(spl_id);
|
||||
shopProductToLabelService.save(shopProductToLabelEntity);
|
||||
}
|
||||
}
|
||||
|
||||
shopProductService.updateById(shopProduct);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] productIds){
|
||||
public R delete(@RequestBody Integer[] productIds) {
|
||||
|
||||
List<ShopProudictBookEntity> bookEntityList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
|
||||
.in("proudict_id", productIds)
|
||||
List<ShopProductBookEntity> bookEntityList = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
|
||||
.in("product_id", productIds)
|
||||
);
|
||||
for (ShopProudictBookEntity shopProudictBookEntity : bookEntityList) {
|
||||
Integer id = shopProudictBookEntity.getId();
|
||||
shopProudictBookService.removeById(id);
|
||||
for (ShopProductBookEntity shopProductBookEntity : bookEntityList) {
|
||||
Integer id = shopProductBookEntity.getId();
|
||||
shopProductBookService.removeById(id);
|
||||
}
|
||||
shopProductService.removeByIds(Arrays.asList(productIds));
|
||||
shopProductService.removeByIds(Arrays.asList(productIds));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/appGetList")
|
||||
public R appGetList(@RequestParam Map<String, Object> params){
|
||||
public R appGetList(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = shopProductService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取分类下商品列表
|
||||
*/
|
||||
@RequestMapping("/appGetCategoryList")
|
||||
public R appGetCategoryList(@RequestParam("catId") Integer catId){
|
||||
public R appGetCategoryList(@RequestParam("catId") Integer catId) {
|
||||
List<ShopCategoryEntity> list1 = shopCategoryService.getBaseMapper().selectList(new QueryWrapper<ShopCategoryEntity>()
|
||||
.eq("cat_id",catId));
|
||||
.eq("cat_id", catId));
|
||||
if (catId == null) {
|
||||
}
|
||||
if(catId == 0){
|
||||
if (catId == 0) {
|
||||
catId = null;
|
||||
}
|
||||
List<ShopProductEntity> list = shopProductService.appGetCategoryList(catId);
|
||||
@@ -485,7 +466,7 @@ public class ShopProductController {
|
||||
* 远程搜索
|
||||
*/
|
||||
@RequestMapping("/prodSearch")
|
||||
public R prodSearch(){
|
||||
public R prodSearch() {
|
||||
List<ShopProductEntity> list = shopProductService.list(new QueryWrapper<ShopProductEntity>().select("product_id,product_name"));
|
||||
List<ShopProductVo> collect = list.stream().map(shopProductEntity -> {
|
||||
ShopProductVo shopProductVo = new ShopProductVo();
|
||||
@@ -500,11 +481,10 @@ public class ShopProductController {
|
||||
* 优惠券获取商品信息
|
||||
*/
|
||||
@RequestMapping("/backProdSearch")
|
||||
public R backProdSearch(@RequestParam Map<String, Object> params){
|
||||
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));
|
||||
.like("product_name", productName));
|
||||
return R.ok().put("list", list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.peanut.modules.book.dao;
|
||||
|
||||
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 java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ShopProudictBookDao extends BaseMapper<ShopProudictBookEntity> {
|
||||
public interface ShopProductBookDao extends BaseMapper<ShopProductBookEntity> {
|
||||
|
||||
List<Integer> getOrderBookId(String orderSn);
|
||||
}
|
||||
@@ -1,21 +1,27 @@
|
||||
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 {
|
||||
|
||||
@TableId
|
||||
private Integer id;
|
||||
@Data
|
||||
@TableName("shop_product_book")
|
||||
public class ShopProductBookEntity {
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
* 主键 id
|
||||
*/
|
||||
@TableField("proudict_id")
|
||||
private Integer proudictId;
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
*图书id
|
||||
* 商品id
|
||||
*/
|
||||
@TableField("product_id")
|
||||
private Integer productId;
|
||||
/**
|
||||
* 图书id
|
||||
*/
|
||||
@TableField("book_id")
|
||||
private Integer bookId;
|
||||
@@ -23,18 +29,21 @@ public class ShopProudictBookEntity {
|
||||
* 多个图书id (备用)
|
||||
*/
|
||||
@TableField("book_ids")
|
||||
private Integer bookdIds;
|
||||
|
||||
|
||||
private Integer bookIds;
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
@TableField("del_flag")
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
private Integer delFlag;
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
//
|
||||
@TableField(exist = false)
|
||||
private ArrayList<Integer> bookidlist;
|
||||
/**
|
||||
* 书籍列表
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private ArrayList<Integer> bookIdList;
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -6,14 +6,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
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.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.ShopProductService;
|
||||
import com.peanut.modules.book.service.ShopProudictBookService;
|
||||
import com.peanut.modules.book.vo.ProudictBookqueryVO;
|
||||
import com.peanut.modules.book.service.ShopProductBookService;
|
||||
import com.peanut.modules.book.vo.ProductBookQueryVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -22,50 +22,50 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("shopProudictBookService")
|
||||
public class ShopProudictBookServiceImpl extends ServiceImpl<ShopProudictBookDao, ShopProudictBookEntity> implements ShopProudictBookService {
|
||||
@Service("shopProductBookService")
|
||||
public class ShopProductBookServiceImpl extends ServiceImpl<ShopProductBookDao, ShopProductBookEntity> implements ShopProductBookService {
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private ShopProudictBookDao shopProudictBookDao;
|
||||
private ShopProductBookDao shopProductBookDao;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<ShopProudictBookEntity> page = this.page(
|
||||
new Query<ShopProudictBookEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProudictBookEntity>()
|
||||
IPage<ShopProductBookEntity> page = this.page(
|
||||
new Query<ShopProductBookEntity>().getPage(params),
|
||||
new QueryWrapper<>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils proudictBookqueryPage(Map<String, Object> params) {
|
||||
public PageUtils productBookQueryPage(Map<String, Object> params) {
|
||||
Object proudictId = params.get("proudictId");
|
||||
IPage<ShopProudictBookEntity> page = this.page(
|
||||
new Query<ShopProudictBookEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProudictBookEntity>().eq("proudict_id", proudictId)
|
||||
IPage<ShopProductBookEntity> page = this.page(
|
||||
new Query<ShopProductBookEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProductBookEntity>().eq("product_id", proudictId)
|
||||
);
|
||||
List<ShopProudictBookEntity> records = page.getRecords();
|
||||
List<ShopProductBookEntity> records = page.getRecords();
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@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));
|
||||
List<ShopProudictBookEntity> proudictBooklist = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("proudict_id", proudictId));
|
||||
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", productId));
|
||||
List<ShopProductBookEntity> proudictBooklist = this.list(new QueryWrapper<ShopProductBookEntity>().eq("product_id", productId));
|
||||
List prList = new ArrayList<>();
|
||||
List prLists = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
for (ShopProudictBookEntity shopProudictBookEntity : proudictBooklist) {
|
||||
Integer bookId = shopProudictBookEntity.getBookId();
|
||||
List<ShopProudictBookEntity> booklist = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("book_id", bookId));
|
||||
for (ShopProudictBookEntity shopProudictBook : booklist) {
|
||||
Integer proudictId1 = shopProudictBook.getProudictId();
|
||||
for (ShopProductBookEntity shopProductBookEntity : proudictBooklist) {
|
||||
Integer bookId = shopProductBookEntity.getBookId();
|
||||
List<ShopProductBookEntity> booklist = this.list(new QueryWrapper<ShopProductBookEntity>().eq("book_id", bookId));
|
||||
for (ShopProductBookEntity shopProudictBook : booklist) {
|
||||
Integer proudictId1 = shopProudictBook.getProductId();
|
||||
Integer bookId1 = shopProudictBook.getBookId();
|
||||
BookEntity bookbyId = bookService.getById(bookId1);
|
||||
prList.add(bookbyId);
|
||||
@@ -78,10 +78,10 @@ public class ShopProudictBookServiceImpl extends ServiceImpl<ShopProudictBookDao
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getBookidsByProductId(Integer productId) {
|
||||
List<ShopProudictBookEntity> spbs = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("del_flag", 0).eq("proudict_id", productId));
|
||||
public List<Integer> getBookIdsByProductId(Integer productId) {
|
||||
List<ShopProductBookEntity> spbs = this.list(new QueryWrapper<ShopProductBookEntity>().eq("del_flag", 0).eq("proudict_id", productId));
|
||||
List<Integer> ids = new ArrayList();
|
||||
for (ShopProudictBookEntity s : spbs) {
|
||||
for (ShopProductBookEntity s : spbs) {
|
||||
ids.add(s.getBookId());
|
||||
}
|
||||
return ids;
|
||||
@@ -89,14 +89,14 @@ public class ShopProudictBookServiceImpl extends ServiceImpl<ShopProudictBookDao
|
||||
|
||||
@Override
|
||||
public Integer getProductByBookId(Integer bookId) {
|
||||
LambdaQueryWrapper<ShopProudictBookEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ShopProudictBookEntity::getBookId, bookId);
|
||||
wrapper.eq(ShopProudictBookEntity::getDelFlag, 0);
|
||||
wrapper.groupBy(ShopProudictBookEntity::getProudictId);
|
||||
List<ShopProudictBookEntity> shopProudictBookEntities = this.getBaseMapper().selectList(wrapper);
|
||||
LambdaQueryWrapper<ShopProductBookEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ShopProductBookEntity::getBookId, bookId);
|
||||
wrapper.eq(ShopProductBookEntity::getDelFlag, 0);
|
||||
wrapper.groupBy(ShopProductBookEntity::getProductId);
|
||||
List<ShopProductBookEntity> shopProudictBookEntities = this.getBaseMapper().selectList(wrapper);
|
||||
List ids = new ArrayList();
|
||||
for (ShopProudictBookEntity s : shopProudictBookEntities) {
|
||||
ids.add(s.getProudictId());
|
||||
for (ShopProductBookEntity s : shopProudictBookEntities) {
|
||||
ids.add(s.getProductId());
|
||||
}
|
||||
if (ids.size() == 0) {
|
||||
return null;
|
||||
@@ -114,7 +114,7 @@ public class ShopProudictBookServiceImpl extends ServiceImpl<ShopProudictBookDao
|
||||
|
||||
@Override
|
||||
public List<Integer> getOrderBookId(String orderSn) {
|
||||
return shopProudictBookDao.getOrderBookId(orderSn);
|
||||
return shopProductBookDao.getOrderBookId(orderSn);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class WeChatPayController {
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
|
||||
@Autowired
|
||||
private ShopProudictBookService shopProudictBookService;
|
||||
private ShopProductBookService shopProudictBookService;
|
||||
|
||||
@Autowired
|
||||
private UserEbookBuyService userEbookBuyService;
|
||||
|
||||
Reference in New Issue
Block a user