mirror of
https://github.com/201206030/novel.git
synced 2025-07-07 21:36:38 +00:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
05d9e22df9 | |||
ef36527ed6 | |||
6688d5b017 | |||
b242d6d89f | |||
5ec0f39b89 | |||
bc445548ce | |||
7c3fb654bb | |||
060429001c | |||
df60698082 | |||
979bcb47df | |||
495bd40644 | |||
52f6bd2519 |
36
README.md
36
README.md
@ -1,12 +1,34 @@
|
|||||||
[](https://cloud.tencent.com/act/cps/redirect?redirect=1052&cps_key=736e609d66e0ac4e57813316cec6fd0b&from=console)
|
[](https://cloud.tencent.com/act/cps/redirect?redirect=1052&cps_key=736e609d66e0ac4e57813316cec6fd0b&from=console)
|
||||||
|
|
||||||
# 小说精品屋
|
# 小说精品屋
|
||||||
|
|
||||||
#### 项目文档
|
#### 新项目:小说精品屋-plus(推荐)
|
||||||
|
|
||||||
通用文档:[点击前往]( http://www.java2nb.com/article/5.html )
|
小说精品屋-plus致力于打造一个完整的可商用、可学习的小说门户平台。小说精品屋-plus是在小说精品屋的基础上,重新进行了数据库设计、代码重构和功能增强,提升了程序整体的可读性和性能,增加了很多商用特性。
|
||||||
|
|
||||||
非JAVA开发参考安装文档:[点击前往]( https://my.oschina.net/java2nb/blog/3145593 )
|
Gitee仓库地址: https://gitee.com/xiongxyang/novel-plus
|
||||||
|
|
||||||
|
GitHub仓库地址: https://github.com/201206030/novel-plus
|
||||||
|
|
||||||
|
#### 新项目:小说精品屋-微服务版(推荐)
|
||||||
|
|
||||||
|
基于小说精品屋-plus构建的Spring Cloud 微服务小说门户平台,可用于学习和商用。
|
||||||
|
|
||||||
|
Gitee仓库地址: https://gitee.com/xiongxyang/novel-cloud
|
||||||
|
|
||||||
|
GitHub仓库地址: https://github.com/201206030/novel-cloud
|
||||||
|
|
||||||
|
#### 前言
|
||||||
|
|
||||||
|
安装前请先阅读完此文档,了解项目基础配置和模块功能,再根据安装文档安装项目,避免一些不必要的错误。
|
||||||
|
|
||||||
|
#### 安装文档
|
||||||
|
|
||||||
|
源码安装文档(适合有一定技术基础的人):[点击前往](https://my.oschina.net/java2nb/blog/3145593)
|
||||||
|
|
||||||
|
包安装文档(适合非技术人员):[点击前往](https://my.oschina.net/java2nb/blog/3146627)
|
||||||
|
|
||||||
|
宝塔安装教程:[点击前往](https://www.daniao.org/7822.html )
|
||||||
|
|
||||||
#### 项目介绍
|
#### 项目介绍
|
||||||
|
|
||||||
@ -105,7 +127,7 @@ novel-admin :平台后台管理系统源码(独立项目,按需安装)
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
#### 安装教程
|
#### 安装说明
|
||||||
|
|
||||||
数据库安装:
|
数据库安装:
|
||||||
|
|
||||||
@ -119,7 +141,7 @@ novel-admin :平台后台管理系统源码(独立项目,按需安装)
|
|||||||
1. 运行script/crawlbook/crawlbook.bat脚本文件。(适用于本地多机器运行)
|
1. 运行script/crawlbook/crawlbook.bat脚本文件。(适用于本地多机器运行)
|
||||||
2. 安装后台管理系统后,打开爬虫管理菜单,点击爬虫运行按钮。(适用于线上环境运行,会占用较多服务器资源)
|
2. 安装后台管理系统后,打开爬虫管理菜单,点击爬虫运行按钮。(适用于线上环境运行,会占用较多服务器资源)
|
||||||
|
|
||||||
平台后台管理系统安装(独立项目,按需安装) :
|
平台后台管理系统安装(独立项目,按需安装)(已停止维护,爬虫功能请使用crawlbook.bat) :
|
||||||
|
|
||||||
1. 修改application.yml文件中数据库配置。
|
1. 修改application.yml文件中数据库配置。
|
||||||
|
|
||||||
@ -225,4 +247,4 @@ novel-admin :平台后台管理系统源码(独立项目,按需安装)
|
|||||||
|
|
||||||
精品小说屋所有相关项目均已在开源中国公开,感兴趣的可进入[开源中国](https://www.oschina.net/p/fiction_house)按关键字`精品小说屋`搜索。
|
精品小说屋所有相关项目均已在开源中国公开,感兴趣的可进入[开源中国](https://www.oschina.net/p/fiction_house)按关键字`精品小说屋`搜索。
|
||||||
|
|
||||||
[](https://www.aliyun.com/minisite/goods?userCode=uf4nasee )
|
[](https://www.aliyun.com/minisite/goods?userCode=uf4nasee )
|
@ -10,7 +10,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>xyz.zinglizingli</groupId>
|
<groupId>xyz.zinglizingli</groupId>
|
||||||
<artifactId>novel-front</artifactId>
|
<artifactId>novel-front</artifactId>
|
||||||
<version>2.3.0.beta</version>
|
<version>2.5.0.beta</version>
|
||||||
<name>novel-front</name>
|
<name>novel-front</name>
|
||||||
<description>小说精品楼-前台web网站</description>
|
<description>小说精品楼-前台web网站</description>
|
||||||
|
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package xyz.zinglizingli.books.core.config;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import xyz.zinglizingli.books.core.crawl.BaseHtmlCrawlSource;
|
||||||
|
import xyz.zinglizingli.books.core.crawl.BiquCrawlSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Configuration
|
||||||
|
public class CrawlBiquwoConfig {
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConfigurationProperties(prefix = "biquwo.crawlsource") // prefix值必须是application.yml中对应属性的前缀
|
||||||
|
@ConditionalOnProperty(prefix = "crawl.website",name = "type",havingValue = "6")
|
||||||
|
public BaseHtmlCrawlSource biquwoCrawlSource() {
|
||||||
|
return new BiquCrawlSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -66,6 +66,7 @@ public class StartListener implements ServletContextListener {
|
|||||||
|
|
||||||
log.info("updateBooks执行中。。。。。。。。。。。。");
|
log.info("updateBooks执行中。。。。。。。。。。。。");
|
||||||
crawlSource.update();
|
crawlSource.update();
|
||||||
|
Thread.sleep(2000);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -42,13 +42,16 @@ public class Network2LocalPicSchedule {
|
|||||||
|
|
||||||
log.info("Network2LocalPicSchedule。。。。。。。。。。。。");
|
log.info("Network2LocalPicSchedule。。。。。。。。。。。。");
|
||||||
|
|
||||||
|
|
||||||
Integer offset = 0, limit = 100;
|
Integer offset = 0, limit = 100;
|
||||||
List<Book> networkPicBooks;
|
List<Book> networkPicBooks;
|
||||||
do {
|
do {
|
||||||
networkPicBooks = bookService.queryNetworkPicBooks(limit, offset);
|
networkPicBooks = bookService.queryNetworkPicBooks(limit, offset);
|
||||||
for (Book book : networkPicBooks) {
|
for (Book book : networkPicBooks) {
|
||||||
bookService.updateBook(book, book.getId());
|
try {
|
||||||
|
bookService.networkPicToLocal(book);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
offset += limit;
|
offset += limit;
|
||||||
} while (networkPicBooks.size() > 0);
|
} while (networkPicBooks.size() > 0);
|
||||||
|
@ -54,11 +54,10 @@ public class BookService {
|
|||||||
private String picSavePath;
|
private String picSavePath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存章节目录和内容
|
* 保存章节目录和内容
|
||||||
* */
|
*/
|
||||||
public void saveBookAndIndexAndContent(Book book, List<BookIndex> bookIndex, List<BookContent> bookContent){
|
public void saveBookAndIndexAndContent(Book book, List<BookIndex> bookIndex, List<BookContent> bookContent) {
|
||||||
//解决内部调用事物不生效的问题
|
//解决内部调用事物不生效的问题
|
||||||
BookService bookService = SpringUtil.getBean(BookService.class);
|
BookService bookService = SpringUtil.getBean(BookService.class);
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ public class BookService {
|
|||||||
if (books.size() > 0) {
|
if (books.size() > 0) {
|
||||||
//更新
|
//更新
|
||||||
bookId = books.get(0).getId();
|
bookId = books.get(0).getId();
|
||||||
if(picSaveType == PicSaveType.LOCAL.getValue() && books.get(0).getPicUrl().startsWith(Constants.LOCAL_PIC_PREFIX)){
|
if (picSaveType == PicSaveType.LOCAL.getValue() && books.get(0).getPicUrl().startsWith(Constants.LOCAL_PIC_PREFIX)) {
|
||||||
book.setPicUrl(null);
|
book.setPicUrl(null);
|
||||||
}
|
}
|
||||||
updateBook(book, bookId);
|
updateBook(book, bookId);
|
||||||
@ -126,7 +125,6 @@ public class BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -134,31 +132,45 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新书籍
|
* 更新书籍
|
||||||
* */
|
*/
|
||||||
public void updateBook(Book book, Long bookId) {
|
public void updateBook(Book book, Long bookId) {
|
||||||
book.setId(bookId);
|
book.setId(bookId);
|
||||||
String picSrc = book.getPicUrl();
|
String picSrc = book.getPicUrl();
|
||||||
if(picSaveType == PicSaveType.LOCAL.getValue() && StringUtils.isNotBlank(picSrc)){
|
if (picSaveType == PicSaveType.LOCAL.getValue() && StringUtils.isNotBlank(picSrc)) {
|
||||||
try {
|
try {
|
||||||
picSrc = FileUtil.network2Local(picSrc,picSavePath);
|
picSrc = FileUtil.network2Local(picSrc, picSavePath);
|
||||||
book.setPicUrl(picSrc);
|
book.setPicUrl(picSrc);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(),e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
bookMapper.updateByPrimaryKeySelective(book);
|
bookMapper.updateByPrimaryKeySelective(book);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网络图片转本地
|
||||||
|
*
|
||||||
|
* @param book
|
||||||
|
*/
|
||||||
|
public void networkPicToLocal(Book book) {
|
||||||
|
try {
|
||||||
|
book.setPicUrl(FileUtil.network2Local(book.getPicUrl(), picSavePath));
|
||||||
|
bookMapper.updateByPrimaryKeySelective(book);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量插入章节目录表和章节内容表(自动修复错误章节)
|
* 批量插入章节目录表和章节内容表(自动修复错误章节)
|
||||||
* */
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void insertIndexListAndContentList(List<BookIndex> newBookIndexList, List<BookContent> newContentList) {
|
public void insertIndexListAndContentList(List<BookIndex> newBookIndexList, List<BookContent> newContentList) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
if(newBookIndexList.size() > 0) {
|
if (newBookIndexList.size() > 0) {
|
||||||
//删除已存在的错误章节
|
//删除已存在的错误章节
|
||||||
List<Integer> indexNumberList = newBookIndexList.stream().map(BookIndex::getIndexNum).collect(Collectors.toList());
|
List<Integer> indexNumberList = newBookIndexList.stream().map(BookIndex::getIndexNum).collect(Collectors.toList());
|
||||||
Long bookId = newBookIndexList.get(0).getBookId();
|
Long bookId = newBookIndexList.get(0).getBookId();
|
||||||
@ -173,15 +185,15 @@ public class BookService {
|
|||||||
bookIndexMapper.insertBatch(newBookIndexList);
|
bookIndexMapper.insertBatch(newBookIndexList);
|
||||||
bookContentMapper.insertBatch(newContentList);
|
bookContentMapper.insertBatch(newContentList);
|
||||||
}
|
}
|
||||||
log.info("更新章节耗时:"+(System.currentTimeMillis()-start));
|
log.info("更新章节耗时:" + (System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成随机访问次数
|
* 生成随机访问次数
|
||||||
* */
|
*/
|
||||||
private Long generateVisitCount(Float score) {
|
private Long generateVisitCount(Float score) {
|
||||||
int baseNum = (int)(score * 100);
|
int baseNum = (int) (score * 100);
|
||||||
return Long.parseLong(baseNum + new Random().nextInt(1000) + "");
|
return Long.parseLong(baseNum + new Random().nextInt(1000) + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,10 +218,9 @@ public class BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询书籍的基础数据
|
* 查询书籍的基础数据
|
||||||
* */
|
*/
|
||||||
public Book queryBaseInfo(Long bookId) {
|
public Book queryBaseInfo(Long bookId) {
|
||||||
|
|
||||||
return bookMapper.selectByPrimaryKey(bookId);
|
return bookMapper.selectByPrimaryKey(bookId);
|
||||||
@ -217,7 +228,7 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询最新更新的书籍列表
|
* 查询最新更新的书籍列表
|
||||||
* */
|
*/
|
||||||
public List<BookIndex> queryNewIndexList(Long bookId) {
|
public List<BookIndex> queryNewIndexList(Long bookId) {
|
||||||
PageHelper.startPage(1, 15);
|
PageHelper.startPage(1, 15);
|
||||||
BookIndexExample example = new BookIndexExample();
|
BookIndexExample example = new BookIndexExample();
|
||||||
@ -229,7 +240,7 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询书籍目录列表
|
* 查询书籍目录列表
|
||||||
* */
|
*/
|
||||||
public List<BookIndex> queryAllIndexList(Long bookId) {
|
public List<BookIndex> queryAllIndexList(Long bookId) {
|
||||||
BookIndexExample example = new BookIndexExample();
|
BookIndexExample example = new BookIndexExample();
|
||||||
example.createCriteria().andBookIdEqualTo(bookId);
|
example.createCriteria().andBookIdEqualTo(bookId);
|
||||||
@ -239,7 +250,7 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询书籍章节内容
|
* 查询书籍章节内容
|
||||||
* */
|
*/
|
||||||
public BookContent queryBookContent(Long bookId, Integer indexNum) {
|
public BookContent queryBookContent(Long bookId, Integer indexNum) {
|
||||||
BookContent content = (BookContent) cacheUtil.getObject(CacheKeyConstans.BOOK_CONTENT_KEY_PREFIX + "_" + bookId + "_" + indexNum);
|
BookContent content = (BookContent) cacheUtil.getObject(CacheKeyConstans.BOOK_CONTENT_KEY_PREFIX + "_" + bookId + "_" + indexNum);
|
||||||
if (content == null) {
|
if (content == null) {
|
||||||
@ -256,12 +267,12 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加访问次数
|
* 增加访问次数
|
||||||
* */
|
*/
|
||||||
public void addVisitCount(Long bookId, String userId, Integer indexNum) {
|
public void addVisitCount(Long bookId, String userId, Integer indexNum) {
|
||||||
|
|
||||||
bookMapper.addVisitCount(bookId);
|
bookMapper.addVisitCount(bookId);
|
||||||
|
|
||||||
if(org.apache.commons.lang3.StringUtils.isNotBlank(userId)) {
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(userId)) {
|
||||||
userRefBookMapper.updateNewstIndex(bookId, userId, indexNum);
|
userRefBookMapper.updateNewstIndex(bookId, userId, indexNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,13 +280,13 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询章节名
|
* 查询章节名
|
||||||
* */
|
*/
|
||||||
public String queryIndexNameByBookIdAndIndexNum(Long bookId, Integer indexNum) {
|
public String queryIndexNameByBookIdAndIndexNum(Long bookId, Integer indexNum) {
|
||||||
|
|
||||||
BookIndexExample example = new BookIndexExample();
|
BookIndexExample example = new BookIndexExample();
|
||||||
example.createCriteria().andBookIdEqualTo(bookId).andIndexNumEqualTo(indexNum);
|
example.createCriteria().andBookIdEqualTo(bookId).andIndexNumEqualTo(indexNum);
|
||||||
List<BookIndex> indexList = bookIndexMapper.selectByExample(example);
|
List<BookIndex> indexList = bookIndexMapper.selectByExample(example);
|
||||||
if(indexList != null && indexList.size() > 0 ) {
|
if (indexList != null && indexList.size() > 0) {
|
||||||
return indexList.get(0).getIndexName();
|
return indexList.get(0).getIndexName();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -283,7 +294,7 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询最大和最小章节号
|
* 查询最大和最小章节号
|
||||||
* */
|
*/
|
||||||
public List<Integer> queryMaxAndMinIndexNum(Long bookId) {
|
public List<Integer> queryMaxAndMinIndexNum(Long bookId) {
|
||||||
List<Integer> result = new ArrayList<>();
|
List<Integer> result = new ArrayList<>();
|
||||||
BookIndexExample example = new BookIndexExample();
|
BookIndexExample example = new BookIndexExample();
|
||||||
@ -300,7 +311,7 @@ public class BookService {
|
|||||||
/**
|
/**
|
||||||
* 查询该书籍已存在目录号
|
* 查询该书籍已存在目录号
|
||||||
*/
|
*/
|
||||||
public Map<Integer,BookIndex> queryIndexByBookNameAndAuthor(String bookName, String author) {
|
public Map<Integer, BookIndex> queryIndexByBookNameAndAuthor(String bookName, String author) {
|
||||||
BookExample example = new BookExample();
|
BookExample example = new BookExample();
|
||||||
example.createCriteria().andBookNameEqualTo(bookName).andAuthorEqualTo(author);
|
example.createCriteria().andBookNameEqualTo(bookName).andAuthorEqualTo(author);
|
||||||
List<Book> books = bookMapper.selectByExample(example);
|
List<Book> books = bookMapper.selectByExample(example);
|
||||||
@ -310,7 +321,7 @@ public class BookService {
|
|||||||
BookIndexExample bookIndexExample = new BookIndexExample();
|
BookIndexExample bookIndexExample = new BookIndexExample();
|
||||||
bookIndexExample.createCriteria().andBookIdEqualTo(bookId);
|
bookIndexExample.createCriteria().andBookIdEqualTo(bookId);
|
||||||
List<BookIndex> bookIndices = bookIndexMapper.selectByExample(bookIndexExample);
|
List<BookIndex> bookIndices = bookIndexMapper.selectByExample(bookIndexExample);
|
||||||
if(bookIndices.size() > 0) {
|
if (bookIndices.size() > 0) {
|
||||||
return bookIndices.stream().collect(Collectors.toMap(BookIndex::getIndexNum, Function.identity()));
|
return bookIndices.stream().collect(Collectors.toMap(BookIndex::getIndexNum, Function.identity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,11 +332,9 @@ public class BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存弹幕
|
* 保存弹幕
|
||||||
* */
|
*/
|
||||||
public void sendBullet(Long contentId, String bullet) {
|
public void sendBullet(Long contentId, String bullet) {
|
||||||
|
|
||||||
ScreenBullet screenBullet = new ScreenBullet();
|
ScreenBullet screenBullet = new ScreenBullet();
|
||||||
@ -338,7 +347,7 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询弹幕
|
* 查询弹幕
|
||||||
* */
|
*/
|
||||||
public List<ScreenBullet> queryBullet(Long contentId) {
|
public List<ScreenBullet> queryBullet(Long contentId) {
|
||||||
|
|
||||||
ScreenBulletExample example = new ScreenBulletExample();
|
ScreenBulletExample example = new ScreenBulletExample();
|
||||||
@ -351,7 +360,7 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询章节内容
|
* 查询章节内容
|
||||||
* */
|
*/
|
||||||
public String queryContentList(Long bookId, int count) {
|
public String queryContentList(Long bookId, int count) {
|
||||||
BookContentExample example = new BookContentExample();
|
BookContentExample example = new BookContentExample();
|
||||||
example.createCriteria().andBookIdEqualTo(bookId).andIndexNumEqualTo(count);
|
example.createCriteria().andBookIdEqualTo(bookId).andIndexNumEqualTo(count);
|
||||||
@ -360,7 +369,7 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询章节数
|
* 查询章节数
|
||||||
* */
|
*/
|
||||||
public int countIndex(Long bookId) {
|
public int countIndex(Long bookId) {
|
||||||
BookIndexExample example = new BookIndexExample();
|
BookIndexExample example = new BookIndexExample();
|
||||||
example.createCriteria().andBookIdEqualTo(bookId);
|
example.createCriteria().andBookIdEqualTo(bookId);
|
||||||
@ -368,11 +377,9 @@ public class BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询前一章节和后一章节号
|
* 查询前一章节和后一章节号
|
||||||
* */
|
*/
|
||||||
public List<Integer> queryPreAndNextIndexNum(Long bookId, Integer indexNum) {
|
public List<Integer> queryPreAndNextIndexNum(Long bookId, Integer indexNum) {
|
||||||
List<Integer> result = new ArrayList<>();
|
List<Integer> result = new ArrayList<>();
|
||||||
BookIndexExample example = new BookIndexExample();
|
BookIndexExample example = new BookIndexExample();
|
||||||
@ -399,14 +406,14 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询推荐书籍数据
|
* 查询推荐书籍数据
|
||||||
* */
|
*/
|
||||||
public List<Book> queryRecBooks(List<Map<String, String>> configMap) {
|
public List<Book> queryRecBooks(List<Map<String, String>> configMap) {
|
||||||
return bookMapper.queryRecBooks(configMap);
|
return bookMapper.queryRecBooks(configMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清理数据库中无效数据
|
* 清理数据库中无效数据
|
||||||
* */
|
*/
|
||||||
public void clearInvilidData() {
|
public void clearInvilidData() {
|
||||||
|
|
||||||
//清除无效内容
|
//清除无效内容
|
||||||
@ -423,27 +430,28 @@ public class BookService {
|
|||||||
* 查询网络图片的小说
|
* 查询网络图片的小说
|
||||||
*
|
*
|
||||||
* @param limit
|
* @param limit
|
||||||
* @param offset*/
|
* @param offset
|
||||||
|
*/
|
||||||
public List<Book> queryNetworkPicBooks(Integer limit, Integer offset) {
|
public List<Book> queryNetworkPicBooks(Integer limit, Integer offset) {
|
||||||
return bookMapper.queryNetworkPicBooks(limit,offset);
|
return bookMapper.queryNetworkPicBooks(limit, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过图片名查询小说数量
|
* 通过图片名查询小说数量
|
||||||
* */
|
*/
|
||||||
public int countByPicName(String fileName) {
|
public int countByPicName(String fileName) {
|
||||||
BookExample bookExample = new BookExample();
|
BookExample bookExample = new BookExample();
|
||||||
bookExample.createCriteria().andPicUrlLike('%'+fileName+'%');
|
bookExample.createCriteria().andPicUrlLike('%' + fileName + '%');
|
||||||
return bookMapper.countByExample(bookExample);
|
return bookMapper.countByExample(bookExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加解析日志
|
* 添加解析日志
|
||||||
* */
|
*/
|
||||||
public void addBookParseLog(String bookUrl, String bookName, Float score, Byte priority) {
|
public void addBookParseLog(String bookUrl, String bookName, Float score, Byte priority) {
|
||||||
BookParseLogExample example = new BookParseLogExample();
|
BookParseLogExample example = new BookParseLogExample();
|
||||||
example.createCriteria().andBookUrlEqualTo(bookUrl).andCreateTimeGreaterThan(new Date(System.currentTimeMillis()-1000*60*60));
|
example.createCriteria().andBookUrlEqualTo(bookUrl).andCreateTimeGreaterThan(new Date(System.currentTimeMillis() - 1000 * 60 * 60));
|
||||||
if(bookParseLogMapper.countByExample(example)==0) {
|
if (bookParseLogMapper.countByExample(example) == 0) {
|
||||||
BookParseLog bookParseLog = new BookParseLog();
|
BookParseLog bookParseLog = new BookParseLog();
|
||||||
bookParseLog.setBookUrl(bookUrl);
|
bookParseLog.setBookUrl(bookUrl);
|
||||||
bookParseLog.setBookName(bookName);
|
bookParseLog.setBookName(bookName);
|
||||||
@ -456,16 +464,18 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询解析日志
|
* 查询解析日志
|
||||||
* */
|
*/
|
||||||
public List<BookParseLog> queryBookParseLogs() {
|
public List<BookParseLog> queryBookParseLogs() {
|
||||||
List<BookParseLog> logs = bookParseLogMapper.queryBookParseLogs();
|
List<BookParseLog> logs = bookParseLogMapper.queryBookParseLogs();
|
||||||
|
if(logs.size()>0) {
|
||||||
SpringUtil.getBean(BookService.class).addBookUpdateCount(logs);
|
SpringUtil.getBean(BookService.class).addBookUpdateCount(logs);
|
||||||
|
}
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加小说更新次数
|
* 增加小说更新次数
|
||||||
* */
|
*/
|
||||||
@Async
|
@Async
|
||||||
public void addBookUpdateCount(List<BookParseLog> logs) {
|
public void addBookUpdateCount(List<BookParseLog> logs) {
|
||||||
bookParseLogMapper.addBookUpdateCount(logs);
|
bookParseLogMapper.addBookUpdateCount(logs);
|
||||||
@ -473,9 +483,9 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除已经成功更新的解析日志
|
* 删除已经成功更新的解析日志
|
||||||
* */
|
*/
|
||||||
public void deleteBookParseLogs(List<Long> successLogIds) {
|
public void deleteBookParseLogs(List<Long> successLogIds) {
|
||||||
if(successLogIds.size()>0) {
|
if (successLogIds.size() > 0) {
|
||||||
BookParseLogExample example = new BookParseLogExample();
|
BookParseLogExample example = new BookParseLogExample();
|
||||||
example.createCriteria().andIdIn(successLogIds);
|
example.createCriteria().andIdIn(successLogIds);
|
||||||
bookParseLogMapper.deleteByExample(example);
|
bookParseLogMapper.deleteByExample(example);
|
||||||
@ -484,35 +494,35 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询书籍是否存在
|
* 查询书籍是否存在
|
||||||
* */
|
*/
|
||||||
public Boolean hasBook(String bookName, String author) {
|
public Boolean hasBook(String bookName, String author) {
|
||||||
BookExample example = new BookExample();
|
BookExample example = new BookExample();
|
||||||
example.createCriteria().andBookNameEqualTo(bookName).andAuthorEqualTo(author);
|
example.createCriteria().andBookNameEqualTo(bookName).andAuthorEqualTo(author);
|
||||||
return bookMapper.countByExample(example)>0;
|
return bookMapper.countByExample(example) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询分类更新时间映射信息
|
* 查询分类更新时间映射信息
|
||||||
* */
|
*/
|
||||||
public Map<Integer, Date> queryLastUpdateTime() {
|
public Map<Integer, Date> queryLastUpdateTime() {
|
||||||
List<BookUpdateTimeLog> list = bookUpdateTimeLogMapper.selectByExample(new BookUpdateTimeLogExample());
|
List<BookUpdateTimeLog> list = bookUpdateTimeLogMapper.selectByExample(new BookUpdateTimeLogExample());
|
||||||
|
|
||||||
return list.stream().collect(Collectors.toMap(BookUpdateTimeLog::getBookCatId, BookUpdateTimeLog::getLastUpdateTime,(key1, key2) -> key2));
|
return list.stream().collect(Collectors.toMap(BookUpdateTimeLog::getBookCatId, BookUpdateTimeLog::getLastUpdateTime, (key1, key2) -> key2));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新分类时间日志
|
* 更新分类时间日志
|
||||||
* */
|
*/
|
||||||
public void updateBookUpdateTimeLog(Map<Integer, Date> cat2Date) {
|
public void updateBookUpdateTimeLog(Map<Integer, Date> cat2Date) {
|
||||||
if(cat2Date.size()>0) {
|
if (cat2Date.size() > 0) {
|
||||||
Set<Map.Entry<Integer, Date>> entries = cat2Date.entrySet();
|
Set<Map.Entry<Integer, Date>> entries = cat2Date.entrySet();
|
||||||
for(Map.Entry<Integer, Date> entry : entries){
|
for (Map.Entry<Integer, Date> entry : entries) {
|
||||||
BookUpdateTimeLogExample example = new BookUpdateTimeLogExample();
|
BookUpdateTimeLogExample example = new BookUpdateTimeLogExample();
|
||||||
example.createCriteria().andBookCatIdEqualTo(entry.getKey());
|
example.createCriteria().andBookCatIdEqualTo(entry.getKey());
|
||||||
BookUpdateTimeLog entity = new BookUpdateTimeLog();
|
BookUpdateTimeLog entity = new BookUpdateTimeLog();
|
||||||
entity.setLastUpdateTime(entry.getValue());
|
entity.setLastUpdateTime(entry.getValue());
|
||||||
bookUpdateTimeLogMapper.updateByExampleSelective(entity,example);
|
bookUpdateTimeLogMapper.updateByExampleSelective(entity, example);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -520,7 +530,7 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除已经成功更新的解析日志
|
* 删除已经成功更新的解析日志
|
||||||
* */
|
*/
|
||||||
public void deleteBookParseLog(Long id) {
|
public void deleteBookParseLog(Long id) {
|
||||||
bookParseLogMapper.deleteByPrimaryKey(id);
|
bookParseLogMapper.deleteByPrimaryKey(id);
|
||||||
|
|
||||||
@ -528,13 +538,13 @@ public class BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据库书籍数量
|
* 查询数据库书籍数量
|
||||||
* */
|
*/
|
||||||
public int queryBookNumber() {
|
public int queryBookNumber() {
|
||||||
|
|
||||||
Integer bookNumber = (Integer) cacheUtil.getObject(CacheKeyConstans.BOOK_NUMBER_KEY);
|
Integer bookNumber = (Integer) cacheUtil.getObject(CacheKeyConstans.BOOK_NUMBER_KEY);
|
||||||
if(bookNumber == null){
|
if (bookNumber == null) {
|
||||||
bookNumber = bookMapper.countByExample(new BookExample());
|
bookNumber = bookMapper.countByExample(new BookExample());
|
||||||
cacheUtil.setObject(CacheKeyConstans.BOOK_NUMBER_KEY,bookNumber,60*5);
|
cacheUtil.setObject(CacheKeyConstans.BOOK_NUMBER_KEY, bookNumber, 60 * 5);
|
||||||
}
|
}
|
||||||
return bookNumber;
|
return bookNumber;
|
||||||
}
|
}
|
||||||
|
@ -86,3 +86,20 @@ biquge:
|
|||||||
intro-pattern: class="review">([^/]+)</p>
|
intro-pattern: class="review">([^/]+)</p>
|
||||||
catalog-url-pattern: <a\s+href="(/ddk\d+/all.html)">查看完整目录</a>
|
catalog-url-pattern: <a\s+href="(/ddk\d+/all.html)">查看完整目录</a>
|
||||||
catalog-pattern: <dd>\s*<a\s+href="(\d+\.html)"\s+title="([^"]+)">([^<]+)</a>\s*</dd>
|
catalog-pattern: <dd>\s*<a\s+href="(\d+\.html)"\s+title="([^"]+)">([^<]+)</a>\s*</dd>
|
||||||
|
|
||||||
|
|
||||||
|
biquwo:
|
||||||
|
crawlsource:
|
||||||
|
index-url: http://m.biquwo.net
|
||||||
|
list-page-url: http://m.biquwo.net/sort{0}/0/{1}.html
|
||||||
|
book-url-pattern: href="/(dudu/\d+/\d+)/"
|
||||||
|
score-pattern: <div\s+class="score">(\d+\.\d+)分</div>
|
||||||
|
book-name-pattern: <p class="title">([^/]+)</p>
|
||||||
|
author-pattern: 作者:([^/]+)<
|
||||||
|
status-pattern: 状态:([^/]+)</li>
|
||||||
|
cat-pattern: 类别:([^/]+)</li>
|
||||||
|
update-time-pattern: 更新:(\d+-\d+-\d+\s\d+:\d+:\d+)</a>
|
||||||
|
pic-pattern: <img src="([^>]+)"\s+onerror="this.src=
|
||||||
|
intro-pattern: class="review">([^<]+)</p>
|
||||||
|
catalog-url-pattern: <a\s+href="(/dudu/\d+/\d+/all\.html)">查看完整目录</a>
|
||||||
|
catalog-pattern: <a\s+style=""\s+href="(/dudu/\d+/\d+/\d+\.html)">([^/]+)</a>
|
@ -86,17 +86,17 @@ books:
|
|||||||
#爬取小说数量
|
#爬取小说数量
|
||||||
maxNum: 300000
|
maxNum: 300000
|
||||||
|
|
||||||
#爬取的网站名称类型 1:笔趣岛 ,2:笔趣塔,3:顶点小说 ,4:百书斋 更多网站解析中,敬请期待
|
#爬取的网站名称类型 1:笔趣岛 ,2:笔趣塔,3:顶点小说 ,4:百书斋,6: 笔趣窝 更多网站解析中,敬请期待
|
||||||
crawl:
|
crawl:
|
||||||
website:
|
website:
|
||||||
type: 4
|
type: 6
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pic:
|
pic:
|
||||||
save:
|
save:
|
||||||
type: 1 #图片保存方式, 1不保存,使用网络图片 ,2本地保存
|
type: 2 #图片保存方式, 1不保存,使用网络图片 ,2本地保存
|
||||||
path: /var/pic #图片保存路径
|
path: /var/pic #图片保存路径
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@ mybatis:
|
|||||||
mysql: {charset: utf8mb4}
|
mysql: {charset: utf8mb4}
|
||||||
books: {lowestScore: 6.0}
|
books: {lowestScore: 6.0}
|
||||||
crawl:
|
crawl:
|
||||||
website: {type: '4'}
|
patten: '1'
|
||||||
soft-novel: 0
|
website: {type: 6}
|
||||||
manhua: 0
|
soft-novel: '0'
|
||||||
|
manhua: '0'
|
||||||
logging: {config: 'classpath:logback-boot.xml'}
|
logging: {config: 'classpath:logback-boot.xml'}
|
||||||
|
Binary file not shown.
Reference in New Issue
Block a user