mirror of
https://github.com/201206030/novel-plus.git
synced 2025-04-27 01:30:51 +00:00
perf: 预加载IdWorker
This commit is contained in:
parent
c1eb7b8954
commit
2a69a28a0c
@ -58,9 +58,10 @@ public class CrawlServiceImpl implements CrawlService {
|
|||||||
|
|
||||||
private final BookService bookService;
|
private final BookService bookService;
|
||||||
|
|
||||||
|
|
||||||
private final CacheService cacheService;
|
private final CacheService cacheService;
|
||||||
|
|
||||||
|
private final IdWorker idWorker = IdWorker.INSTANCE;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCrawlSource(CrawlSource source) {
|
public void addCrawlSource(CrawlSource source) {
|
||||||
@ -327,7 +328,7 @@ public class CrawlServiceImpl implements CrawlService {
|
|||||||
book.setCrawlBookId(bookId);
|
book.setCrawlBookId(bookId);
|
||||||
book.setCrawlSourceId(sourceId);
|
book.setCrawlSourceId(sourceId);
|
||||||
book.setCrawlLastTime(new Date());
|
book.setCrawlLastTime(new Date());
|
||||||
book.setId(IdWorker.INSTANCE.nextId());
|
book.setId(idWorker.nextId());
|
||||||
//解析章节目录
|
//解析章节目录
|
||||||
boolean parseIndexContentResult = CrawlParser.parseBookIndexAndContent(bookId, book, ruleBean, new HashMap<>(0), chapter -> {
|
boolean parseIndexContentResult = CrawlParser.parseBookIndexAndContent(bookId, book, ruleBean, new HashMap<>(0), chapter -> {
|
||||||
bookService.saveBookAndIndexAndContent(book, chapter.getBookIndexList(), chapter.getBookContentList());
|
bookService.saveBookAndIndexAndContent(book, chapter.getBookIndexList(), chapter.getBookContentList());
|
||||||
|
@ -95,6 +95,8 @@ public class BookServiceImpl implements BookService {
|
|||||||
|
|
||||||
private final BookPriceProperties bookPriceConfig;
|
private final BookPriceProperties bookPriceConfig;
|
||||||
|
|
||||||
|
private final IdWorker idWorker = IdWorker.INSTANCE;
|
||||||
|
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
@ -428,7 +430,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
} else {
|
} else {
|
||||||
//作者不存在,先创建作者
|
//作者不存在,先创建作者
|
||||||
Date currentDate = new Date();
|
Date currentDate = new Date();
|
||||||
authorId = IdWorker.INSTANCE.nextId();
|
authorId = idWorker.nextId();
|
||||||
BookAuthor bookAuthor = new BookAuthor();
|
BookAuthor bookAuthor = new BookAuthor();
|
||||||
bookAuthor.setId(authorId);
|
bookAuthor.setId(authorId);
|
||||||
bookAuthor.setPenName(authorName);
|
bookAuthor.setPenName(authorName);
|
||||||
@ -548,7 +550,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
//并不是更新自己的小说
|
//并不是更新自己的小说
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Long lastIndexId = IdWorker.INSTANCE.nextId();
|
Long lastIndexId = idWorker.nextId();
|
||||||
Date currentDate = new Date();
|
Date currentDate = new Date();
|
||||||
int wordCount = StringUtil.getStrValidWordCount(content);
|
int wordCount = StringUtil.getStrValidWordCount(content);
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ public class UserServiceImpl implements UserService {
|
|||||||
|
|
||||||
private final UserBuyRecordMapper userBuyRecordMapper;
|
private final UserBuyRecordMapper userBuyRecordMapper;
|
||||||
|
|
||||||
|
private final IdWorker idWorker = IdWorker.INSTANCE;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -74,7 +75,7 @@ public class UserServiceImpl implements UserService {
|
|||||||
User entity = new User();
|
User entity = new User();
|
||||||
BeanUtils.copyProperties(user,entity);
|
BeanUtils.copyProperties(user,entity);
|
||||||
//数据库生成注册记录
|
//数据库生成注册记录
|
||||||
Long id = IdWorker.INSTANCE.nextId();
|
Long id = idWorker.nextId();
|
||||||
entity.setId(id);
|
entity.setId(id);
|
||||||
entity.setNickName(entity.getUsername());
|
entity.setNickName(entity.getUsername());
|
||||||
Date currentDate = new Date();
|
Date currentDate = new Date();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user