mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
本地图片保存优化
This commit is contained in:
parent
37bef6e1ce
commit
1555c5b170
@ -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();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<Resource> 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);
|
||||
|
@ -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
|
||||
|
@ -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'
|
||||
|
Loading…
x
Reference in New Issue
Block a user