From 8d3c128f3bf68403643b26f82e58f96c42f93e26 Mon Sep 17 00:00:00 2001 From: yc13649764453 <1902434166@qq.com> Date: Fri, 15 Sep 2023 09:08:38 +0800 Subject: [PATCH] =?UTF-8?q?--=E5=9B=BE=E4=B9=A6=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 712 ++++++++++-------- logs/cms.2022-08-04.0.log | 22 +- peanut_book.iml | 1 + pom.xml | 6 + .../controller/BookCategoryController.java | 115 +++ .../controller/BookChapterController.java | 28 +- .../controller/BookClockinController.java | 2 +- .../book/controller/BookController.java | 15 +- .../BookForumArticlesServiceController.java | 41 +- .../controller/ShopProductController.java | 61 +- .../controller/UserEbookBuyController.java | 15 +- .../book/controller/UserRecordController.java | 86 ++- .../modules/book/dao/BookCategoryDao.java | 13 + .../book/entity/BookCategoryEntity.java | 70 ++ .../book/entity/BookClockinEntity.java | 6 +- .../book/entity/ShopProductEntity.java | 6 +- .../book/service/BookCategoryService.java | 22 + .../service/impl/BookCategoryServiceImpl.java | 75 ++ .../impl/BookChapterContentServiceImpl.java | 5 - .../service/impl/BookChapterServiceImpl.java | 2 +- .../service/impl/ShopCategoryServiceImpl.java | 6 +- .../service/impl/ShopProductServiceImpl.java | 4 +- .../oss/service/impl/OssServiceImpl.java | 2 +- .../resources/mapper/book/BookCategoryDao.xml | 20 + 24 files changed, 862 insertions(+), 473 deletions(-) create mode 100644 src/main/java/com/peanut/modules/book/controller/BookCategoryController.java create mode 100644 src/main/java/com/peanut/modules/book/dao/BookCategoryDao.java create mode 100644 src/main/java/com/peanut/modules/book/entity/BookCategoryEntity.java create mode 100644 src/main/java/com/peanut/modules/book/service/BookCategoryService.java create mode 100644 src/main/java/com/peanut/modules/book/service/impl/BookCategoryServiceImpl.java create mode 100644 src/main/resources/mapper/book/BookCategoryDao.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b4c2cb4a..e37f136d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,35 +2,30 @@ + + + + + + - + + + + - - - - + + - - - - - - - - - - + + + + - - - - - - @@ -71,38 +66,20 @@ - - - - - - - - - - - - - - + + - + - - - - - - - - - - - + + + + + @@ -122,36 +99,36 @@ - appGetOrderInfo - for (String - sout - 图片 - 健康超市 - appGetCategoryList - /punchcoments - punchcoments - clockin - queryBookInOther - book/task/list - nginx 销量 desccreatelist - 签到 我的 bookForumArticlesServiceImpl update 打卡 ossf 您尚未签到 - oss imageUrlPrefix html @RequiresPermissions forum/articles - @RequiresPermissions 生成器 9100 9200 + 分类 + 医学视频 + bookchapter + oss + desc + wei + Set<String> purchasedProductIds = new HashSet<>(); + book/bookchapter + 未购买 + 签到 + catalogueEntity + Append + shop-categorytree + save + mybatis @@ -165,36 +142,17 @@ @@ -259,8 +236,8 @@ - @@ -273,7 +250,6 @@ - @@ -349,6 +325,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -358,12 +412,13 @@ + - + @@ -848,7 +903,11 @@ - + + + + + 1663124293206 @@ -1229,7 +1288,7 @@ - @@ -1251,10 +1310,10 @@ - + - + @@ -1267,12 +1326,12 @@ - + - + @@ -1301,10 +1360,10 @@ - + - + @@ -1322,13 +1381,13 @@ - + - + @@ -1432,18 +1491,6 @@ - + - - + + - + - - + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - + - - + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - + + + + + - + - - + + - + - - + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - + - - + + - + - - + + - + - - + + - + - - - - - + + - + - - + + - + - - + + - + - - - - - + + - + - - + + - + - - + + - + - - - - - - - - - - - - - - - - + + - - + + + + + + + + + + + + + + + + + + + - - - - - + - - - - - + - + - - - - - - - - - + + - - + + @@ -1813,20 +1861,28 @@ - + - - - - - + + - + - - + + + + + + + + + + + + + diff --git a/logs/cms.2022-08-04.0.log b/logs/cms.2022-08-04.0.log index 4fab1cdb..9c2e6430 100644 --- a/logs/cms.2022-08-04.0.log +++ b/logs/cms.2022-08-04.0.log @@ -26,8 +26,8 @@ 2022-08-04 15:23:59.848 [INFO ] trationDelegate$BeanPostProcessorChecker : Bean 'OAuth2Realm' of type [com.peanut.modules.sys.oauth2.OAuth2Realm] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2022-08-04 15:23:59.872 [INFO ] trationDelegate$BeanPostProcessorChecker : Bean 'securityManager' of type [org.apache.shiro.web.mgt.DefaultWebSecurityManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2022-08-04 15:23:59.883 [INFO ] trationDelegate$BeanPostProcessorChecker : Bean 'authorizationAttributeSourceAdvisor' of type [org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) -2022-08-04 15:24:00.102 [INFO ] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9100 (http) -2022-08-04 15:24:00.111 [INFO ] o.a.coyote.http11.Http11NioProtocol : Initializing ProtocolHandler ["http-nio-9100"] +2022-08-04 15:24:00.102 [INFO ] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9200 (http) +2022-08-04 15:24:00.111 [INFO ] o.a.coyote.http11.Http11NioProtocol : Initializing ProtocolHandler ["http-nio-9200"] 2022-08-04 15:24:00.111 [INFO ] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-08-04 15:24:00.111 [INFO ] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.60] 2022-08-04 15:24:00.201 [INFO ] o.a.c.c.C.[Tomcat].[localhost].[/pb] : Initializing Spring embedded WebApplicationContext @@ -37,20 +37,20 @@ 2022-08-04 15:24:00.656 [INFO ] org.quartz.core.QuartzScheduler : Quartz Scheduler v.2.3.0 created. 2022-08-04 15:24:00.661 [INFO ] o.s.s.quartz.LocalDataSourceJobStore : Using db table-based data access locking (synchronization). 2022-08-04 15:24:00.662 [INFO ] o.s.s.quartz.LocalDataSourceJobStore : JobStoreCMT initialized. -2022-08-04 15:24:00.663 [INFO ] org.quartz.core.QuartzScheduler : Scheduler meta-data: Quartz Scheduler (v2.3.0) 'RenrenScheduler' with instanceId 'DESKTOP-MUPIBUO1659597840649' - Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally. - NOT STARTED. - Currently in standby mode. - Number of jobs executed: 0 - Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 20 threads. - Using job-store 'org.springframework.scheduling.quartz.LocalDataSourceJobStore' - which supports persistence. and is clustered. +2022-08-04 15:24:00.663 [INFO ] org.quartz.core.QuartzScheduler : Scheduler meta-data: Quartz Scheduler (v2.3.0) 'RenrenScheduler' with instanceId 'DESKTOP-MUPIBUO1659597840649' + Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally. + NOT STARTED. + Currently in standby mode. + Number of jobs executed: 0 + Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 20 threads. + Using job-store 'org.springframework.scheduling.quartz.LocalDataSourceJobStore' - which supports persistence. and is clustered. 2022-08-04 15:24:00.663 [INFO ] org.quartz.impl.StdSchedulerFactory : Quartz scheduler 'RenrenScheduler' initialized from an externally provided properties instance. 2022-08-04 15:24:00.664 [INFO ] org.quartz.impl.StdSchedulerFactory : Quartz scheduler version: 2.3.0 2022-08-04 15:24:00.665 [INFO ] org.quartz.core.QuartzScheduler : JobFactory set to: org.springframework.scheduling.quartz.AdaptableJobFactory@baa9ce4 2022-08-04 15:24:01.683 [INFO ] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [springfox.documentation.swagger2.web.Swagger2Controller#getDocumentation(String, HttpServletRequest)] -2022-08-04 15:24:02.134 [INFO ] o.a.coyote.http11.Http11NioProtocol : Starting ProtocolHandler ["http-nio-9100"] -2022-08-04 15:24:02.148 [INFO ] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9100 (http) with context path '/pb' +2022-08-04 15:24:02.134 [INFO ] o.a.coyote.http11.Http11NioProtocol : Starting ProtocolHandler ["http-nio-9200"] +2022-08-04 15:24:02.148 [INFO ] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9200 (http) with context path '/pb' 2022-08-04 15:24:02.149 [INFO ] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed 2022-08-04 15:24:02.160 [INFO ] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s) 2022-08-04 15:24:02.186 [INFO ] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references diff --git a/peanut_book.iml b/peanut_book.iml index bc7de4f8..09153be8 100644 --- a/peanut_book.iml +++ b/peanut_book.iml @@ -109,6 +109,7 @@ + diff --git a/pom.xml b/pom.xml index 3a60f55e..86b7dce8 100644 --- a/pom.xml +++ b/pom.xml @@ -125,6 +125,12 @@ + + icu.mhb + mybatis-plus-join + 1.3.4 + + mysql mysql-connector-java diff --git a/src/main/java/com/peanut/modules/book/controller/BookCategoryController.java b/src/main/java/com/peanut/modules/book/controller/BookCategoryController.java new file mode 100644 index 00000000..c5abbbcc --- /dev/null +++ b/src/main/java/com/peanut/modules/book/controller/BookCategoryController.java @@ -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 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 list = bookCategoryService.getOneLevel(); + return R.ok().put("list",list); + } + + + /** + * 获取图书 二级分类 + */ + @RequestMapping("/getTwoLevel") + public R getTwoLevel(){ + List listTree = bookCategoryService.listTree(); + return R.ok().put("data",listTree); + } + + + + +} diff --git a/src/main/java/com/peanut/modules/book/controller/BookChapterController.java b/src/main/java/com/peanut/modules/book/controller/BookChapterController.java index 51d7dff3..17174936 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookChapterController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookChapterController.java @@ -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 bookChapterEntities = this.bookChapterService.getBaseMapper().selectList(new QueryWrapper() .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() -// .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(); } diff --git a/src/main/java/com/peanut/modules/book/controller/BookClockinController.java b/src/main/java/com/peanut/modules/book/controller/BookClockinController.java index f9e06049..af531809 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookClockinController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookClockinController.java @@ -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() .eq("book_id", bookId) diff --git a/src/main/java/com/peanut/modules/book/controller/BookController.java b/src/main/java/com/peanut/modules/book/controller/BookController.java index f78decc6..fe1ce1bd 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookController.java @@ -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); diff --git a/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java b/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java index b7d9da0f..e43f288f 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java @@ -52,42 +52,51 @@ public class BookForumArticlesServiceController { List list = new ArrayList<>(); List newBookList_all = bookForumArticlesService.getBaseMapper().selectList(new QueryWrapper() .orderByDesc("create_time")); + Set 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 newBookList_unique = new ArrayList<>(uniqueSet); List 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 bookids = Arrays.asList(authorIds); - - List id = bookService.getBaseMapper().selectList(new QueryWrapper().in("id", bookids)); - + List id = bookService.getBaseMapper().selectList(new QueryWrapper().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 authorList = Arrays.asList(author); List authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper().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); diff --git a/src/main/java/com/peanut/modules/book/controller/ShopProductController.java b/src/main/java/com/peanut/modules/book/controller/ShopProductController.java index 71809346..4e8b21fa 100644 --- a/src/main/java/com/peanut/modules/book/controller/ShopProductController.java +++ b/src/main/java/com/peanut/modules/book/controller/ShopProductController.java @@ -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 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().eq("product_id", productId)); + ArrayList> imagesUrl = new ArrayList>(); + ArrayList> imagesUrls = new ArrayList>(); Integer poid = shopProductEntity.getProductPid(); String bookids = shopProductEntity.getBookId(); List 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> imagesUrl = new ArrayList>(); - ArrayList> imagesUrls = new ArrayList>(); - 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 urlMap = new HashMap(); - 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 urlMap = new HashMap(); + 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 list1 = shopCategoryService.getBaseMapper().selectList(new QueryWrapper() + .eq("cat_id",catId)); + if (catId == null) { + + } + if(catId == 0){ catId = null; } List list = shopProductService.appGetCategoryList(catId); + System.out.println("list==========================="+list); return R.ok().put("list", list); } diff --git a/src/main/java/com/peanut/modules/book/controller/UserEbookBuyController.java b/src/main/java/com/peanut/modules/book/controller/UserEbookBuyController.java index 3f2e97c6..02931cea 100644 --- a/src/main/java/com/peanut/modules/book/controller/UserEbookBuyController.java +++ b/src/main/java/com/peanut/modules/book/controller/UserEbookBuyController.java @@ -97,23 +97,24 @@ public class UserEbookBuyController { List user_id = userEbookBuyService.getBaseMapper().selectList(new QueryWrapper().eq("user_id", userId)); for (UserEbookBuyEntity userEbookBuyEntity : user_id) { Map 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 id = bookService.getBaseMapper().selectList(new QueryWrapper().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); diff --git a/src/main/java/com/peanut/modules/book/controller/UserRecordController.java b/src/main/java/com/peanut/modules/book/controller/UserRecordController.java index 374a2567..c3d97367 100644 --- a/src/main/java/com/peanut/modules/book/controller/UserRecordController.java +++ b/src/main/java/com/peanut/modules/book/controller/UserRecordController.java @@ -52,50 +52,60 @@ public class UserRecordController { @RequestMapping("/All") public R All(@RequestBody UserRecordEntity userRecordEntity) { + + List list = new ArrayList<>(); + //此处bookid实际传的是商品id List bookid = userRecordService.getBaseMapper().selectList(new QueryWrapper().eq("bookid", userRecordEntity.getBookid()).orderByDesc("create_date")); - for (UserRecordEntity userRecord : bookid) { - HashMap map = new HashMap<>(); - Integer bookid1 = userRecord.getBookid(); - Integer userid1 = userRecord.getUserid(); - Integer id1 = userRecord.getId(); - List id = myUserService.getBaseMapper().selectList(new QueryWrapper().eq("id", userid1)); - String usser = ""; - String name = ""; - for (MyUserEntity user : id) { - usser = user.getAvatar(); - name = user.getNickname(); - } - List followUpEntity = userFollowUpService.getBaseMapper().selectList(new QueryWrapper() - .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 map = new HashMap<>(); + Integer bookid1 = userRecord.getBookid(); + Integer userid1 = userRecord.getUserid(); + Integer id1 = userRecord.getId(); + List id = myUserService.getBaseMapper().selectList(new QueryWrapper().eq("id", userid1)); + String usser = ""; + String name = ""; + for (MyUserEntity user : id) { + usser = user.getAvatar(); + name = user.getNickname(); + } + + List followUpEntity = userFollowUpService.getBaseMapper().selectList(new QueryWrapper() + .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("该商品暂无评论"); + } diff --git a/src/main/java/com/peanut/modules/book/dao/BookCategoryDao.java b/src/main/java/com/peanut/modules/book/dao/BookCategoryDao.java new file mode 100644 index 00000000..2f9d9bb3 --- /dev/null +++ b/src/main/java/com/peanut/modules/book/dao/BookCategoryDao.java @@ -0,0 +1,13 @@ +package com.peanut.modules.book.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.peanut.modules.book.entity.BookCategoryEntity; +import org.apache.ibatis.annotations.Mapper; + + + + + +@Mapper +public interface BookCategoryDao extends BaseMapper { +} diff --git a/src/main/java/com/peanut/modules/book/entity/BookCategoryEntity.java b/src/main/java/com/peanut/modules/book/entity/BookCategoryEntity.java new file mode 100644 index 00000000..7d0e79a4 --- /dev/null +++ b/src/main/java/com/peanut/modules/book/entity/BookCategoryEntity.java @@ -0,0 +1,70 @@ +package com.peanut.modules.book.entity; + + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * 图书二级分类 + * + */ +@Data +@TableName("book_category") +public class BookCategoryEntity { + + /** + * 分类id + */ + @TableId + private Integer id; + /** + * 分类名称 + */ + @TableField("name") + private String name; + /** + * 父分类id + */ + @TableField("book_cid") + private Integer bookCid; + /** + * 层级 + */ + @TableField("book_level") + private Integer bookLevel; + + + + /** + * 删除标记 + */ + @TableLogic + private Integer delFlag; + + + /** + * 排序 + */ + @TableField("sort") + private Integer sort; + + /** + * 商品数量 + */ + @TableField("book_count") + private Integer bookCount; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @TableField(exist = false) + private List children; + + + + +} diff --git a/src/main/java/com/peanut/modules/book/entity/BookClockinEntity.java b/src/main/java/com/peanut/modules/book/entity/BookClockinEntity.java index 5acbf7f3..232443f1 100644 --- a/src/main/java/com/peanut/modules/book/entity/BookClockinEntity.java +++ b/src/main/java/com/peanut/modules/book/entity/BookClockinEntity.java @@ -18,11 +18,7 @@ import java.util.Date; @TableName("book_clockin") public class BookClockinEntity implements Serializable { - /** - * id book_id user_id content clockin_sum - * clockin_days create_time update_time del_flag - * images voices like like_sum comment_sum - */ + /** * diff --git a/src/main/java/com/peanut/modules/book/entity/ShopProductEntity.java b/src/main/java/com/peanut/modules/book/entity/ShopProductEntity.java index f3e02cb7..89b51944 100644 --- a/src/main/java/com/peanut/modules/book/entity/ShopProductEntity.java +++ b/src/main/java/com/peanut/modules/book/entity/ShopProductEntity.java @@ -1,9 +1,6 @@ package com.peanut.modules.book.entity; -import com.baomidou.mybatisplus.annotation.FieldStrategy; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.*; import java.math.BigDecimal; import java.io.Serializable; @@ -90,6 +87,7 @@ public class ShopProductEntity implements Serializable { /** * 删除标记 */ + @TableLogic private Integer delFlag; /** * 排序 diff --git a/src/main/java/com/peanut/modules/book/service/BookCategoryService.java b/src/main/java/com/peanut/modules/book/service/BookCategoryService.java new file mode 100644 index 00000000..f1a0334b --- /dev/null +++ b/src/main/java/com/peanut/modules/book/service/BookCategoryService.java @@ -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 { + PageUtils queryPage(Map params); + + List getOneLevel(); + + + + void removeCheckByIds(List asList); + + List listTree(); +} diff --git a/src/main/java/com/peanut/modules/book/service/impl/BookCategoryServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/BookCategoryServiceImpl.java new file mode 100644 index 00000000..f4c5c533 --- /dev/null +++ b/src/main/java/com/peanut/modules/book/service/impl/BookCategoryServiceImpl.java @@ -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 implements BookCategoryService { + @Override + public PageUtils queryPage(Map params) { + //分页 + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + ); + + return new PageUtils(page); + } + + @Override + public List getOneLevel() { + //获取一级分类 + return null; + } + + + + @Override + public void removeCheckByIds(List asList) { + //删除前查看是否有子目录 + } + + @Override + public List listTree() { + List entities = baseMapper.selectList(null); + + List 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 getChildrens(BookCategoryEntity root,List all){ + + List 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; + } +} diff --git a/src/main/java/com/peanut/modules/book/service/impl/BookChapterContentServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/BookChapterContentServiceImpl.java index d312baa1..705d363a 100644 --- a/src/main/java/com/peanut/modules/book/service/impl/BookChapterContentServiceImpl.java +++ b/src/main/java/com/peanut/modules/book/service/impl/BookChapterContentServiceImpl.java @@ -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 implements BookChapterContentService { diff --git a/src/main/java/com/peanut/modules/book/service/impl/BookChapterServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/BookChapterServiceImpl.java index b225da12..b76399c8 100644 --- a/src/main/java/com/peanut/modules/book/service/impl/BookChapterServiceImpl.java +++ b/src/main/java/com/peanut/modules/book/service/impl/BookChapterServiceImpl.java @@ -31,7 +31,7 @@ public class BookChapterServiceImpl extends ServiceImpl page = this.page( new Query().getPage(params), //8.24修改根据number升序 排序 - new QueryWrapper().eq("book_id",bookid).orderByAsc("number") + new QueryWrapper().eq("book_id",bookid).orderByDesc("number") ); return new PageUtils(page); diff --git a/src/main/java/com/peanut/modules/book/service/impl/ShopCategoryServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/ShopCategoryServiceImpl.java index 54c65f28..0e854f95 100644 --- a/src/main/java/com/peanut/modules/book/service/impl/ShopCategoryServiceImpl.java +++ b/src/main/java/com/peanut/modules/book/service/impl/ShopCategoryServiceImpl.java @@ -58,8 +58,10 @@ public class ShopCategoryServiceImpl extends ServiceImpl getOneLevel() { -// List list = this.list(new QueryWrapper().eq("parent_cid", 1).eq("show_status", 1)); - List list = this.list(new QueryWrapper().eq("name", "医学视频").eq("show_status", 1)); + List list = this.list(new QueryWrapper().eq("parent_cid", 1).eq("show_status", 1)); + System.out.println("list=================================="+list); + + // List list = this.list(new QueryWrapper().eq("name", "医学视频").eq("show_status", 1)); return list; } diff --git a/src/main/java/com/peanut/modules/book/service/impl/ShopProductServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/ShopProductServiceImpl.java index 38e751d1..92f97951 100644 --- a/src/main/java/com/peanut/modules/book/service/impl/ShopProductServiceImpl.java +++ b/src/main/java/com/peanut/modules/book/service/impl/ShopProductServiceImpl.java @@ -26,7 +26,7 @@ public class ShopProductServiceImpl extends ServiceImpl page = this.page( new Query().getPage(params), new ExcludeEmptyQueryWrapper().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 params) { IPage page = this.page( new Query().getPage(params), - new QueryWrapper() + new QueryWrapper().orderByDesc("create_time") ); return new PageUtils(page); } diff --git a/src/main/java/com/peanut/modules/oss/service/impl/OssServiceImpl.java b/src/main/java/com/peanut/modules/oss/service/impl/OssServiceImpl.java index 61c4ea1c..c7154b6b 100644 --- a/src/main/java/com/peanut/modules/oss/service/impl/OssServiceImpl.java +++ b/src/main/java/com/peanut/modules/oss/service/impl/OssServiceImpl.java @@ -32,7 +32,6 @@ public class OssServiceImpl implements OssService { InputStream inputStream = file.getInputStream(); //获取文件名称 String fileName = file.getOriginalFilename(); - //1 在文件名称里面添加随机唯一的值 String uuid = UUID.randomUUID().toString().replaceAll("-",""); // yuy76t5rew01.jpg @@ -59,6 +58,7 @@ public class OssServiceImpl implements OssService { //需要把上传到阿里云oss路径手动拼接出来 // https://edu-guli-1010.oss-cn-beijing.aliyuncs.com/01.jpg String url = "https://"+bucketName+"."+endpoint+"/"+fileName; + return url; }catch(Exception e) { e.printStackTrace(); diff --git a/src/main/resources/mapper/book/BookCategoryDao.xml b/src/main/resources/mapper/book/BookCategoryDao.xml new file mode 100644 index 00000000..db9025c9 --- /dev/null +++ b/src/main/resources/mapper/book/BookCategoryDao.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file