This commit is contained in:
xxy 2020-05-05 08:51:42 +08:00
parent bc445548ce
commit 5ec0f39b89
2 changed files with 22 additions and 17 deletions

View File

@ -42,8 +42,19 @@ public class Network2LocalPicSchedule {
log.info("Network2LocalPicSchedule。。。。。。。。。。。。");
bookService.networkPicToLocal();
Integer offset = 0, limit = 100;
List<Book> networkPicBooks;
do {
networkPicBooks = bookService.queryNetworkPicBooks(limit, offset);
for (Book book : networkPicBooks) {
try {
bookService.networkPicToLocal(book);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
offset += limit;
} while (networkPicBooks.size() > 0);
}

View File

@ -150,22 +150,16 @@ public class BookService {
/**
* 网络图片转本地
*
* @param book
*/
public void networkPicToLocal() {
Integer offset = 0, limit = 100;
List<Book> networkPicBooks;
do {
networkPicBooks = queryNetworkPicBooks(limit, offset);
for (Book book : networkPicBooks) {
try {
book.setPicUrl(FileUtil.network2Local(book.getPicUrl(), picSavePath));
bookMapper.updateByPrimaryKeySelective(book);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
offset += limit;
} while (networkPicBooks.size() > 0);
public void networkPicToLocal(Book book) {
try {
book.setPicUrl(FileUtil.network2Local(book.getPicUrl(), picSavePath));
bookMapper.updateByPrimaryKeySelective(book);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}