调整更新策略

This commit is contained in:
xiongxiaoyang 2020-01-13 11:21:58 +08:00
parent ae8b8d47a9
commit a35ac89d89
3 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,39 @@
package xyz.zinglizingli.books.core.schedule;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import xyz.zinglizingli.books.core.crawl.BaseCrawlSource;
import xyz.zinglizingli.books.po.Book;
import xyz.zinglizingli.books.service.BookService;
import java.util.List;
/**
* 定时更新
*
* @author 11797
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class UpdateBookSchedule {
private final BaseCrawlSource crawlSource;
/**
* 10分钟更新一次
*/
@Scheduled(fixedRate = 1000 * 60 * 10)
public void updateBook() {
log.info("UpdateBookSchedule。。。。。。。。。。。。");
crawlSource.update();
}
}

13
sql/2020-01-13.sql Normal file
View File

@ -0,0 +1,13 @@
DROP TABLE IF EXISTS `book_parse_log`;
CREATE TABLE `book_parse_log` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`book_url` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
`book_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`score` float NOT NULL,
`create_time` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uq_key_bookurl` (`book_url`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

View File

@ -1011,3 +1011,16 @@ INSERT INTO `sys_dict` (`id`, `name`, `value`, `type`, `description`, `sort`, `p
alter table user_ref_book add column `index_num` int(5);
DROP TABLE IF EXISTS `book_parse_log`;
CREATE TABLE `book_parse_log` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`book_url` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
`book_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`score` float NOT NULL,
`create_time` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uq_key_bookurl` (`book_url`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;