--图书分类
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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.BookCategoryEntity;
|
||||
import com.peanut.modules.book.entity.ShopCategoryEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface BookCategoryService extends IService<BookCategoryEntity> {
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
List<BookCategoryEntity> getOneLevel();
|
||||
|
||||
|
||||
|
||||
void removeCheckByIds(List<String> asList);
|
||||
|
||||
List<BookCategoryEntity> listTree();
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.book.dao.BookCategoryDao;
|
||||
import com.peanut.modules.book.entity.BookCategoryEntity;
|
||||
import com.peanut.modules.book.entity.ShopCategoryEntity;
|
||||
import com.peanut.modules.book.service.BookCategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("bookCategoryService")
|
||||
public class BookCategoryServiceImpl extends ServiceImpl<BookCategoryDao, BookCategoryEntity> implements BookCategoryService {
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
//分页
|
||||
IPage<BookCategoryEntity> page = this.page(
|
||||
new Query<BookCategoryEntity>().getPage(params),
|
||||
new QueryWrapper<BookCategoryEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookCategoryEntity> getOneLevel() {
|
||||
//获取一级分类
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void removeCheckByIds(List<String> asList) {
|
||||
//删除前查看是否有子目录
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookCategoryEntity> listTree() {
|
||||
List<BookCategoryEntity> entities = baseMapper.selectList(null);
|
||||
|
||||
List<BookCategoryEntity> level1 = entities.stream().filter((catalogueEntity) ->
|
||||
catalogueEntity.getBookCid() == 0
|
||||
|
||||
).map((menu)->{
|
||||
menu.setChildren(getChildrens(menu,entities));
|
||||
return menu;
|
||||
}).sorted((menu1,menu2)->{
|
||||
return (menu1.getSort() == null? 0 : menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return level1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private List<BookCategoryEntity> getChildrens(BookCategoryEntity root,List<BookCategoryEntity> all){
|
||||
|
||||
List<BookCategoryEntity> children = all.stream().filter(catalogueEntity -> {
|
||||
return root.getId().equals(catalogueEntity.getBookCid());
|
||||
}).map(catalogueEntity -> {
|
||||
catalogueEntity.setChildren(getChildrens(catalogueEntity, all));
|
||||
return catalogueEntity;
|
||||
}).sorted((menu1,menu2)->{
|
||||
return (menu1.getSort()==null?0:menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return children;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.common.utils.FileDownloadUtil;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BookChapterEntity;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.service.BookChapterService;
|
||||
@@ -12,7 +10,6 @@ import com.spire.doc.documents.Paragraph;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.text.BreakIterator;
|
||||
import java.util.List;
|
||||
@@ -22,13 +19,11 @@ 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.BookChapterContentDao;
|
||||
import com.peanut.modules.book.entity.BookChapterContentEntity;
|
||||
import com.peanut.modules.book.service.BookChapterContentService;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
|
||||
@Service("bookChapterContentService")
|
||||
public class BookChapterContentServiceImpl extends ServiceImpl<BookChapterContentDao, BookChapterContentEntity> implements BookChapterContentService {
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class BookChapterServiceImpl extends ServiceImpl<BookChapterDao, BookChap
|
||||
IPage<BookChapterEntity> page = this.page(
|
||||
new Query<BookChapterEntity>().getPage(params),
|
||||
//8.24修改根据number升序 排序
|
||||
new QueryWrapper<BookChapterEntity>().eq("book_id",bookid).orderByAsc("number")
|
||||
new QueryWrapper<BookChapterEntity>().eq("book_id",bookid).orderByDesc("number")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
|
||||
@@ -58,8 +58,10 @@ public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryDao, ShopCa
|
||||
|
||||
@Override
|
||||
public List<ShopCategoryEntity> getOneLevel() {
|
||||
// List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("parent_cid", 1).eq("show_status", 1));
|
||||
List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("name", "医学视频").eq("show_status", 1));
|
||||
List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("parent_cid", 1).eq("show_status", 1));
|
||||
System.out.println("list=================================="+list);
|
||||
|
||||
// List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("name", "医学视频").eq("show_status", 1));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<ShopProductEntity>().like("product_name", params.get("key"))
|
||||
.notLike("book_ids",",")
|
||||
.notLike("book_ids",",").orderByDesc("sum_sales").eq("del_flag",0)
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
public PageUtils appQueryPage(Map<String, Object> params) {
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProductEntity>()
|
||||
new QueryWrapper<ShopProductEntity>().orderByDesc("create_time")
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user