diff --git a/novel-front/src/main/java/xyz/zinglizingli/books/core/schedule/ClearInvilidDataSchedule.java b/novel-front/src/main/java/xyz/zinglizingli/books/core/schedule/ClearInvilidDataSchedule.java index 36ffffb..7174e8a 100644 --- a/novel-front/src/main/java/xyz/zinglizingli/books/core/schedule/ClearInvilidDataSchedule.java +++ b/novel-front/src/main/java/xyz/zinglizingli/books/core/schedule/ClearInvilidDataSchedule.java @@ -3,6 +3,7 @@ package xyz.zinglizingli.books.core.schedule; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import xyz.zinglizingli.books.service.BookService; @@ -18,6 +19,9 @@ public class ClearInvilidDataSchedule { private final BookService bookService; + @Value("${pic.save.path}") + private String picSavePath; + /** * 每天凌晨两点清理一次 */ @@ -29,5 +33,7 @@ public class ClearInvilidDataSchedule { bookService.clearInvilidData(); + + } } diff --git a/novel-front/src/main/java/xyz/zinglizingli/books/service/BookService.java b/novel-front/src/main/java/xyz/zinglizingli/books/service/BookService.java index 5cc9c82..de6ef47 100644 --- a/novel-front/src/main/java/xyz/zinglizingli/books/service/BookService.java +++ b/novel-front/src/main/java/xyz/zinglizingli/books/service/BookService.java @@ -77,6 +77,9 @@ public class BookService { if (books.size() > 0) { //更新 bookId = books.get(0).getId(); + if(picSaveType == PicSaveType.LOCAL.getValue() && books.get(0).getPicUrl().startsWith(Constants.LOCAL_PIC_PREFIX)){ + book.setPicUrl(null); + } updateBook(book, bookId); isUpdate = true; diff --git a/novel-front/src/main/java/xyz/zinglizingli/common/utils/FileUtil.java b/novel-front/src/main/java/xyz/zinglizingli/common/utils/FileUtil.java index 978428c..9be3f34 100644 --- a/novel-front/src/main/java/xyz/zinglizingli/common/utils/FileUtil.java +++ b/novel-front/src/main/java/xyz/zinglizingli/common/utils/FileUtil.java @@ -7,6 +7,7 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; +import xyz.zinglizingli.books.core.utils.Constants; import java.io.*; import java.util.Date; @@ -28,7 +29,7 @@ public class FileUtil { ResponseEntity resEntity = RestTemplateUtil.getInstance(Charsets.ISO_8859_1).exchange(picSrc, HttpMethod.GET, requestEntity, Resource.class); InputStream input = Objects.requireNonNull(resEntity.getBody()).getInputStream(); Date currentDate = new Date(); - picSrc = "/localPic/" + DateUtils.formatDate(currentDate, "yyyy") + "/" + DateUtils.formatDate(currentDate, "MM") + "/" + DateUtils.formatDate(currentDate, "dd") + picSrc = Constants.LOCAL_PIC_PREFIX + DateUtils.formatDate(currentDate, "yyyy") + "/" + DateUtils.formatDate(currentDate, "MM") + "/" + DateUtils.formatDate(currentDate, "dd") + UUIDUtils.getUUID32() + picSrc.substring(picSrc.lastIndexOf(".")); File picFile = new File(picSavePath + picSrc); diff --git a/novel-front/src/main/resources/application.yml b/novel-front/src/main/resources/application.yml index 4a9c4e1..5bfbc8d 100644 --- a/novel-front/src/main/resources/application.yml +++ b/novel-front/src/main/resources/application.yml @@ -5,7 +5,7 @@ spring: datasource: url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root - password: + password: test123456 # url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai # username: root # password: test123456 diff --git a/script/crawlbook/application.yml b/script/crawlbook/application.yml index 2eef3a4..4ed0aef 100644 --- a/script/crawlbook/application.yml +++ b/script/crawlbook/application.yml @@ -1,13 +1,13 @@ server: {port: 8083} spring: - datasource: {url: 'jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai', - username: root, password: ''} + datasource: {url: 'jdbc:mysql://47.106.243.172:3306/novel?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai', + username: novel, password: novel!8888} mybatis: mapper-locations: classpath:mybatis/mapping/*.xml type-aliases-package: xyz.zinglizingli.books.po configuration: {log-impl: org.apache.ibatis.logging.stdout.StdOutImpl} mysql: {charset: utf8mb4} -books: {lowestScore: '8.5'} +books: {lowestScore: '9.0'} crawl: website: {type: '2'} soft-novel: '0'