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.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import xyz.zinglizingli.books.service.BookService;
|
import xyz.zinglizingli.books.service.BookService;
|
||||||
@ -18,6 +19,9 @@ public class ClearInvilidDataSchedule {
|
|||||||
|
|
||||||
private final BookService bookService;
|
private final BookService bookService;
|
||||||
|
|
||||||
|
@Value("${pic.save.path}")
|
||||||
|
private String picSavePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 每天凌晨两点清理一次
|
* 每天凌晨两点清理一次
|
||||||
*/
|
*/
|
||||||
@ -29,5 +33,7 @@ public class ClearInvilidDataSchedule {
|
|||||||
bookService.clearInvilidData();
|
bookService.clearInvilidData();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,9 @@ public class BookService {
|
|||||||
if (books.size() > 0) {
|
if (books.size() > 0) {
|
||||||
//更新
|
//更新
|
||||||
bookId = books.get(0).getId();
|
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);
|
updateBook(book, bookId);
|
||||||
isUpdate = true;
|
isUpdate = true;
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import org.springframework.http.HttpEntity;
|
|||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import xyz.zinglizingli.books.core.utils.Constants;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Date;
|
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);
|
ResponseEntity<Resource> resEntity = RestTemplateUtil.getInstance(Charsets.ISO_8859_1).exchange(picSrc, HttpMethod.GET, requestEntity, Resource.class);
|
||||||
InputStream input = Objects.requireNonNull(resEntity.getBody()).getInputStream();
|
InputStream input = Objects.requireNonNull(resEntity.getBody()).getInputStream();
|
||||||
Date currentDate = new Date();
|
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()
|
+ UUIDUtils.getUUID32()
|
||||||
+ picSrc.substring(picSrc.lastIndexOf("."));
|
+ picSrc.substring(picSrc.lastIndexOf("."));
|
||||||
File picFile = new File(picSavePath + picSrc);
|
File picFile = new File(picSavePath + picSrc);
|
||||||
|
@ -5,7 +5,7 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||||
username: root
|
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
|
# url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||||
# username: root
|
# username: root
|
||||||
# password: test123456
|
# password: test123456
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
server: {port: 8083}
|
server: {port: 8083}
|
||||||
spring:
|
spring:
|
||||||
datasource: {url: 'jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai',
|
datasource: {url: 'jdbc:mysql://47.106.243.172:3306/novel?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai',
|
||||||
username: root, password: ''}
|
username: novel, password: novel!8888}
|
||||||
mybatis:
|
mybatis:
|
||||||
mapper-locations: classpath:mybatis/mapping/*.xml
|
mapper-locations: classpath:mybatis/mapping/*.xml
|
||||||
type-aliases-package: xyz.zinglizingli.books.po
|
type-aliases-package: xyz.zinglizingli.books.po
|
||||||
configuration: {log-impl: org.apache.ibatis.logging.stdout.StdOutImpl}
|
configuration: {log-impl: org.apache.ibatis.logging.stdout.StdOutImpl}
|
||||||
mysql: {charset: utf8mb4}
|
mysql: {charset: utf8mb4}
|
||||||
books: {lowestScore: '8.5'}
|
books: {lowestScore: '9.0'}
|
||||||
crawl:
|
crawl:
|
||||||
website: {type: '2'}
|
website: {type: '2'}
|
||||||
soft-novel: '0'
|
soft-novel: '0'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user