--图书分类
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BookCategoryEntity;
|
||||
import com.peanut.modules.book.entity.ShopCategoryEntity;
|
||||
import com.peanut.modules.book.service.BookCategoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 图书分类
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/bookCategory")
|
||||
public class BookCategoryController {
|
||||
@Autowired
|
||||
private BookCategoryService bookCategoryService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 分页列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = bookCategoryService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
BookCategoryEntity bookCategoryEntity = bookCategoryService.getById(id);
|
||||
|
||||
return R.ok().put("bookCategoryEntity", bookCategoryEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody BookCategoryEntity bookCategoryEntity){
|
||||
bookCategoryEntity.setDelFlag(0);
|
||||
bookCategoryService.save(bookCategoryEntity);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BookCategoryEntity bookCategoryEntity){
|
||||
bookCategoryService.updateById(bookCategoryEntity);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
bookCategoryService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除前检查
|
||||
*/
|
||||
@RequestMapping("/deleteCheck")
|
||||
public R deleteCheck(@RequestBody String[] oids){
|
||||
bookCategoryService.removeCheckByIds(Arrays.asList(oids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图书 一级分类
|
||||
*/
|
||||
@RequestMapping("/getOneLevel")
|
||||
public R getOneLevel(){
|
||||
List<BookCategoryEntity> list = bookCategoryService.getOneLevel();
|
||||
return R.ok().put("list",list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取图书 二级分类
|
||||
*/
|
||||
@RequestMapping("/getTwoLevel")
|
||||
public R getTwoLevel(){
|
||||
List<BookCategoryEntity> listTree = bookCategoryService.listTree();
|
||||
return R.ok().put("data",listTree);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -63,6 +63,12 @@ public class BookChapterController {
|
||||
return R.ok().put("bookChapter", bookChapter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@@ -71,34 +77,18 @@ public class BookChapterController {
|
||||
BookChapterEntity bookChapterEntity = new BookChapterEntity();
|
||||
Integer number = bookChapter.getNumber();
|
||||
Integer bookId = bookChapter.getBookId();
|
||||
|
||||
if (number == 0) {
|
||||
return R.error("章节号不可为0,请输入正确章节号");
|
||||
}
|
||||
|
||||
List<BookChapterEntity> bookChapterEntities = this.bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
|
||||
.eq("book_id", bookId)
|
||||
.ge("number", number));
|
||||
|
||||
for(BookChapterEntity entity: bookChapterEntities){
|
||||
entity.setNumber(entity.getNumber() + 1);
|
||||
this.bookChapterService.updateById(entity);
|
||||
}
|
||||
|
||||
bookChapterService.save(bookChapter);
|
||||
// if (number != null && bookId != null) {
|
||||
// BookChapterEntity chapter = bookChapterService.getBaseMapper().selectOne(new QueryWrapper<BookChapterEntity>()
|
||||
// .eq("number", number)
|
||||
// .eq("book_id", bookId));
|
||||
// if (chapter != null) {
|
||||
// return R.error("该章节已存在,请修改或重新上传");
|
||||
// } else {
|
||||
// bookChapterEntity.setBookId(bookChapter.getBookId());
|
||||
// bookChapterEntity.setNumber(bookChapter.getNumber());
|
||||
// bookChapterEntity.setContent(bookChapter.getContent());
|
||||
// bookChapterEntity.setChapter(bookChapter.getChapter());
|
||||
// bookChapterEntity.setVoices(bookChapter.getVoices());
|
||||
// bookChapterService.save(bookChapterEntity);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ public class BookClockinController {
|
||||
.eq("user_id", userId)
|
||||
);
|
||||
if (bookClockinPunchEntity==null) {
|
||||
return R.error("您尚未签到,签到完成即可发表内容");
|
||||
return R.error("当天打卡内容未发布");
|
||||
}
|
||||
BookClockinEntity bookClockin = bookClockinService.getBaseMapper().selectOne(new QueryWrapper<BookClockinEntity>()
|
||||
.eq("book_id", bookId)
|
||||
|
||||
@@ -59,18 +59,6 @@ public class BookController {
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@@ -92,8 +80,7 @@ public class BookController {
|
||||
@PathVariable("userId") Integer userId) {
|
||||
|
||||
|
||||
System.out.println("++++++id"+id);
|
||||
System.out.println("++++++userId"+userId);
|
||||
|
||||
// 判断用户是否够买书籍
|
||||
|
||||
BookEntity book = bookService.getById(id);
|
||||
|
||||
@@ -52,42 +52,51 @@ public class BookForumArticlesServiceController {
|
||||
List list = new ArrayList<>();
|
||||
List<BookForumArticlesEntity> newBookList_all = bookForumArticlesService.getBaseMapper().selectList(new QueryWrapper<BookForumArticlesEntity>()
|
||||
.orderByDesc("create_time"));
|
||||
Set<BookForumArticlesEntity> uniqueSet = new HashSet<>();
|
||||
System.out.println();
|
||||
for (BookForumArticlesEntity entity : newBookList_all) {
|
||||
boolean isUnique = true;
|
||||
for (BookForumArticlesEntity uniqueEntity : uniqueSet) {
|
||||
if (entity.getBookid().equals(uniqueEntity.getBookid())) {
|
||||
isUnique = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isUnique) {
|
||||
uniqueSet.add(entity);
|
||||
}
|
||||
}
|
||||
List<BookForumArticlesEntity> newBookList_unique = new ArrayList<>(uniqueSet);
|
||||
List<BookForumArticlesEntity> newBookList = new ArrayList<>();
|
||||
int start = (page-1)*2;
|
||||
int end = (page-1)*2+2;
|
||||
if((page-1)*2 >= newBookList_all.size()){
|
||||
start = newBookList_all.size();
|
||||
if((page-1)*2 >= newBookList_unique.size()){
|
||||
start = newBookList_unique.size();
|
||||
}
|
||||
if((page-1)*2+2 >= newBookList_all.size()){
|
||||
end = newBookList_all.size();
|
||||
if((page-1)*2+2 >= newBookList_unique.size()){
|
||||
end = newBookList_unique.size();
|
||||
}
|
||||
newBookList = newBookList_all.subList(start,end);
|
||||
newBookList = newBookList_unique.subList(start,end);
|
||||
|
||||
for (BookForumArticlesEntity book : newBookList) {
|
||||
String bookid = "";
|
||||
String publisherName = "";
|
||||
BookForumArticlesVO bookForumArticlesVO = new BookForumArticlesVO();
|
||||
|
||||
|
||||
String bookid1 = String.valueOf(book.getBookid());
|
||||
|
||||
String image = book.getImage();
|
||||
String content = book.getContent();
|
||||
String title = book.getTitle();
|
||||
Date createTime = book.getCreateTime();
|
||||
|
||||
String[] authorIds = bookid1.split(",");
|
||||
List<String> bookids = Arrays.asList(authorIds);
|
||||
|
||||
List<BookEntity> id = bookService.getBaseMapper().selectList(new QueryWrapper<BookEntity>().in("id", bookids));
|
||||
|
||||
List<BookEntity> id = bookService.getBaseMapper().selectList(new QueryWrapper<BookEntity>().in("id", bookid1));
|
||||
System.out.println("id==========="+id);
|
||||
for (BookEntity bookentity : id) {
|
||||
String authorName = "";
|
||||
String images = bookentity.getImages();
|
||||
String name = bookentity.getName();
|
||||
Integer id1 = bookentity.getId();
|
||||
|
||||
|
||||
String authorId = bookentity.getAuthorId();
|
||||
|
||||
String[] author = authorId.split(",");
|
||||
List<String> authorList = Arrays.asList(author);
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
|
||||
@@ -107,7 +116,7 @@ public class BookForumArticlesServiceController {
|
||||
publisherName += "," + publisherEntity.getPublisherName();
|
||||
}
|
||||
publisherName = publisherName.startsWith(",") ? publisherName.substring(1) : publisherName;
|
||||
bookForumArticlesVO.setBookid(bookid1);
|
||||
bookForumArticlesVO.setBookid(String.valueOf(bookid1));
|
||||
bookForumArticlesVO.setAuthorName(authorName);
|
||||
bookForumArticlesVO.setPublisherName(publisherName);
|
||||
bookForumArticlesVO.setBookName(name);
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.stream.Collectors;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.BuyOrderDetailEntity;
|
||||
import com.peanut.modules.book.entity.ShopCategoryEntity;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.BuyOrderDetailService;
|
||||
import com.peanut.modules.book.service.ShopCategoryService;
|
||||
@@ -67,7 +68,7 @@ public class ShopProductController {
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:shopproduct:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = shopProductService.queryPage(params);
|
||||
PageUtils page = shopProductService.appQueryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
|
||||
}
|
||||
@@ -192,12 +193,14 @@ public class ShopProductController {
|
||||
/**
|
||||
* 信息
|
||||
|
||||
* @param productId
|
||||
* @param productId 9.13商品详情原接口
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/info/{productId}")
|
||||
public R info(@PathVariable("productId") Integer productId){
|
||||
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", productId));
|
||||
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String,String>>();
|
||||
ArrayList<Map<String, String>> imagesUrls = new ArrayList<Map<String,String>>();
|
||||
Integer poid = shopProductEntity.getProductPid();
|
||||
String bookids = shopProductEntity.getBookId();
|
||||
List<Integer> poids = shopCategoryService.findPoid(poid);
|
||||
@@ -206,31 +209,41 @@ public class ShopProductController {
|
||||
String bookId = shopProductEntity.getBookId();
|
||||
list.add(bookId);
|
||||
shopProductEntity.setBookids(list);
|
||||
String bookId1 = shopProductEntity.getBookId();
|
||||
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String,String>>();
|
||||
ArrayList<Map<String, String>> imagesUrls = new ArrayList<Map<String,String>>();
|
||||
Boolean canListen=null;
|
||||
for(String s : bookId1.split(",")){
|
||||
if(null != s && !"".equals(s)){
|
||||
BookEntity book = this.bookService.getById(s);
|
||||
String canListen1 =String.valueOf(book.getCanListen()) ;
|
||||
Map<String, String> urlMap = new HashMap<String, String>();
|
||||
urlMap.put("id",s);
|
||||
//如果图书删除了,商品页面会报错
|
||||
urlMap.put("images",book.getImages());
|
||||
urlMap.put("name",book.getName());
|
||||
urlMap.put("canListen",canListen1);
|
||||
imagesUrl.add(urlMap)
|
||||
;
|
||||
//TODO 判定
|
||||
if (shopProductEntity.getBookId() != null) {
|
||||
String bookId1 = shopProductEntity.getBookId();
|
||||
for(String s : bookId1.split(",")){
|
||||
if(null != s && !"".equals(s)){
|
||||
BookEntity book = this.bookService.getById(s);
|
||||
String canListen1 =String.valueOf(book.getCanListen()) ;
|
||||
Map<String, String> urlMap = new HashMap<String, String>();
|
||||
urlMap.put("id",s);
|
||||
//如果图书删除了,商品页面会报错
|
||||
urlMap.put("images",book.getImages());
|
||||
urlMap.put("name",book.getName());
|
||||
urlMap.put("canListen",canListen1);
|
||||
imagesUrl.add(urlMap)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
ShopProductEntity shopProduct = shopProductService.getById(productId);
|
||||
return R.ok().put("shopProduct", shopProduct);
|
||||
}
|
||||
|
||||
|
||||
Boolean canListen=null;
|
||||
|
||||
|
||||
|
||||
shopProductEntity.setBookidsimages(imagesUrl);
|
||||
return R.ok().put("shopProduct", shopProductEntity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@@ -246,8 +259,10 @@ public class ShopProductController {
|
||||
if (bkids!=null &&!bkids.isEmpty()){
|
||||
String substring = bkids.substring(0, bkids.length() - 1);
|
||||
shopProduct.setBookId(substring);
|
||||
}else {
|
||||
shopProduct.setBookId("");
|
||||
}
|
||||
shopProduct.setBookId("");
|
||||
|
||||
shopProduct.setCreateTime(new Date());
|
||||
shopProductService.save(shopProduct);
|
||||
return R.ok();
|
||||
@@ -301,10 +316,18 @@ public class ShopProductController {
|
||||
*/
|
||||
@RequestMapping("/appGetCategoryList")
|
||||
public R appGetCategoryList(@RequestParam("catId") Integer catId){
|
||||
System.out.println("catId======================"+catId);
|
||||
List<ShopCategoryEntity> list1 = shopCategoryService.getBaseMapper().selectList(new QueryWrapper<ShopCategoryEntity>()
|
||||
.eq("cat_id",catId));
|
||||
if (catId == null) {
|
||||
|
||||
}
|
||||
|
||||
if(catId == 0){
|
||||
catId = null;
|
||||
}
|
||||
List<ShopProductEntity> list = shopProductService.appGetCategoryList(catId);
|
||||
System.out.println("list==========================="+list);
|
||||
return R.ok().put("list", list);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,23 +97,24 @@ public class UserEbookBuyController {
|
||||
List<UserEbookBuyEntity> user_id = userEbookBuyService.getBaseMapper().selectList(new QueryWrapper<UserEbookBuyEntity>().eq("user_id", userId));
|
||||
for (UserEbookBuyEntity userEbookBuyEntity : user_id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Integer bookId = userEbookBuyEntity.getBookId();
|
||||
Integer userId1 = userEbookBuyEntity.getUserId();
|
||||
String bookName = userEbookBuyEntity.getBookName();
|
||||
Integer bookId = userEbookBuyEntity.getBookId();
|
||||
Integer buyId = userEbookBuyEntity.getBuyId();
|
||||
String image = userEbookBuyEntity.getImage();
|
||||
String author = userEbookBuyEntity.getAuthor();
|
||||
List<BookEntity> id = bookService.getBaseMapper().selectList(new QueryWrapper<BookEntity>().eq("id", bookId));
|
||||
for (BookEntity bookEntity : id) {
|
||||
String images = bookEntity.getImages();
|
||||
Integer id1 = bookEntity.getId();
|
||||
String name1 = bookEntity.getName();
|
||||
|
||||
String name = bookEntity.getName();
|
||||
Boolean canListen = bookEntity.getCanListen();
|
||||
map.put("canListen", canListen);
|
||||
map.put("bookId",bookId);
|
||||
map.put("userId",userId1);
|
||||
map.put("bookName",bookName);
|
||||
map.put("bookName",name1);
|
||||
map.put("buyId",buyId);
|
||||
map.put("image",image);
|
||||
map.put("author",author);
|
||||
map.put("image",images);
|
||||
// map.put("author",author);
|
||||
|
||||
list.add(map);
|
||||
|
||||
|
||||
@@ -52,50 +52,60 @@ public class UserRecordController {
|
||||
@RequestMapping("/All")
|
||||
public R All(@RequestBody UserRecordEntity userRecordEntity) {
|
||||
|
||||
|
||||
|
||||
List list = new ArrayList<>();
|
||||
//此处bookid实际传的是商品id
|
||||
List<UserRecordEntity> bookid = userRecordService.getBaseMapper().selectList(new QueryWrapper<UserRecordEntity>().eq("bookid", userRecordEntity.getBookid()).orderByDesc("create_date"));
|
||||
for (UserRecordEntity userRecord : bookid) {
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
Integer bookid1 = userRecord.getBookid();
|
||||
Integer userid1 = userRecord.getUserid();
|
||||
Integer id1 = userRecord.getId();
|
||||
List<MyUserEntity> id = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userid1));
|
||||
String usser = "";
|
||||
String name = "";
|
||||
for (MyUserEntity user : id) {
|
||||
usser = user.getAvatar();
|
||||
name = user.getNickname();
|
||||
}
|
||||
|
||||
List<UserFollowUpEntity> followUpEntity = userFollowUpService.getBaseMapper().selectList(new QueryWrapper<UserFollowUpEntity>()
|
||||
.eq("oid", id1)
|
||||
.eq("userId", userid1)
|
||||
.orderByDesc("create_date"));
|
||||
String conTent = "";
|
||||
Date date = null;
|
||||
for (UserFollowUpEntity followUp : followUpEntity) {
|
||||
conTent = followUp.getConTent();
|
||||
date = followUp.getCreateDate();
|
||||
|
||||
if (bookid != null) {
|
||||
for (UserRecordEntity userRecord : bookid) {
|
||||
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
Integer bookid1 = userRecord.getBookid();
|
||||
Integer userid1 = userRecord.getUserid();
|
||||
Integer id1 = userRecord.getId();
|
||||
List<MyUserEntity> id = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userid1));
|
||||
String usser = "";
|
||||
String name = "";
|
||||
for (MyUserEntity user : id) {
|
||||
usser = user.getAvatar();
|
||||
name = user.getNickname();
|
||||
}
|
||||
|
||||
List<UserFollowUpEntity> followUpEntity = userFollowUpService.getBaseMapper().selectList(new QueryWrapper<UserFollowUpEntity>()
|
||||
.eq("oid", id1)
|
||||
.eq("userId", userid1)
|
||||
.orderByDesc("create_date"));
|
||||
String conTent = "";
|
||||
Date date = null;
|
||||
for (UserFollowUpEntity followUp : followUpEntity) {
|
||||
conTent = followUp.getConTent();
|
||||
date = followUp.getCreateDate();
|
||||
|
||||
}
|
||||
|
||||
map.put("followUpdate", date);
|
||||
map.put("followUpcontent", conTent);
|
||||
map.put("avatar", usser);
|
||||
map.put("name", name);
|
||||
map.put("bookid", bookid1);
|
||||
map.put("orderSn", userRecord.getOrderSn());
|
||||
map.put("userid", userid1);
|
||||
map.put("content", userRecord.getContent());
|
||||
map.put("images", userRecord.getImages());
|
||||
map.put("starlevel", userRecord.getStarLevel());
|
||||
map.put("createdate", userRecord.getCreateDate());
|
||||
list.add(map);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
map.put("followUpdate", date);
|
||||
map.put("followUpcontent", conTent);
|
||||
map.put("avatar", usser);
|
||||
map.put("name", name);
|
||||
map.put("bookid", bookid1);
|
||||
map.put("orderSn", userRecord.getOrderSn());
|
||||
map.put("userid", userid1);
|
||||
map.put("content", userRecord.getContent());
|
||||
map.put("images", userRecord.getImages());
|
||||
map.put("starlevel", userRecord.getStarLevel());
|
||||
map.put("createdate", userRecord.getCreateDate());
|
||||
list.add(map);
|
||||
|
||||
|
||||
|
||||
return R.ok().put("list", list);
|
||||
}
|
||||
return R.ok().put("list", list);
|
||||
return R.error("该商品暂无评论");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user