1优化网络图片转换策略

This commit is contained in:
xiongxiaoyang 2020-05-21 08:46:46 +08:00
parent a13ea78c3f
commit c2cdf73893
5 changed files with 11 additions and 16 deletions

View File

@ -13,9 +13,10 @@ import java.util.List;
/** /**
* 网络图片转存本地任务 * 网络图片转存本地任务
*
* @author Administrator * @author Administrator
*/ */
@ConditionalOnProperty(prefix = "pic.save",name = "type",havingValue = "2") @ConditionalOnProperty(prefix = "pic.save", name = "type", havingValue = "2")
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j @Slf4j
@ -38,15 +39,10 @@ public class Network2LocalPicSchedule {
log.info("Network2LocalPicSchedule。。。。。。。。。。。。"); log.info("Network2LocalPicSchedule。。。。。。。。。。。。");
Integer offset = 0, limit = 100; List<Book> networkPicBooks = bookService.queryNetworkPicBooks(100);
List<Book> networkPicBooks; for (Book book : networkPicBooks) {
do { bookService.updateBookPicToLocal(book.getPicUrl(), book.getId());
networkPicBooks = bookService.queryNetworkPicBooks(limit, offset); }
for (Book book : networkPicBooks) {
bookService.updateBookPicToLocal(book.getPicUrl(), book.getId());
}
offset += limit;
} while (networkPicBooks.size() > 0);
} }

View File

@ -22,7 +22,7 @@ public interface FrontBookMapper extends BookMapper {
void addCommentCount(@Param("bookId") Long bookId); void addCommentCount(@Param("bookId") Long bookId);
List<Book> queryNetworkPicBooks(@Param("limit") Integer limit,@Param("offset") Integer offset); List<Book> queryNetworkPicBooks(@Param("limit") Integer limit);
/** /**
* 按评分随机查询小说集合 * 按评分随机查询小说集合

View File

@ -181,10 +181,9 @@ public interface BookService {
/** /**
* 查询网络图片的小说 * 查询网络图片的小说
* @param limit 查询条数 * @param limit 查询条数
* @param offset 开始行数
* @return 返回小说集合 * @return 返回小说集合
* */ * */
List<Book> queryNetworkPicBooks(Integer limit, Integer offset); List<Book> queryNetworkPicBooks(Integer limit);
/** /**

View File

@ -600,8 +600,8 @@ public class BookServiceImpl implements BookService {
} }
@Override @Override
public List<Book> queryNetworkPicBooks(Integer limit, Integer offset) { public List<Book> queryNetworkPicBooks(Integer limit) {
return bookMapper.queryNetworkPicBooks(limit, offset); return bookMapper.queryNetworkPicBooks(limit);
} }
@Override @Override

View File

@ -56,7 +56,7 @@
select select
id,pic_url from book id,pic_url from book
where pic_url like 'http%' where pic_url like 'http%'
limit #{offset},#{limit} limit #{limit}
</select> </select>
<select id="selectIdsByScoreAndRandom" parameterType="int" resultType="com.java2nb.novel.entity.Book"> <select id="selectIdsByScoreAndRandom" parameterType="int" resultType="com.java2nb.novel.entity.Book">