Browse Source

完善阅读接口
更新 springboot 版本,解决 静态资源访问 问题

tianyunperfect 3 years ago
parent
commit
007bae382e

+ 1 - 1
book-dao/src/main/java/com/book/dao/VO/BookContentVO.java

@@ -6,6 +6,6 @@ import lombok.Data;
 public class BookContentVO {
 public class BookContentVO {
     Long userId;
     Long userId;
     Long bookId;
     Long bookId;
-    Integer contentId;
+    Long contentId;
     String contentName;
     String contentName;
 }
 }

+ 0 - 4
book-server/pom.xml

@@ -62,10 +62,6 @@
             <artifactId>spring-boot-starter-log4j2</artifactId>
             <artifactId>spring-boot-starter-log4j2</artifactId>
         </dependency>
         </dependency>
 
 
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-cache</artifactId>
-        </dependency>
         <!--异步日志依赖-->
         <!--异步日志依赖-->
         <dependency>
         <dependency>
             <groupId>com.lmax</groupId>
             <groupId>com.lmax</groupId>

+ 1 - 0
book-server/src/main/java/com/book/server/controller/BookController.java

@@ -18,6 +18,7 @@ import java.util.List;
  * 书籍
  * 书籍
  */
  */
 @RestController
 @RestController
+@CrossOrigin
 @RequestMapping("/api/book")
 @RequestMapping("/api/book")
 @Slf4j
 @Slf4j
 public class BookController extends BaseController {
 public class BookController extends BaseController {

+ 2 - 0
book-server/src/main/java/com/book/server/controller/UserController.java

@@ -4,6 +4,7 @@ import com.book.dao.cps.pojo.User;
 import com.book.server.common.entity.Result;
 import com.book.server.common.entity.Result;
 import com.book.server.service.UserService;
 import com.book.server.service.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
@@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
 /**
 /**
  * 用户
  * 用户
  */
  */
+@CrossOrigin
 @RestController
 @RestController
 @RequestMapping("/api/user")
 @RequestMapping("/api/user")
 public class UserController extends BaseController {
 public class UserController extends BaseController {

+ 0 - 19
book-server/src/main/java/com/book/server/filter/CorsFilter.java

@@ -1,19 +0,0 @@
-package com.book.server.filter;
-
-import org.springframework.stereotype.Component;
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
-
-@Component
-public class CorsFilter extends WebMvcConfigurationSupport {
-    @Override
-    protected void addCorsMappings(CorsRegistry registry) {
-        System.out.println(123456);
-        registry.addMapping("/**").
-                allowCredentials(true)
-                .allowedHeaders("*")
-                .allowedMethods("*")
-                .allowedOrigins("*");
-        super.addCorsMappings(registry);
-    }
-}

+ 6 - 5
book-server/src/main/java/com/book/server/service/impl/BookServiceImpl.java

@@ -309,8 +309,9 @@ public class BookServiceImpl implements BookService {
         if (bookContentVO.getContentId() > freeChapterNum) { //收费
         if (bookContentVO.getContentId() > freeChapterNum) { //收费
             //是否已购买
             //是否已购买
             Consume consume = consumeMapper.selectOneByExample(ConsumeExample.newAndCreateCriteria()
             Consume consume = consumeMapper.selectOneByExample(ConsumeExample.newAndCreateCriteria()
-                    .andBookIdEqualTo(bookContentVO.getBookId())
                     .andUserIdEqualTo(bookContentVO.getUserId())
                     .andUserIdEqualTo(bookContentVO.getUserId())
+                    .andBookIdEqualTo(bookContentVO.getBookId())
+                    .andChapterIdEqualTo(bookContentVO.getContentId())
                     .example()
                     .example()
             );
             );
             if (consume == null) { // 没有购买记录
             if (consume == null) { // 没有购买记录
@@ -387,7 +388,7 @@ public class BookServiceImpl implements BookService {
                 int i = userRecentlyReadMapper.insert(UserRecentlyRead.builder()
                 int i = userRecentlyReadMapper.insert(UserRecentlyRead.builder()
                         .userId(bookContentVO.getUserId())
                         .userId(bookContentVO.getUserId())
                         .bookId(book.getId())
                         .bookId(book.getId())
-                        .chapterId(Long.valueOf(bookContentVO.getContentId()))
+                        .chapterId(bookContentVO.getContentId())
                         .chapterName(bookContentVO.getContentName())
                         .chapterName(bookContentVO.getContentName())
                         .createtime(DateUtils.getNow())
                         .createtime(DateUtils.getNow())
                         .updatetime(DateUtils.getNow())
                         .updatetime(DateUtils.getNow())
@@ -396,7 +397,7 @@ public class BookServiceImpl implements BookService {
                         .build());
                         .build());
                 //checkUpdate(i);
                 //checkUpdate(i);
             } else {
             } else {
-                userRecentlyRead.setChapterId(Long.valueOf(bookContentVO.getContentId()));
+                userRecentlyRead.setChapterId(bookContentVO.getContentId());
                 userRecentlyRead.setChapterName(bookContentVO.getContentName());
                 userRecentlyRead.setChapterName(bookContentVO.getContentName());
                 userRecentlyRead.setUpdatetime(DateUtils.getNow());
                 userRecentlyRead.setUpdatetime(DateUtils.getNow());
                 int i = userRecentlyReadMapper.updateByPrimaryKeySelective(userRecentlyRead,
                 int i = userRecentlyReadMapper.updateByPrimaryKeySelective(userRecentlyRead,
@@ -432,7 +433,7 @@ public class BookServiceImpl implements BookService {
                 .type("1") // 订购章节
                 .type("1") // 订购章节
                 .bookId(book.getId())
                 .bookId(book.getId())
                 .bookName(book.getName())
                 .bookName(book.getName())
-                .chapterId(Long.valueOf(bookContentVO.getContentId()))
+                .chapterId(bookContentVO.getContentId())
                 .chapterName(bookContentVO.getContentName())
                 .chapterName(bookContentVO.getContentName())
                 .ddKandian(kandian)
                 .ddKandian(kandian)
                 .ddFreeKandian(freeKandian)
                 .ddFreeKandian(freeKandian)
@@ -486,7 +487,7 @@ public class BookServiceImpl implements BookService {
      */
      */
     private BookContent getBookContentFromRemote(BookContentVO bookContentVO) {
     private BookContent getBookContentFromRemote(BookContentVO bookContentVO) {
         Long bookId = bookContentVO.getBookId();
         Long bookId = bookContentVO.getBookId();
-        Integer contentId = bookContentVO.getContentId();
+        Long contentId = bookContentVO.getContentId();
         String contentUrl = "http://new.emeixs.com/index.php/Home/Interface/content/bid/%s/cid/%s";
         String contentUrl = "http://new.emeixs.com/index.php/Home/Interface/content/bid/%s/cid/%s";
         if (bookId == null || contentId == null) {
         if (bookId == null || contentId == null) {
             return null;
             return null;

+ 0 - 10
book-server/src/main/resources/static/index.html

@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <title>Title</title>
-</head>
-<body>
-test
-</body>
-</html>

+ 1 - 4
pom.xml

@@ -23,7 +23,7 @@
     <parent>
     <parent>
         <groupId>org.springframework.boot</groupId>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.1.5.RELEASE</version>
+        <version>2.1.17.RELEASE</version>
         <relativePath/>
         <relativePath/>
     </parent>
     </parent>
     <build>
     <build>
@@ -42,9 +42,6 @@
     <!--锁定springCloud版本-->
     <!--锁定springCloud版本-->
     <dependencyManagement>
     <dependencyManagement>
         <dependencies>
         <dependencies>
-
-
-
             <dependency>
             <dependency>
                 <groupId>org.springframework.cloud</groupId>
                 <groupId>org.springframework.cloud</groupId>
                 <artifactId>spring-cloud-dependencies</artifactId>
                 <artifactId>spring-cloud-dependencies</artifactId>