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。。。。。。。。。。。。"); log.info("Network2LocalPicSchedule。。。。。。。。。。。。");
Integer offset = 0, limit = 100;
bookService.networkPicToLocal(); 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() { public void networkPicToLocal(Book book) {
Integer offset = 0, limit = 100; try {
List<Book> networkPicBooks; book.setPicUrl(FileUtil.network2Local(book.getPicUrl(), picSavePath));
do { bookMapper.updateByPrimaryKeySelective(book);
networkPicBooks = queryNetworkPicBooks(limit, offset); } catch (Exception e) {
for (Book book : networkPicBooks) { log.error(e.getMessage(), e);
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);
} }