mirror of
https://github.com/201206030/novel-plus.git
synced 2025-07-01 15:26:37 +00:00
Compare commits
69 Commits
develop
...
release_v2
Author | SHA1 | Date | |
---|---|---|---|
70f04bd37c | |||
9d621edaec | |||
56c0a81c1b | |||
6b3b88c147 | |||
894ee67f56 | |||
a88891b72f | |||
5c7724c813 | |||
79c9f3e0f1 | |||
575142f9f3 | |||
83c2460c83 | |||
c7642ac2ef | |||
5af570a514 | |||
0d96ff81b6 | |||
7733cf1e3f | |||
c9c714e71e | |||
3cbb6bf3fb | |||
750e234f60 | |||
c1d485c42b | |||
0e2e6229cd | |||
f8a669eb01 | |||
6d56399d0f | |||
1a0c1f864b | |||
b193aca288 | |||
7a6d7a4442 | |||
5505840b6e | |||
8eb3048b91 | |||
1b138c2aad | |||
f5e2dbaa6b | |||
b6cb9aaedc | |||
f9f1e474ec | |||
06bf848e99 | |||
6e171d20ed | |||
c62acc288e | |||
9975faed01 | |||
8fde3a3725 | |||
430504ee28 | |||
16447c60ec | |||
be7cbe2d6f | |||
8f1ed88b07 | |||
9b9851e7ab | |||
a55edf0408 | |||
856c4c0667 | |||
e4dd5bcb71 | |||
5dbddbdd96 | |||
73be43e1c5 | |||
ce2a3b4647 | |||
68abdeca93 | |||
0b505a3922 | |||
353cb8c536 | |||
e1e1310b9e | |||
4c42ac0d29 | |||
d025d3d514 | |||
a0fb8e481a | |||
80b933db8d | |||
87a060280a | |||
9c78f400dc | |||
c2cdf73893 | |||
a13ea78c3f | |||
0144b77983 | |||
07b9ffde96 | |||
002a0723f7 | |||
8a628f081f | |||
4aa6b82143 | |||
c80b02caf0 | |||
5e16119880 | |||
231b94f1da | |||
92ce982899 | |||
8c2e43c04f | |||
f553d23fb9 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -14,3 +14,5 @@
|
|||||||
/*.iml
|
/*.iml
|
||||||
/novel-admin/*.iml
|
/novel-admin/*.iml
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/novel-admin/cachedata
|
||||||
|
/novel-admin/logs
|
||||||
|
100
README.md
100
README.md
@ -1,7 +1,15 @@
|
|||||||
[](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
|
# 小说精品屋-plus
|
||||||
|
|
||||||
|
#### 新项目:小说精品屋-微服务版
|
||||||
|
|
||||||
|
基于小说精品屋-plus构建的Spring Cloud 微服务小说门户平台。
|
||||||
|
|
||||||
|
Gitee仓库地址: https://gitee.com/xiongxyang/novel-cloud
|
||||||
|
|
||||||
|
GitHub仓库地址: https://github.com/201206030/novel-cloud
|
||||||
|
|
||||||
#### 演示地址
|
#### 演示地址
|
||||||
|
|
||||||
[点击前往](http://www.java2nb.com)(前台门户)
|
[点击前往](http://www.java2nb.com)(前台门户)
|
||||||
@ -40,53 +48,109 @@ novel-plus -- 父工程
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### 技术选型
|
#### 技术选型
|
||||||
Springboot+Mybatis+Mysql+Ehcache+Thymeleaf+Layui
|
|
||||||
|
| 技术 | 说明
|
||||||
|
| -------------------- | ---------------------------
|
||||||
|
| SpringBoot | Spring应用快速开发脚手架
|
||||||
|
| MyBatis | 持久层ORM框架
|
||||||
|
| MyBatis Dynamic SQL | Mybatis动态sql
|
||||||
|
| PageHelper | MyBatis分页插件
|
||||||
|
| MyBatisGenerator | 持久层代码生成插件
|
||||||
|
| Sharding-Jdbc | 代码层分库分表中间件
|
||||||
|
| JJWT | JWT登录支持
|
||||||
|
| SpringSecurity | 安全框架
|
||||||
|
| Shiro | 安全框架
|
||||||
|
| Ehcache | Java进程内缓存框架(默认缓存)
|
||||||
|
| Redis | 分布式缓存(缓存替换方案,默认关闭,一行配置开启)
|
||||||
|
| ElasticSearch | 搜索引擎(搜索增强方案,默认关闭,一行配置开启)
|
||||||
|
| RabbitMq | 消息队列(流量削峰,默认关闭,一行配置开启)
|
||||||
|
| OSS | 阿里云对象存储服务(图片存储方式之一,一行配置即可切换)
|
||||||
|
| FastDfs |开源轻量级分布式文件系统(图片存储方式之一,一行配置即可切换)
|
||||||
|
| Redisson | 实现分布式锁
|
||||||
|
| Lombok | 简化对象封装工具
|
||||||
|
| Docker | 应用容器引擎
|
||||||
|
| Mysql | 数据库服务
|
||||||
|
| Thymeleaf | 模板引擎
|
||||||
|
| Layui | 前端UI
|
||||||
|
|
||||||
|
|
||||||
#### PC站截图
|
#### PC站截图
|
||||||
|
|
||||||
|
1. 首页
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||

|
2. 分类索引页
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
3. 搜索页
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
4. 排行榜
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
5. 详情页
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
6. 阅读页
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
7. 用户中心
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
8. 充值
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
9. 作家专区
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
10. 购买
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
#### 手机站截图
|
#### 手机站截图
|
||||||
|
|
||||||
1. 首页
|
1. 首页
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2. 小说详情页
|
2. 小说详情页
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
3. 目录页
|
3. 目录页
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
4. 小说阅读页
|
4. 小说阅读页
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### 爬虫管理系统截图
|
#### 爬虫管理系统截图
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
#### 后台管理系统截图
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
#### 安装步骤
|
#### 安装步骤
|
||||||
|
|
||||||
@ -127,7 +191,7 @@ docker安装教程:[点击前往](https://my.oschina.net/java2nb/blog/4271989)
|
|||||||
|
|
||||||
#### QQ交流群
|
#### QQ交流群
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
#### 捐赠支持
|
#### 捐赠支持
|
||||||
|
|
||||||
@ -139,4 +203,4 @@ docker安装教程:[点击前往](https://my.oschina.net/java2nb/blog/4271989)
|
|||||||
|
|
||||||
精品小说屋所有相关项目均已在开源中国公开,感兴趣的可进入[开源中国](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 )
|
BIN
assets/QQ20200520-215756.png
Normal file
BIN
assets/QQ20200520-215756.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 105 KiB |
Binary file not shown.
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 62 KiB |
Binary file not shown.
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 185 KiB |
82
es/index_create.txt
Normal file
82
es/index_create.txt
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
PUT /novel
|
||||||
|
{
|
||||||
|
"mappings" : {
|
||||||
|
"book" : {
|
||||||
|
"properties" : {
|
||||||
|
"id" : {
|
||||||
|
"type" : "long"
|
||||||
|
},
|
||||||
|
"authorId" : {
|
||||||
|
"type" : "long"
|
||||||
|
},
|
||||||
|
"authorName" : {
|
||||||
|
"type" : "text",
|
||||||
|
"analyzer": "ik_smart",
|
||||||
|
"boost": 1.9
|
||||||
|
},
|
||||||
|
|
||||||
|
"bookName" : {
|
||||||
|
"type" : "text",
|
||||||
|
"analyzer": "ik_smart",
|
||||||
|
"boost": 2
|
||||||
|
},
|
||||||
|
|
||||||
|
"bookDesc" : {
|
||||||
|
"type" : "text",
|
||||||
|
"analyzer": "ik_smart",
|
||||||
|
"boost": 0.1
|
||||||
|
},
|
||||||
|
|
||||||
|
"bookStatus" : {
|
||||||
|
"type" : "short"
|
||||||
|
},
|
||||||
|
|
||||||
|
"catId" : {
|
||||||
|
"type" : "integer"
|
||||||
|
},
|
||||||
|
|
||||||
|
"catName" : {
|
||||||
|
"type" : "text",
|
||||||
|
"analyzer": "ik_smart",
|
||||||
|
"boost": 1.0
|
||||||
|
},
|
||||||
|
|
||||||
|
"lastIndexId" : {
|
||||||
|
"type" : "long"
|
||||||
|
},
|
||||||
|
|
||||||
|
"lastIndexName" : {
|
||||||
|
"type" : "text",
|
||||||
|
"analyzer": "ik_smart",
|
||||||
|
"boost": 0.1
|
||||||
|
},
|
||||||
|
|
||||||
|
"lastIndexUpdateTime" : {
|
||||||
|
"type": "keyword"
|
||||||
|
},
|
||||||
|
|
||||||
|
"picUrl" : {
|
||||||
|
"type" : "keyword"
|
||||||
|
},
|
||||||
|
|
||||||
|
"score" : {
|
||||||
|
"type" : "float"
|
||||||
|
},
|
||||||
|
|
||||||
|
"wordCount" : {
|
||||||
|
"type" : "integer"
|
||||||
|
},
|
||||||
|
|
||||||
|
"workDirection" : {
|
||||||
|
"type" : "short"
|
||||||
|
},
|
||||||
|
|
||||||
|
"visitCount" : {
|
||||||
|
"type": "long"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
6
novel-admin/Dockerfile
Normal file
6
novel-admin/Dockerfile
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
FROM java:8
|
||||||
|
ADD novel-admin-1.0.0.jar /root
|
||||||
|
ENV dburl=""
|
||||||
|
ENV username=""
|
||||||
|
ENV password=""
|
||||||
|
ENTRYPOINT ["sh","-c","java -Dspring.datasource.url=${dburl} -Dspring.datasource.username=${username} -Dspring.datasource.password=${password} -jar /root/novel-admin-1.0.0.jar"]
|
@ -1,5 +0,0 @@
|
|||||||
2020-05-13 21:52:00,972 INFO (StartupInfoLogger.java:50)- Starting TestDemo on USER-20180729KA with PID 3532 (started by Administrator in E:\baseprojectparent\novel-plus\novel-admin)
|
|
||||||
2020-05-13 21:52:01,113 DEBUG (StartupInfoLogger.java:53)- Running with Spring Boot v2.0.1.RELEASE, Spring v5.0.5.RELEASE
|
|
||||||
2020-05-13 21:52:01,131 INFO (SpringApplication.java:663)- The following profiles are active: dev
|
|
||||||
2020-05-13 21:52:54,469 DEBUG (ApplicationContextRegister.java:29)- ApplicationContext registed-->org.springframework.web.context.support.GenericWebApplicationContext@5b529706: startup date [Wed May 13 21:52:01 CST 2020]; root of context hierarchy
|
|
||||||
2020-05-13 21:53:49,622 INFO (StartupInfoLogger.java:59)- Started TestDemo in 114.268 seconds (JVM running for 124.957)
|
|
@ -137,10 +137,6 @@
|
|||||||
<artifactId>velocity</artifactId>
|
<artifactId>velocity</artifactId>
|
||||||
<version>1.7</version>
|
<version>1.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-cache</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!--<dependency>-->
|
<!--<dependency>-->
|
||||||
<!--<groupId>org.springframework.boot</groupId>-->
|
<!--<groupId>org.springframework.boot</groupId>-->
|
||||||
<!--<artifactId>spring-boot-starter-data-redis</artifactId>-->
|
<!--<artifactId>spring-boot-starter-data-redis</artifactId>-->
|
||||||
|
@ -12,7 +12,7 @@ spring:
|
|||||||
driverClassName: com.mysql.jdbc.Driver
|
driverClassName: com.mysql.jdbc.Driver
|
||||||
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
|
||||||
username: root
|
username: root
|
||||||
password:
|
password: test123456
|
||||||
#password:
|
#password:
|
||||||
initialSize: 1
|
initialSize: 1
|
||||||
minIdle: 3
|
minIdle: 3
|
||||||
|
File diff suppressed because one or more lines are too long
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>novel</artifactId>
|
<artifactId>novel</artifactId>
|
||||||
<groupId>com.java2nb</groupId>
|
<groupId>com.java2nb</groupId>
|
||||||
<version>2.0.1</version>
|
<version>2.6.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -31,11 +31,20 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-cache</artifactId>
|
<artifactId>spring-boot-starter-cache</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--ehcache-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.sf.ehcache</groupId>
|
<groupId>net.sf.ehcache</groupId>
|
||||||
<artifactId>ehcache</artifactId>
|
<artifactId>ehcache</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--集成redis-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-redis</artifactId>
|
||||||
|
<version>${redis.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--mysql驱动-->
|
<!--mysql驱动-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
@ -48,6 +57,22 @@
|
|||||||
<version>${mybatis.version}</version>
|
<version>${mybatis.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 分库分表-->
|
||||||
|
<!-- sharding jdbc依赖 -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.shardingsphere</groupId>
|
||||||
|
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
|
||||||
|
<version>${sharding.jdbc.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.shardingsphere</groupId>
|
||||||
|
<artifactId>sharding-jdbc-spring-namespace</artifactId>
|
||||||
|
<version>${sharding.jdbc.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!--分页助手启动器-->
|
<!--分页助手启动器-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.pagehelper</groupId>
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
@ -46,4 +46,23 @@ public interface CacheKey {
|
|||||||
* */
|
* */
|
||||||
String RUNNING_CRAWL_THREAD_KEY_PREFIX = "runningCrawlTreadDataKeyPrefix";
|
String RUNNING_CRAWL_THREAD_KEY_PREFIX = "runningCrawlTreadDataKeyPrefix";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上一次搜索引擎更新的时间
|
||||||
|
* */
|
||||||
|
String ES_LAST_UPDATE_TIME = "esLastUpdateTime";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索引擎转换锁
|
||||||
|
* */
|
||||||
|
String ES_TRANS_LOCK = "esTransLock";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上一次搜索引擎是否更新过小说点击量
|
||||||
|
* */
|
||||||
|
String ES_IS_UPDATE_VISIT = "esIsUpdateVisit";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累积的小说点击量
|
||||||
|
* */
|
||||||
|
String BOOK_ADD_VISIT_COUNT = "bookAddVisitCount";
|
||||||
}
|
}
|
@ -51,9 +51,5 @@ public interface CacheService {
|
|||||||
* */
|
* */
|
||||||
void expire(String key, long timeout);
|
void expire(String key, long timeout);
|
||||||
|
|
||||||
/**
|
|
||||||
* 刷新缓存
|
|
||||||
* */
|
|
||||||
void refresh(String key);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,25 @@
|
|||||||
package com.java2nb.novel.core.cache.impl;
|
package com.java2nb.novel.core.cache.impl;
|
||||||
|
|
||||||
import com.java2nb.novel.core.cache.CacheService;
|
import com.java2nb.novel.core.cache.CacheService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.sf.ehcache.Cache;
|
import net.sf.ehcache.Cache;
|
||||||
import net.sf.ehcache.CacheManager;
|
import net.sf.ehcache.CacheManager;
|
||||||
import net.sf.ehcache.Element;
|
import net.sf.ehcache.Element;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xxy
|
* @author xxy
|
||||||
*/
|
*/
|
||||||
|
@ConditionalOnProperty(prefix = "cache", name = "type", havingValue = "ehcache")
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class EhCacheServiceImpl implements CacheService {
|
public class EhCacheServiceImpl implements CacheService {
|
||||||
|
|
||||||
@Autowired
|
private final CacheManager cacheManager ;
|
||||||
private CacheManager cacheManager ;
|
|
||||||
|
|
||||||
private static final String CACHE_NAME = "utilCache";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得一个Cache,没有则创建一个。
|
* 获得一个Cache,没有则创建一个。
|
||||||
* @return
|
* @return
|
||||||
@ -30,14 +31,6 @@ public class EhCacheServiceImpl implements CacheService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CacheManager getCacheManager() {
|
|
||||||
return cacheManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(String key) {
|
public String get(String key) {
|
||||||
Element element = getCache().get(key);
|
Element element = getCache().get(key);
|
||||||
@ -125,20 +118,6 @@ public class EhCacheServiceImpl implements CacheService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void refresh(String key) {
|
|
||||||
Element element = getCache().get(key);
|
|
||||||
if (element != null) {
|
|
||||||
Object value = element.getValue();
|
|
||||||
int timeToLive = element.getTimeToLive();
|
|
||||||
element = new Element(key, value);
|
|
||||||
element.setTimeToLive(timeToLive);
|
|
||||||
Cache cache = getCache();
|
|
||||||
cache.put(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
73
novel-common/src/main/java/com/java2nb/novel/core/cache/impl/RedisServiceImpl.java
vendored
Normal file
73
novel-common/src/main/java/com/java2nb/novel/core/cache/impl/RedisServiceImpl.java
vendored
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package com.java2nb.novel.core.cache.impl;
|
||||||
|
|
||||||
|
import com.java2nb.novel.core.cache.CacheService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xxy
|
||||||
|
*/
|
||||||
|
@ConditionalOnProperty(prefix = "cache", name = "type", havingValue = "redis")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class RedisServiceImpl implements CacheService {
|
||||||
|
|
||||||
|
private final StringRedisTemplate stringRedisTemplate;
|
||||||
|
|
||||||
|
private final RedisTemplate<Object, Object> redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get(String key) {
|
||||||
|
return stringRedisTemplate.opsForValue().get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(String key, String value) {
|
||||||
|
stringRedisTemplate.opsForValue().set(key,value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(String key, String value, long timeout) {
|
||||||
|
stringRedisTemplate.opsForValue().set(key,value,timeout, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getObject(String key) {
|
||||||
|
return redisTemplate.opsForValue().get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setObject(String key, Object value) {
|
||||||
|
redisTemplate.opsForValue().set(key,value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setObject(String key, Object value, long timeout) {
|
||||||
|
redisTemplate.opsForValue().set(key,value,timeout, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void del(String key) {
|
||||||
|
redisTemplate.delete(key);
|
||||||
|
stringRedisTemplate.delete(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(String key) {
|
||||||
|
return redisTemplate.hasKey(key) || stringRedisTemplate.hasKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void expire(String key, long timeout) {
|
||||||
|
redisTemplate.expire(key,timeout, TimeUnit.SECONDS);
|
||||||
|
stringRedisTemplate.expire(key,timeout, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -55,9 +55,18 @@ public enum ResponseStatus {
|
|||||||
* */
|
* */
|
||||||
INVITE_CODE_INVALID(4001, "邀请码无效!"),
|
INVITE_CODE_INVALID(4001, "邀请码无效!"),
|
||||||
AUTHOR_STATUS_FORBIDDEN(4002, "作者状态异常,暂不能管理小说!")
|
AUTHOR_STATUS_FORBIDDEN(4002, "作者状态异常,暂不能管理小说!")
|
||||||
, BOOKNAME_EXISTS(4003,"已发布过同名小说!")
|
, BOOKNAME_EXISTS(4003,"已发布过同名小说!"),
|
||||||
|
|
||||||
,
|
/**
|
||||||
|
* 小说相关错误
|
||||||
|
*/
|
||||||
|
BOOK_EXISTS(5001,"该小说已存在")
|
||||||
|
|
||||||
|
,
|
||||||
|
/**
|
||||||
|
* 搜索引擎相关错误
|
||||||
|
* */
|
||||||
|
ES_SEARCH_FAIL(9001,"搜索引擎查询错误!"),
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.java2nb.novel.core.utils;
|
package com.java2nb.novel.core.utils;
|
||||||
|
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.codec.Charsets;
|
import org.apache.commons.codec.Charsets;
|
||||||
import org.apache.http.client.utils.DateUtils;
|
import org.apache.http.client.utils.DateUtils;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
@ -9,6 +10,7 @@ import org.springframework.http.HttpHeaders;
|
|||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -17,34 +19,65 @@ import java.util.Objects;
|
|||||||
* 文件操作工具类
|
* 文件操作工具类
|
||||||
* @author 11797
|
* @author 11797
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class FileUtil {
|
public class FileUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网络图片转本地
|
* 网络图片转本地
|
||||||
* */
|
* */
|
||||||
@SneakyThrows
|
|
||||||
public static String network2Local(String picSrc,String picSavePath,String visitPrefix) {
|
public static String network2Local(String picSrc,String picSavePath,String visitPrefix) {
|
||||||
//本地图片保存
|
InputStream input = null;
|
||||||
HttpHeaders headers = new HttpHeaders();
|
OutputStream out = null;
|
||||||
HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
|
try {
|
||||||
ResponseEntity<Resource> resEntity = RestTemplateUtil.getInstance(Charsets.ISO_8859_1.name()).exchange(picSrc, HttpMethod.GET, requestEntity, Resource.class);
|
//本地图片保存
|
||||||
InputStream input = Objects.requireNonNull(resEntity.getBody()).getInputStream();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
Date currentDate = new Date();
|
HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
|
||||||
picSrc = visitPrefix + DateUtils.formatDate(currentDate, "yyyy") + "/" + DateUtils.formatDate(currentDate, "MM") + "/" + DateUtils.formatDate(currentDate, "dd") + "/"
|
ResponseEntity<Resource> resEntity = RestTemplateUtil.getInstance(Charsets.ISO_8859_1.name()).exchange(picSrc, HttpMethod.GET, requestEntity, Resource.class);
|
||||||
+ UUIDUtil.getUUID32()
|
input = Objects.requireNonNull(resEntity.getBody()).getInputStream();
|
||||||
+ picSrc.substring(picSrc.lastIndexOf("."));
|
Date currentDate = new Date();
|
||||||
File picFile = new File(picSavePath + picSrc);
|
picSrc = visitPrefix + DateUtils.formatDate(currentDate, "yyyy") + "/" + DateUtils.formatDate(currentDate, "MM") + "/" + DateUtils.formatDate(currentDate, "dd") + "/"
|
||||||
File parentFile = picFile.getParentFile();
|
+ UUIDUtil.getUUID32()
|
||||||
if (!parentFile.exists()) {
|
+ picSrc.substring(picSrc.lastIndexOf("."));
|
||||||
parentFile.mkdirs();
|
File picFile = new File(picSavePath + picSrc);
|
||||||
|
File parentFile = picFile.getParentFile();
|
||||||
|
if (!parentFile.exists()) {
|
||||||
|
parentFile.mkdirs();
|
||||||
|
}
|
||||||
|
out = new FileOutputStream(picFile);
|
||||||
|
byte[] b = new byte[4096];
|
||||||
|
for (int n; (n = input.read(b)) != -1; ) {
|
||||||
|
out.write(b, 0, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
out.flush();
|
||||||
|
if( ImageIO.read(picFile) == null){
|
||||||
|
picSrc = "/images/default.gif";
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
|
||||||
|
picSrc = "/images/default.gif";
|
||||||
|
}finally {
|
||||||
|
if(input != null){
|
||||||
|
try {
|
||||||
|
input.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}finally {
|
||||||
|
if(out != null){
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
OutputStream out = new FileOutputStream(picFile);
|
|
||||||
byte[] b = new byte[4096];
|
|
||||||
for (int n; (n = input.read(b)) != -1; ) {
|
|
||||||
out.write(b, 0, n);
|
|
||||||
}
|
|
||||||
out.close();
|
|
||||||
input.close();
|
|
||||||
return picSrc;
|
return picSrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class RestTemplateUtil {
|
|||||||
requestFactory.setHttpClient(httpClient);
|
requestFactory.setHttpClient(httpClient);
|
||||||
requestFactory.setConnectionRequestTimeout(3000);
|
requestFactory.setConnectionRequestTimeout(3000);
|
||||||
requestFactory.setConnectTimeout(3000);
|
requestFactory.setConnectTimeout(3000);
|
||||||
requestFactory.setReadTimeout(10000);
|
requestFactory.setReadTimeout(30000);
|
||||||
RestTemplate restTemplate = new RestTemplate(requestFactory);
|
RestTemplate restTemplate = new RestTemplate(requestFactory);
|
||||||
List<HttpMessageConverter<?>> list = restTemplate.getMessageConverters();
|
List<HttpMessageConverter<?>> list = restTemplate.getMessageConverters();
|
||||||
for (HttpMessageConverter<?> httpMessageConverter : list) {
|
for (HttpMessageConverter<?> httpMessageConverter : list) {
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
package com.java2nb.novel.core.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiongxiaoyang
|
||||||
|
*/
|
||||||
|
public class StringUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将驼峰式命名的字符串转换为下划线大写方式。如果转换前的驼峰式命名的字符串为空,则返回空字符串。</br>
|
||||||
|
* 例如:HelloWorld->HELLO_WORLD
|
||||||
|
* @param name 转换前的驼峰式命名的字符串
|
||||||
|
* @return 转换后下划线大写方式命名的字符串
|
||||||
|
*/
|
||||||
|
public static String underscoreName(String name) {
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
if (name != null && name.length() > 0) {
|
||||||
|
// 将第一个字符处理成大写
|
||||||
|
result.append(name.substring(0, 1).toUpperCase());
|
||||||
|
// 循环处理其余字符
|
||||||
|
for (int i = 1; i < name.length(); i++) {
|
||||||
|
String s = name.substring(i, i + 1);
|
||||||
|
// 在大写字母前添加下划线
|
||||||
|
if (s.equals(s.toUpperCase()) && !Character.isDigit(s.charAt(0))) {
|
||||||
|
result.append("_");
|
||||||
|
}
|
||||||
|
// 其他字符直接转成大写
|
||||||
|
result.append(s.toUpperCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
|
||||||
|
* 例如:HELLO_WORLD->HelloWorld
|
||||||
|
* @param name 转换前的下划线大写方式命名的字符串
|
||||||
|
* @return 转换后的驼峰式命名的字符串
|
||||||
|
*/
|
||||||
|
public static String camelName(String name) {
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
// 快速检查
|
||||||
|
if (name == null || name.isEmpty()) {
|
||||||
|
// 没必要转换
|
||||||
|
return "";
|
||||||
|
} else if (!name.contains("_")) {
|
||||||
|
// 不含下划线,仅将首字母小写
|
||||||
|
return name.substring(0, 1).toLowerCase() + name.substring(1);
|
||||||
|
}
|
||||||
|
// 用下划线将原始字符串分割
|
||||||
|
String camels[] = name.split("_");
|
||||||
|
for (String camel : camels) {
|
||||||
|
// 跳过原始字符串中开头、结尾的下换线或双重下划线
|
||||||
|
if (camel.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 处理真正的驼峰片段
|
||||||
|
if (result.length() == 0) {
|
||||||
|
// 第一个驼峰片段,全部字母都小写
|
||||||
|
result.append(camel.toLowerCase());
|
||||||
|
} else {
|
||||||
|
// 其他的驼峰片段,首字母大写
|
||||||
|
result.append(camel.substring(0, 1).toUpperCase());
|
||||||
|
result.append(camel.substring(1).toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -10,9 +10,21 @@ public class CrawlSingleTask {
|
|||||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
private Integer sourceId;
|
private Integer sourceId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private String sourceName;
|
||||||
|
|
||||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
private String sourceBookId;
|
private String sourceBookId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Integer catId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private String bookName;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private String authorName;
|
||||||
|
|
||||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
private Byte taskStatus;
|
private Byte taskStatus;
|
||||||
|
|
||||||
@ -42,6 +54,16 @@ public class CrawlSingleTask {
|
|||||||
this.sourceId = sourceId;
|
this.sourceId = sourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public String getSourceName() {
|
||||||
|
return sourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setSourceName(String sourceName) {
|
||||||
|
this.sourceName = sourceName == null ? null : sourceName.trim();
|
||||||
|
}
|
||||||
|
|
||||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
public String getSourceBookId() {
|
public String getSourceBookId() {
|
||||||
return sourceBookId;
|
return sourceBookId;
|
||||||
@ -52,6 +74,36 @@ public class CrawlSingleTask {
|
|||||||
this.sourceBookId = sourceBookId == null ? null : sourceBookId.trim();
|
this.sourceBookId = sourceBookId == null ? null : sourceBookId.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Integer getCatId() {
|
||||||
|
return catId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setCatId(Integer catId) {
|
||||||
|
this.catId = catId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public String getBookName() {
|
||||||
|
return bookName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setBookName(String bookName) {
|
||||||
|
this.bookName = bookName == null ? null : bookName.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public String getAuthorName() {
|
||||||
|
return authorName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setAuthorName(String authorName) {
|
||||||
|
this.authorName = authorName == null ? null : authorName.trim();
|
||||||
|
}
|
||||||
|
|
||||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
public Byte getTaskStatus() {
|
public Byte getTaskStatus() {
|
||||||
return taskStatus;
|
return taskStatus;
|
||||||
|
@ -24,7 +24,7 @@ public final class BookContentDynamicSqlSupport {
|
|||||||
|
|
||||||
public final SqlColumn<Long> indexId = column("index_id", JDBCType.BIGINT);
|
public final SqlColumn<Long> indexId = column("index_id", JDBCType.BIGINT);
|
||||||
|
|
||||||
public final SqlColumn<String> content = column("content", JDBCType.LONGVARCHAR);
|
public final SqlColumn<String> content = column("content", JDBCType.VARCHAR);
|
||||||
|
|
||||||
public BookContent() {
|
public BookContent() {
|
||||||
super("book_content");
|
super("book_content");
|
||||||
|
@ -63,7 +63,7 @@ public interface BookContentMapper {
|
|||||||
@Results(id="BookContentResult", value = {
|
@Results(id="BookContentResult", value = {
|
||||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
||||||
@Result(column="index_id", property="indexId", jdbcType=JdbcType.BIGINT),
|
@Result(column="index_id", property="indexId", jdbcType=JdbcType.BIGINT),
|
||||||
@Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
|
@Result(column="content", property="content", jdbcType=JdbcType.VARCHAR)
|
||||||
})
|
})
|
||||||
List<BookContent> selectMany(SelectStatementProvider selectStatement);
|
List<BookContent> selectMany(SelectStatementProvider selectStatement);
|
||||||
|
|
||||||
|
@ -16,9 +16,21 @@ public final class CrawlSingleTaskDynamicSqlSupport {
|
|||||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
public static final SqlColumn<Integer> sourceId = crawlSingleTask.sourceId;
|
public static final SqlColumn<Integer> sourceId = crawlSingleTask.sourceId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<String> sourceName = crawlSingleTask.sourceName;
|
||||||
|
|
||||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
public static final SqlColumn<String> sourceBookId = crawlSingleTask.sourceBookId;
|
public static final SqlColumn<String> sourceBookId = crawlSingleTask.sourceBookId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Integer> catId = crawlSingleTask.catId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<String> bookName = crawlSingleTask.bookName;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<String> authorName = crawlSingleTask.authorName;
|
||||||
|
|
||||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
public static final SqlColumn<Byte> taskStatus = crawlSingleTask.taskStatus;
|
public static final SqlColumn<Byte> taskStatus = crawlSingleTask.taskStatus;
|
||||||
|
|
||||||
@ -34,8 +46,16 @@ public final class CrawlSingleTaskDynamicSqlSupport {
|
|||||||
|
|
||||||
public final SqlColumn<Integer> sourceId = column("source_id", JDBCType.INTEGER);
|
public final SqlColumn<Integer> sourceId = column("source_id", JDBCType.INTEGER);
|
||||||
|
|
||||||
|
public final SqlColumn<String> sourceName = column("source_name", JDBCType.VARCHAR);
|
||||||
|
|
||||||
public final SqlColumn<String> sourceBookId = column("source_book_id", JDBCType.VARCHAR);
|
public final SqlColumn<String> sourceBookId = column("source_book_id", JDBCType.VARCHAR);
|
||||||
|
|
||||||
|
public final SqlColumn<Integer> catId = column("cat_id", JDBCType.INTEGER);
|
||||||
|
|
||||||
|
public final SqlColumn<String> bookName = column("book_name", JDBCType.VARCHAR);
|
||||||
|
|
||||||
|
public final SqlColumn<String> authorName = column("author_name", JDBCType.VARCHAR);
|
||||||
|
|
||||||
public final SqlColumn<Byte> taskStatus = column("task_status", JDBCType.TINYINT);
|
public final SqlColumn<Byte> taskStatus = column("task_status", JDBCType.TINYINT);
|
||||||
|
|
||||||
public final SqlColumn<Byte> excCount = column("exc_count", JDBCType.TINYINT);
|
public final SqlColumn<Byte> excCount = column("exc_count", JDBCType.TINYINT);
|
||||||
|
@ -35,7 +35,7 @@ import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface CrawlSingleTaskMapper {
|
public interface CrawlSingleTaskMapper {
|
||||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
BasicColumn[] selectList = BasicColumn.columnList(id, sourceId, sourceBookId, taskStatus, excCount, createTime);
|
BasicColumn[] selectList = BasicColumn.columnList(id, sourceId, sourceName, sourceBookId, catId, bookName, authorName, taskStatus, excCount, createTime);
|
||||||
|
|
||||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||||
@ -63,7 +63,11 @@ public interface CrawlSingleTaskMapper {
|
|||||||
@Results(id="CrawlSingleTaskResult", value = {
|
@Results(id="CrawlSingleTaskResult", value = {
|
||||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
||||||
@Result(column="source_id", property="sourceId", jdbcType=JdbcType.INTEGER),
|
@Result(column="source_id", property="sourceId", jdbcType=JdbcType.INTEGER),
|
||||||
|
@Result(column="source_name", property="sourceName", jdbcType=JdbcType.VARCHAR),
|
||||||
@Result(column="source_book_id", property="sourceBookId", jdbcType=JdbcType.VARCHAR),
|
@Result(column="source_book_id", property="sourceBookId", jdbcType=JdbcType.VARCHAR),
|
||||||
|
@Result(column="cat_id", property="catId", jdbcType=JdbcType.INTEGER),
|
||||||
|
@Result(column="book_name", property="bookName", jdbcType=JdbcType.VARCHAR),
|
||||||
|
@Result(column="author_name", property="authorName", jdbcType=JdbcType.VARCHAR),
|
||||||
@Result(column="task_status", property="taskStatus", jdbcType=JdbcType.TINYINT),
|
@Result(column="task_status", property="taskStatus", jdbcType=JdbcType.TINYINT),
|
||||||
@Result(column="exc_count", property="excCount", jdbcType=JdbcType.TINYINT),
|
@Result(column="exc_count", property="excCount", jdbcType=JdbcType.TINYINT),
|
||||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
|
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
|
||||||
@ -96,7 +100,11 @@ public interface CrawlSingleTaskMapper {
|
|||||||
return MyBatis3Utils.insert(this::insert, record, crawlSingleTask, c ->
|
return MyBatis3Utils.insert(this::insert, record, crawlSingleTask, c ->
|
||||||
c.map(id).toProperty("id")
|
c.map(id).toProperty("id")
|
||||||
.map(sourceId).toProperty("sourceId")
|
.map(sourceId).toProperty("sourceId")
|
||||||
|
.map(sourceName).toProperty("sourceName")
|
||||||
.map(sourceBookId).toProperty("sourceBookId")
|
.map(sourceBookId).toProperty("sourceBookId")
|
||||||
|
.map(catId).toProperty("catId")
|
||||||
|
.map(bookName).toProperty("bookName")
|
||||||
|
.map(authorName).toProperty("authorName")
|
||||||
.map(taskStatus).toProperty("taskStatus")
|
.map(taskStatus).toProperty("taskStatus")
|
||||||
.map(excCount).toProperty("excCount")
|
.map(excCount).toProperty("excCount")
|
||||||
.map(createTime).toProperty("createTime")
|
.map(createTime).toProperty("createTime")
|
||||||
@ -108,7 +116,11 @@ public interface CrawlSingleTaskMapper {
|
|||||||
return MyBatis3Utils.insertMultiple(this::insertMultiple, records, crawlSingleTask, c ->
|
return MyBatis3Utils.insertMultiple(this::insertMultiple, records, crawlSingleTask, c ->
|
||||||
c.map(id).toProperty("id")
|
c.map(id).toProperty("id")
|
||||||
.map(sourceId).toProperty("sourceId")
|
.map(sourceId).toProperty("sourceId")
|
||||||
|
.map(sourceName).toProperty("sourceName")
|
||||||
.map(sourceBookId).toProperty("sourceBookId")
|
.map(sourceBookId).toProperty("sourceBookId")
|
||||||
|
.map(catId).toProperty("catId")
|
||||||
|
.map(bookName).toProperty("bookName")
|
||||||
|
.map(authorName).toProperty("authorName")
|
||||||
.map(taskStatus).toProperty("taskStatus")
|
.map(taskStatus).toProperty("taskStatus")
|
||||||
.map(excCount).toProperty("excCount")
|
.map(excCount).toProperty("excCount")
|
||||||
.map(createTime).toProperty("createTime")
|
.map(createTime).toProperty("createTime")
|
||||||
@ -120,7 +132,11 @@ public interface CrawlSingleTaskMapper {
|
|||||||
return MyBatis3Utils.insert(this::insert, record, crawlSingleTask, c ->
|
return MyBatis3Utils.insert(this::insert, record, crawlSingleTask, c ->
|
||||||
c.map(id).toPropertyWhenPresent("id", record::getId)
|
c.map(id).toPropertyWhenPresent("id", record::getId)
|
||||||
.map(sourceId).toPropertyWhenPresent("sourceId", record::getSourceId)
|
.map(sourceId).toPropertyWhenPresent("sourceId", record::getSourceId)
|
||||||
|
.map(sourceName).toPropertyWhenPresent("sourceName", record::getSourceName)
|
||||||
.map(sourceBookId).toPropertyWhenPresent("sourceBookId", record::getSourceBookId)
|
.map(sourceBookId).toPropertyWhenPresent("sourceBookId", record::getSourceBookId)
|
||||||
|
.map(catId).toPropertyWhenPresent("catId", record::getCatId)
|
||||||
|
.map(bookName).toPropertyWhenPresent("bookName", record::getBookName)
|
||||||
|
.map(authorName).toPropertyWhenPresent("authorName", record::getAuthorName)
|
||||||
.map(taskStatus).toPropertyWhenPresent("taskStatus", record::getTaskStatus)
|
.map(taskStatus).toPropertyWhenPresent("taskStatus", record::getTaskStatus)
|
||||||
.map(excCount).toPropertyWhenPresent("excCount", record::getExcCount)
|
.map(excCount).toPropertyWhenPresent("excCount", record::getExcCount)
|
||||||
.map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
|
.map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
|
||||||
@ -158,7 +174,11 @@ public interface CrawlSingleTaskMapper {
|
|||||||
static UpdateDSL<UpdateModel> updateAllColumns(CrawlSingleTask record, UpdateDSL<UpdateModel> dsl) {
|
static UpdateDSL<UpdateModel> updateAllColumns(CrawlSingleTask record, UpdateDSL<UpdateModel> dsl) {
|
||||||
return dsl.set(id).equalTo(record::getId)
|
return dsl.set(id).equalTo(record::getId)
|
||||||
.set(sourceId).equalTo(record::getSourceId)
|
.set(sourceId).equalTo(record::getSourceId)
|
||||||
|
.set(sourceName).equalTo(record::getSourceName)
|
||||||
.set(sourceBookId).equalTo(record::getSourceBookId)
|
.set(sourceBookId).equalTo(record::getSourceBookId)
|
||||||
|
.set(catId).equalTo(record::getCatId)
|
||||||
|
.set(bookName).equalTo(record::getBookName)
|
||||||
|
.set(authorName).equalTo(record::getAuthorName)
|
||||||
.set(taskStatus).equalTo(record::getTaskStatus)
|
.set(taskStatus).equalTo(record::getTaskStatus)
|
||||||
.set(excCount).equalTo(record::getExcCount)
|
.set(excCount).equalTo(record::getExcCount)
|
||||||
.set(createTime).equalTo(record::getCreateTime);
|
.set(createTime).equalTo(record::getCreateTime);
|
||||||
@ -168,7 +188,11 @@ public interface CrawlSingleTaskMapper {
|
|||||||
static UpdateDSL<UpdateModel> updateSelectiveColumns(CrawlSingleTask record, UpdateDSL<UpdateModel> dsl) {
|
static UpdateDSL<UpdateModel> updateSelectiveColumns(CrawlSingleTask record, UpdateDSL<UpdateModel> dsl) {
|
||||||
return dsl.set(id).equalToWhenPresent(record::getId)
|
return dsl.set(id).equalToWhenPresent(record::getId)
|
||||||
.set(sourceId).equalToWhenPresent(record::getSourceId)
|
.set(sourceId).equalToWhenPresent(record::getSourceId)
|
||||||
|
.set(sourceName).equalToWhenPresent(record::getSourceName)
|
||||||
.set(sourceBookId).equalToWhenPresent(record::getSourceBookId)
|
.set(sourceBookId).equalToWhenPresent(record::getSourceBookId)
|
||||||
|
.set(catId).equalToWhenPresent(record::getCatId)
|
||||||
|
.set(bookName).equalToWhenPresent(record::getBookName)
|
||||||
|
.set(authorName).equalToWhenPresent(record::getAuthorName)
|
||||||
.set(taskStatus).equalToWhenPresent(record::getTaskStatus)
|
.set(taskStatus).equalToWhenPresent(record::getTaskStatus)
|
||||||
.set(excCount).equalToWhenPresent(record::getExcCount)
|
.set(excCount).equalToWhenPresent(record::getExcCount)
|
||||||
.set(createTime).equalToWhenPresent(record::getCreateTime);
|
.set(createTime).equalToWhenPresent(record::getCreateTime);
|
||||||
@ -178,7 +202,11 @@ public interface CrawlSingleTaskMapper {
|
|||||||
default int updateByPrimaryKey(CrawlSingleTask record) {
|
default int updateByPrimaryKey(CrawlSingleTask record) {
|
||||||
return update(c ->
|
return update(c ->
|
||||||
c.set(sourceId).equalTo(record::getSourceId)
|
c.set(sourceId).equalTo(record::getSourceId)
|
||||||
|
.set(sourceName).equalTo(record::getSourceName)
|
||||||
.set(sourceBookId).equalTo(record::getSourceBookId)
|
.set(sourceBookId).equalTo(record::getSourceBookId)
|
||||||
|
.set(catId).equalTo(record::getCatId)
|
||||||
|
.set(bookName).equalTo(record::getBookName)
|
||||||
|
.set(authorName).equalTo(record::getAuthorName)
|
||||||
.set(taskStatus).equalTo(record::getTaskStatus)
|
.set(taskStatus).equalTo(record::getTaskStatus)
|
||||||
.set(excCount).equalTo(record::getExcCount)
|
.set(excCount).equalTo(record::getExcCount)
|
||||||
.set(createTime).equalTo(record::getCreateTime)
|
.set(createTime).equalTo(record::getCreateTime)
|
||||||
@ -190,7 +218,11 @@ public interface CrawlSingleTaskMapper {
|
|||||||
default int updateByPrimaryKeySelective(CrawlSingleTask record) {
|
default int updateByPrimaryKeySelective(CrawlSingleTask record) {
|
||||||
return update(c ->
|
return update(c ->
|
||||||
c.set(sourceId).equalToWhenPresent(record::getSourceId)
|
c.set(sourceId).equalToWhenPresent(record::getSourceId)
|
||||||
|
.set(sourceName).equalToWhenPresent(record::getSourceName)
|
||||||
.set(sourceBookId).equalToWhenPresent(record::getSourceBookId)
|
.set(sourceBookId).equalToWhenPresent(record::getSourceBookId)
|
||||||
|
.set(catId).equalToWhenPresent(record::getCatId)
|
||||||
|
.set(bookName).equalToWhenPresent(record::getBookName)
|
||||||
|
.set(authorName).equalToWhenPresent(record::getAuthorName)
|
||||||
.set(taskStatus).equalToWhenPresent(record::getTaskStatus)
|
.set(taskStatus).equalToWhenPresent(record::getTaskStatus)
|
||||||
.set(excCount).equalToWhenPresent(record::getExcCount)
|
.set(excCount).equalToWhenPresent(record::getExcCount)
|
||||||
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||||
|
@ -1,19 +1,77 @@
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
include: [common]
|
include: [common]
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
|
#Redis服务器IP
|
||||||
|
redis:
|
||||||
|
host: 127.0.0.1
|
||||||
|
#Redis服务器连接端口
|
||||||
|
port: 6379
|
||||||
|
#Redis服务器连接密码
|
||||||
|
password: test
|
||||||
|
jedis:
|
||||||
|
pool:
|
||||||
|
#连接池最大连接数(使用负值表示没有限制)
|
||||||
|
max-active: 8
|
||||||
|
#连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
|
max-wait: 1
|
||||||
|
#连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
|
max-idle: 8
|
||||||
|
#连接池中的最小空闲连接
|
||||||
|
min-idle: 0
|
||||||
|
#连接超时时间(毫秒)
|
||||||
|
timeout: 30000
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||||
username: root
|
username: root
|
||||||
password:
|
password: test123456
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
|
||||||
|
####使用shardingJdbc时,
|
||||||
|
####所有的jdbcType都不能是LONGVARCHAR,否则会导致java.io.NotSerializableException: java.io.StringReader错误
|
||||||
|
##### 应该替换所有的 LONGVARCHAR 类型为VARCHAR
|
||||||
|
|
||||||
|
sharding:
|
||||||
|
jdbc:
|
||||||
|
datasource:
|
||||||
|
names: ds0 #,ds1
|
||||||
|
ds0:
|
||||||
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
jdbc-url: jdbc:mysql://localhost:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||||
|
username: root
|
||||||
|
password: test123456
|
||||||
|
# ds1:
|
||||||
|
# type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
# driver-class-name: com.mysql.jdbc.Driver
|
||||||
|
# url: jdbc:mysql://localhost:3306/novel_plus2
|
||||||
|
# username: root
|
||||||
|
# password: test123456
|
||||||
|
config:
|
||||||
|
sharding:
|
||||||
|
props:
|
||||||
|
sql.show: true
|
||||||
|
tables:
|
||||||
|
book_content: #book_content表
|
||||||
|
key-generator-column-name: id #主键
|
||||||
|
actual-data-nodes: ds${0}.book_content${0..9} #数据节点
|
||||||
|
# database-strategy: #分库策略
|
||||||
|
# inline:
|
||||||
|
# sharding-column: book_id
|
||||||
|
# algorithm-expression: ds${book_id % 10}
|
||||||
|
table-strategy: #分表策略
|
||||||
|
inline:
|
||||||
|
shardingColumn: index_id
|
||||||
|
algorithm-expression: book_content${index_id % 10}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pic:
|
pic:
|
||||||
save:
|
save:
|
||||||
type: 2 #图片保存方式, 1不保存,使用网络图片 ,2本地保存
|
type: 2 #图片保存方式, 1不保存,使用爬取的网络图片 ,2保存在自己的存储介质
|
||||||
path: /var/pic #图片保存路径
|
storage: local #存储介质,local:本地,OSS:阿里云对象存储,fastDfs:分布式文件系统
|
||||||
|
path: /var/pic #图片保存路径
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -11,6 +11,9 @@ spring:
|
|||||||
generator:
|
generator:
|
||||||
write-numbers-as-strings: true
|
write-numbers-as-strings: true
|
||||||
|
|
||||||
|
#缓存类型,ehcache(默认)、redis
|
||||||
|
cache:
|
||||||
|
type: ehcache
|
||||||
|
|
||||||
mybatis:
|
mybatis:
|
||||||
configuration:
|
configuration:
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</commentGenerator>
|
</commentGenerator>
|
||||||
<jdbcConnection
|
<jdbcConnection
|
||||||
connectionURL="jdbc:mysql://127.0.0.1:3306/novel_plus?tinyInt1isBit=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true"
|
connectionURL="jdbc:mysql://127.0.0.1:3306/novel_plus?tinyInt1isBit=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true"
|
||||||
driverClass="com.mysql.jdbc.Driver" password=""
|
driverClass="com.mysql.jdbc.Driver" password="test123456"
|
||||||
userId="root" />
|
userId="root" />
|
||||||
|
|
||||||
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer, 为 true时把JDBC DECIMAL
|
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer, 为 true时把JDBC DECIMAL
|
||||||
@ -44,7 +44,7 @@
|
|||||||
</javaClientGenerator>
|
</javaClientGenerator>
|
||||||
|
|
||||||
<!--生成全部表tableName设为%-->
|
<!--生成全部表tableName设为%-->
|
||||||
<table tableName="user_buy_record" domainObjectName="UserBuyRecord"/>
|
<table tableName="crawl_single_task"/>
|
||||||
|
|
||||||
<!-- 指定数据库表 -->
|
<!-- 指定数据库表 -->
|
||||||
<!--<table schema="jly" tableName="job_position" domainObjectName="JobPositionTest"/>-->
|
<!--<table schema="jly" tableName="job_position" domainObjectName="JobPositionTest"/>-->
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>novel</artifactId>
|
<artifactId>novel</artifactId>
|
||||||
<groupId>com.java2nb</groupId>
|
<groupId>com.java2nb</groupId>
|
||||||
<version>2.0.1</version>
|
<version>2.6.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -25,6 +25,8 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -3,11 +3,12 @@ package com.java2nb.novel.controller;
|
|||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.java2nb.novel.core.bean.ResultBean;
|
import com.java2nb.novel.core.bean.ResultBean;
|
||||||
import com.java2nb.novel.core.utils.BeanUtil;
|
import com.java2nb.novel.core.utils.BeanUtil;
|
||||||
|
import com.java2nb.novel.entity.CrawlSingleTask;
|
||||||
import com.java2nb.novel.entity.CrawlSource;
|
import com.java2nb.novel.entity.CrawlSource;
|
||||||
import com.java2nb.novel.service.CrawlService;
|
import com.java2nb.novel.service.CrawlService;
|
||||||
|
import com.java2nb.novel.vo.CrawlSingleTaskVO;
|
||||||
import com.java2nb.novel.vo.CrawlSourceVO;
|
import com.java2nb.novel.vo.CrawlSourceVO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
@ -56,6 +57,38 @@ public class CrawlController {
|
|||||||
return ResultBean.ok();
|
return ResultBean.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增单本采集任务
|
||||||
|
* */
|
||||||
|
@PostMapping("addCrawlSingleTask")
|
||||||
|
public ResultBean addCrawlSingleTask(CrawlSingleTask singleTask){
|
||||||
|
crawlService.addCrawlSingleTask(singleTask);
|
||||||
|
|
||||||
|
return ResultBean.ok();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单本采集任务分页列表查询
|
||||||
|
* */
|
||||||
|
@PostMapping("listCrawlSingleTaskByPage")
|
||||||
|
public ResultBean listCrawlSingleTaskByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize){
|
||||||
|
|
||||||
|
return ResultBean.ok(new PageInfo<>(BeanUtil.copyList(crawlService.listCrawlSingleTaskByPage(page,pageSize), CrawlSingleTaskVO.class)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除采集任务
|
||||||
|
* */
|
||||||
|
@PostMapping("delCrawlSingleTask")
|
||||||
|
public ResultBean delCrawlSingleTask(Long id){
|
||||||
|
|
||||||
|
crawlService.delCrawlSingleTask(id);
|
||||||
|
|
||||||
|
return ResultBean.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,12 +3,17 @@ package com.java2nb.novel.core.crawl;
|
|||||||
import com.java2nb.novel.core.utils.HttpUtil;
|
import com.java2nb.novel.core.utils.HttpUtil;
|
||||||
import com.java2nb.novel.core.utils.IdWorker;
|
import com.java2nb.novel.core.utils.IdWorker;
|
||||||
import com.java2nb.novel.core.utils.RandomBookInfoUtil;
|
import com.java2nb.novel.core.utils.RandomBookInfoUtil;
|
||||||
|
import com.java2nb.novel.core.utils.RestTemplateUtil;
|
||||||
import com.java2nb.novel.entity.Book;
|
import com.java2nb.novel.entity.Book;
|
||||||
import com.java2nb.novel.entity.BookContent;
|
import com.java2nb.novel.entity.BookContent;
|
||||||
import com.java2nb.novel.entity.BookIndex;
|
import com.java2nb.novel.entity.BookIndex;
|
||||||
import com.java2nb.novel.utils.Constants;
|
import com.java2nb.novel.utils.Constants;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -22,17 +27,24 @@ import static java.util.regex.Pattern.compile;
|
|||||||
*
|
*
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class CrawlParser {
|
public class CrawlParser {
|
||||||
|
|
||||||
|
private static IdWorker idWorker = new IdWorker();
|
||||||
|
|
||||||
public static final Integer BOOK_INDEX_LIST_KEY = 1;
|
public static final Integer BOOK_INDEX_LIST_KEY = 1;
|
||||||
|
|
||||||
public static final Integer BOOK_CONTENT_LIST_KEY = 2;
|
public static final Integer BOOK_CONTENT_LIST_KEY = 2;
|
||||||
|
|
||||||
|
private static RestTemplate restTemplate = RestTemplateUtil.getInstance("utf-8");
|
||||||
|
|
||||||
|
private static ThreadLocal <Integer> retryCount = new ThreadLocal<>();
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static Book parseBook(RuleBean ruleBean, String bookId) {
|
public static Book parseBook(RuleBean ruleBean, String bookId) {
|
||||||
Book book = new Book();
|
Book book = new Book();
|
||||||
String bookDetailUrl = ruleBean.getBookDetailUrl().replace("{bookId}", bookId);
|
String bookDetailUrl = ruleBean.getBookDetailUrl().replace("{bookId}", bookId);
|
||||||
String bookDetailHtml = HttpUtil.getByHttpClient(bookDetailUrl);
|
String bookDetailHtml = getByHttpClient(bookDetailUrl);
|
||||||
if (bookDetailHtml != null) {
|
if (bookDetailHtml != null) {
|
||||||
Pattern bookNamePatten = compile(ruleBean.getBookNamePatten());
|
Pattern bookNamePatten = compile(ruleBean.getBookNamePatten());
|
||||||
Matcher bookNameMatch = bookNamePatten.matcher(bookDetailHtml);
|
Matcher bookNameMatch = bookNamePatten.matcher(bookDetailHtml);
|
||||||
@ -54,6 +66,9 @@ public class CrawlParser {
|
|||||||
boolean isFindPicUrl = picUrlMatch.find();
|
boolean isFindPicUrl = picUrlMatch.find();
|
||||||
if (isFindPicUrl) {
|
if (isFindPicUrl) {
|
||||||
String picUrl = picUrlMatch.group(1);
|
String picUrl = picUrlMatch.group(1);
|
||||||
|
if(StringUtils.isNotBlank(picUrl) && StringUtils.isNotBlank(ruleBean.getPicUrlPrefix())) {
|
||||||
|
picUrl = ruleBean.getPicUrlPrefix() + picUrl;
|
||||||
|
}
|
||||||
//设置封面图片路径
|
//设置封面图片路径
|
||||||
book.setPicUrl(picUrl);
|
book.setPicUrl(picUrl);
|
||||||
}
|
}
|
||||||
@ -81,6 +96,12 @@ public class CrawlParser {
|
|||||||
|
|
||||||
String desc = bookDetailHtml.substring(bookDetailHtml.indexOf(ruleBean.getDescStart()) + ruleBean.getDescStart().length());
|
String desc = bookDetailHtml.substring(bookDetailHtml.indexOf(ruleBean.getDescStart()) + ruleBean.getDescStart().length());
|
||||||
desc = desc.substring(0, desc.indexOf(ruleBean.getDescEnd()));
|
desc = desc.substring(0, desc.indexOf(ruleBean.getDescEnd()));
|
||||||
|
//过滤掉简介中的特殊标签
|
||||||
|
desc = desc.replaceAll("<a[^<]+</a>","")
|
||||||
|
.replaceAll("<font[^<]+</font>","")
|
||||||
|
.replaceAll("<p>\\s*</p>","")
|
||||||
|
.replaceAll("<p>","")
|
||||||
|
.replaceAll("</p>","<br/>");
|
||||||
//设置书籍简介
|
//设置书籍简介
|
||||||
book.setBookDesc(desc);
|
book.setBookDesc(desc);
|
||||||
if (StringUtils.isNotBlank(ruleBean.getStatusPatten())) {
|
if (StringUtils.isNotBlank(ruleBean.getStatusPatten())) {
|
||||||
@ -136,8 +157,13 @@ public class CrawlParser {
|
|||||||
List<BookContent> contentList = new ArrayList<>();
|
List<BookContent> contentList = new ArrayList<>();
|
||||||
//读取目录
|
//读取目录
|
||||||
String indexListUrl = ruleBean.getBookIndexUrl().replace("{bookId}", sourceBookId);
|
String indexListUrl = ruleBean.getBookIndexUrl().replace("{bookId}", sourceBookId);
|
||||||
String indexListHtml = HttpUtil.getByHttpClient(indexListUrl);
|
String indexListHtml = getByHttpClient(indexListUrl);
|
||||||
|
|
||||||
if (indexListHtml != null) {
|
if (indexListHtml != null) {
|
||||||
|
if(StringUtils.isNotBlank(ruleBean.getBookIndexStart())){
|
||||||
|
indexListHtml = indexListHtml.substring(indexListHtml.indexOf(ruleBean.getBookIndexStart()) + ruleBean.getBookIndexStart().length());
|
||||||
|
}
|
||||||
|
|
||||||
Pattern indexIdPatten = compile(ruleBean.getIndexIdPatten());
|
Pattern indexIdPatten = compile(ruleBean.getIndexIdPatten());
|
||||||
Matcher indexIdMatch = indexIdPatten.matcher(indexListHtml);
|
Matcher indexIdMatch = indexIdPatten.matcher(indexListHtml);
|
||||||
|
|
||||||
@ -155,6 +181,7 @@ public class CrawlParser {
|
|||||||
String lastIndexName = null;
|
String lastIndexName = null;
|
||||||
|
|
||||||
while (isFindIndex) {
|
while (isFindIndex) {
|
||||||
|
|
||||||
BookIndex hasIndex = hasIndexs.get(indexNum);
|
BookIndex hasIndex = hasIndexs.get(indexNum);
|
||||||
String indexName = indexNameMatch.group(1);
|
String indexName = indexNameMatch.group(1);
|
||||||
|
|
||||||
@ -162,8 +189,8 @@ public class CrawlParser {
|
|||||||
String contentUrl = ruleBean.getBookContentUrl().replace("{bookId}", sourceBookId).replace("{indexId}", indexIdMatch.group(1));
|
String contentUrl = ruleBean.getBookContentUrl().replace("{bookId}", sourceBookId).replace("{indexId}", indexIdMatch.group(1));
|
||||||
|
|
||||||
//查询章节内容
|
//查询章节内容
|
||||||
String contentHtml = HttpUtil.getByHttpClient(contentUrl);
|
String contentHtml = getByHttpClient(contentUrl);
|
||||||
if (contentHtml != null) {
|
if (contentHtml != null && !contentHtml.contains("正在手打中")) {
|
||||||
String content = contentHtml.substring(contentHtml.indexOf(ruleBean.getContentStart()) + ruleBean.getContentStart().length());
|
String content = contentHtml.substring(contentHtml.indexOf(ruleBean.getContentStart()) + ruleBean.getContentStart().length());
|
||||||
content = content.substring(0, content.indexOf(ruleBean.getContentEnd()));
|
content = content.substring(0, content.indexOf(ruleBean.getContentEnd()));
|
||||||
//TODO插入章节目录和章节内容
|
//TODO插入章节目录和章节内容
|
||||||
@ -181,7 +208,7 @@ public class CrawlParser {
|
|||||||
if(hasIndexs.size() == 0){
|
if(hasIndexs.size() == 0){
|
||||||
//新书入库
|
//新书入库
|
||||||
//设置目录和章节内容
|
//设置目录和章节内容
|
||||||
Long indexId = new IdWorker().nextId();
|
Long indexId = idWorker.nextId();
|
||||||
lastIndexId = indexId;
|
lastIndexId = indexId;
|
||||||
lastIndexName = indexName;
|
lastIndexName = indexName;
|
||||||
bookIndex.setId(indexId);
|
bookIndex.setId(indexId);
|
||||||
@ -214,8 +241,6 @@ public class CrawlParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -237,4 +262,37 @@ public class CrawlParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static String getByHttpClient(String url) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);
|
||||||
|
if (forEntity.getStatusCode() == HttpStatus.OK) {
|
||||||
|
String body = forEntity.getBody();
|
||||||
|
if(body.length() < Constants.INVALID_HTML_LENGTH){
|
||||||
|
return processErrorHttpResult(url);
|
||||||
|
}
|
||||||
|
//成功获得html内容
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return processErrorHttpResult(url);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
private static String processErrorHttpResult(String url){
|
||||||
|
Integer count = retryCount.get();
|
||||||
|
if(count == null){
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
if(count < Constants.HTTP_FAIL_RETRY_COUNT){
|
||||||
|
Thread.sleep( new Random().nextInt(10*1000));
|
||||||
|
retryCount.set(++count);
|
||||||
|
return getByHttpClient(url);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,14 @@ import java.util.Map;
|
|||||||
@Data
|
@Data
|
||||||
public class RuleBean {
|
public class RuleBean {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小说更新列表url
|
||||||
|
* */
|
||||||
|
private String updateBookListUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类列表页URL规则
|
||||||
|
* */
|
||||||
private String bookListUrl;
|
private String bookListUrl;
|
||||||
|
|
||||||
private Map<String,String> catIdRule;
|
private Map<String,String> catIdRule;
|
||||||
@ -39,4 +47,9 @@ public class RuleBean {
|
|||||||
private String contentEnd;
|
private String contentEnd;
|
||||||
|
|
||||||
|
|
||||||
|
private String picUrlPrefix;
|
||||||
|
|
||||||
|
private String bookIndexStart;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,7 @@ package com.java2nb.novel.core.listener;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.java2nb.novel.core.crawl.CrawlParser;
|
import com.java2nb.novel.core.crawl.CrawlParser;
|
||||||
import com.java2nb.novel.core.crawl.RuleBean;
|
import com.java2nb.novel.core.crawl.RuleBean;
|
||||||
import com.java2nb.novel.entity.Book;
|
import com.java2nb.novel.entity.*;
|
||||||
import com.java2nb.novel.entity.BookContent;
|
|
||||||
import com.java2nb.novel.entity.BookIndex;
|
|
||||||
import com.java2nb.novel.entity.CrawlSource;
|
|
||||||
import com.java2nb.novel.service.BookService;
|
import com.java2nb.novel.service.BookService;
|
||||||
import com.java2nb.novel.service.CrawlService;
|
import com.java2nb.novel.service.CrawlService;
|
||||||
import com.java2nb.novel.utils.Constants;
|
import com.java2nb.novel.utils.Constants;
|
||||||
@ -40,15 +37,15 @@ public class StarterListener implements ServletContextListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void contextInitialized(ServletContextEvent sce) {
|
public void contextInitialized(ServletContextEvent sce) {
|
||||||
log.info("程序启动,开始执行自动更新线程。。。");
|
for (int i = 0; i < updateThreadCount; i++) {
|
||||||
for(int i = 0 ; i<updateThreadCount; i++) {
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
log.info("程序启动,开始执行自动更新线程。。。");
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
//1.查询最新目录更新时间在一个月之内的前100条需要更新的数据
|
//1.查询最新目录更新时间在一个月之内的前100条需要更新的数据
|
||||||
Date currentDate = new Date();
|
Date currentDate = new Date();
|
||||||
Date startDate = DateUtils.addDays(currentDate, -30);
|
Date startDate = DateUtils.addDays(currentDate, -30);
|
||||||
List<Book> bookList ;
|
List<Book> bookList;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
bookList = bookService.queryNeedUpdateBook(startDate, 100);
|
bookList = bookService.queryNeedUpdateBook(startDate, 100);
|
||||||
}
|
}
|
||||||
@ -61,7 +58,7 @@ public class StarterListener implements ServletContextListener {
|
|||||||
Book book = CrawlParser.parseBook(ruleBean, needUpdateBook.getCrawlBookId());
|
Book book = CrawlParser.parseBook(ruleBean, needUpdateBook.getCrawlBookId());
|
||||||
//这里只做老书更新
|
//这里只做老书更新
|
||||||
book.setId(needUpdateBook.getId());
|
book.setId(needUpdateBook.getId());
|
||||||
if(needUpdateBook.getPicUrl()!=null && needUpdateBook.getPicUrl().startsWith(Constants.LOCAL_PIC_PREFIX)) {
|
if (needUpdateBook.getPicUrl() != null && needUpdateBook.getPicUrl().contains(Constants.LOCAL_PIC_PREFIX)) {
|
||||||
//本地图片则不更新
|
//本地图片则不更新
|
||||||
book.setPicUrl(null);
|
book.setPicUrl(null);
|
||||||
}
|
}
|
||||||
@ -83,6 +80,42 @@ public class StarterListener implements ServletContextListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
new Thread(() -> {
|
||||||
|
log.info("程序启动,开始执行单本采集任务线程。。。");
|
||||||
|
while (true) {
|
||||||
|
CrawlSingleTask task = null;
|
||||||
|
byte crawlStatus = 0;
|
||||||
|
try {
|
||||||
|
//获取采集任务
|
||||||
|
task = crawlService.getCrawlSingleTask();
|
||||||
|
|
||||||
|
if (task != null) {
|
||||||
|
//查询爬虫规则
|
||||||
|
CrawlSource source = crawlService.queryCrawlSource(task.getSourceId());
|
||||||
|
RuleBean ruleBean = new ObjectMapper().readValue(source.getCrawlRule(), RuleBean.class);
|
||||||
|
|
||||||
|
if (crawlService.parseBookAndSave(task.getCatId(), ruleBean, task.getSourceId(), task.getSourceBookId())) {
|
||||||
|
//采集成功
|
||||||
|
crawlStatus = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.sleep(1000 * 60);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
if (task != null) {
|
||||||
|
crawlService.updateCrawlSingleTask(task, crawlStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.java2nb.novel.service;
|
package com.java2nb.novel.service;
|
||||||
|
|
||||||
import com.java2nb.novel.core.crawl.RuleBean;
|
import com.java2nb.novel.core.crawl.RuleBean;
|
||||||
|
import com.java2nb.novel.entity.CrawlSingleTask;
|
||||||
import com.java2nb.novel.entity.CrawlSource;
|
import com.java2nb.novel.entity.CrawlSource;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -39,6 +40,16 @@ public interface CrawlService {
|
|||||||
* */
|
* */
|
||||||
void updateCrawlSourceStatus(Integer sourceId, Byte sourceStatus);
|
void updateCrawlSourceStatus(Integer sourceId, Byte sourceStatus);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采集并保存小说
|
||||||
|
* @param catId 分类ID
|
||||||
|
* @param bookId 小说ID
|
||||||
|
* @param sourceId 源ID
|
||||||
|
* @param ruleBean 采集规则\
|
||||||
|
* @return true:成功,false:失败
|
||||||
|
* */
|
||||||
|
boolean parseBookAndSave(int catId, RuleBean ruleBean, Integer sourceId, String bookId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据爬虫状态查询爬虫源集合
|
* 根据爬虫状态查询爬虫源集合
|
||||||
* @param sourceStatus 状态,0关闭,1开启
|
* @param sourceStatus 状态,0关闭,1开启
|
||||||
@ -61,4 +72,37 @@ public interface CrawlService {
|
|||||||
* @return 源信息
|
* @return 源信息
|
||||||
* */
|
* */
|
||||||
CrawlSource queryCrawlSource(Integer sourceId);
|
CrawlSource queryCrawlSource(Integer sourceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增单本采集任务
|
||||||
|
* @param singleTask 任务信息对象
|
||||||
|
* */
|
||||||
|
void addCrawlSingleTask(CrawlSingleTask singleTask);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单本采集任务分页列表查询
|
||||||
|
* @param page 当前页码
|
||||||
|
* @param pageSize 分页大小
|
||||||
|
* @return 单本采集任务集合
|
||||||
|
* */
|
||||||
|
List<CrawlSingleTask> listCrawlSingleTaskByPage(int page, int pageSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除采集任务
|
||||||
|
* @param id 任务ID
|
||||||
|
* */
|
||||||
|
void delCrawlSingleTask(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取采集任务
|
||||||
|
* @return 采集任务
|
||||||
|
* */
|
||||||
|
CrawlSingleTask getCrawlSingleTask();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新单本采集任务
|
||||||
|
* @param task 采集任务
|
||||||
|
* @param status 采集状态
|
||||||
|
* */
|
||||||
|
void updateCrawlSingleTask(CrawlSingleTask task, Byte status);
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,12 @@ import com.java2nb.novel.core.cache.CacheKey;
|
|||||||
import com.java2nb.novel.core.cache.CacheService;
|
import com.java2nb.novel.core.cache.CacheService;
|
||||||
import com.java2nb.novel.core.crawl.CrawlParser;
|
import com.java2nb.novel.core.crawl.CrawlParser;
|
||||||
import com.java2nb.novel.core.crawl.RuleBean;
|
import com.java2nb.novel.core.crawl.RuleBean;
|
||||||
|
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||||
|
import com.java2nb.novel.core.exception.BusinessException;
|
||||||
import com.java2nb.novel.core.utils.IdWorker;
|
import com.java2nb.novel.core.utils.IdWorker;
|
||||||
import com.java2nb.novel.core.utils.SpringUtil;
|
import com.java2nb.novel.core.utils.SpringUtil;
|
||||||
import com.java2nb.novel.core.utils.ThreadUtil;
|
import com.java2nb.novel.core.utils.ThreadUtil;
|
||||||
import com.java2nb.novel.entity.Book;
|
import com.java2nb.novel.entity.*;
|
||||||
import com.java2nb.novel.entity.BookContent;
|
|
||||||
import com.java2nb.novel.entity.BookIndex;
|
|
||||||
import com.java2nb.novel.entity.CrawlSource;
|
import com.java2nb.novel.entity.CrawlSource;
|
||||||
import com.java2nb.novel.mapper.*;
|
import com.java2nb.novel.mapper.*;
|
||||||
import com.java2nb.novel.service.BookService;
|
import com.java2nb.novel.service.BookService;
|
||||||
@ -33,8 +33,7 @@ import static com.java2nb.novel.core.utils.HttpUtil.getByHttpClient;
|
|||||||
import static com.java2nb.novel.mapper.BookDynamicSqlSupport.crawlBookId;
|
import static com.java2nb.novel.mapper.BookDynamicSqlSupport.crawlBookId;
|
||||||
import static com.java2nb.novel.mapper.BookDynamicSqlSupport.crawlSourceId;
|
import static com.java2nb.novel.mapper.BookDynamicSqlSupport.crawlSourceId;
|
||||||
import static com.java2nb.novel.mapper.CrawlSourceDynamicSqlSupport.*;
|
import static com.java2nb.novel.mapper.CrawlSourceDynamicSqlSupport.*;
|
||||||
import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;
|
import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
||||||
import static org.mybatis.dynamic.sql.SqlBuilder.update;
|
|
||||||
import static org.mybatis.dynamic.sql.select.SelectDSL.select;
|
import static org.mybatis.dynamic.sql.select.SelectDSL.select;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,6 +47,8 @@ public class CrawlServiceImpl implements CrawlService {
|
|||||||
|
|
||||||
private final CrawlSourceMapper crawlSourceMapper;
|
private final CrawlSourceMapper crawlSourceMapper;
|
||||||
|
|
||||||
|
private final CrawlSingleTaskMapper crawlSingleTaskMapper;
|
||||||
|
|
||||||
private final BookService bookService;
|
private final BookService bookService;
|
||||||
|
|
||||||
|
|
||||||
@ -140,6 +141,62 @@ public class CrawlServiceImpl implements CrawlService {
|
|||||||
return crawlSourceMapper.selectMany(render).get(0);
|
return crawlSourceMapper.selectMany(render).get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCrawlSingleTask(CrawlSingleTask singleTask) {
|
||||||
|
|
||||||
|
if(bookService.queryIsExistByBookNameAndAuthorName(singleTask.getBookName(),singleTask.getAuthorName())){
|
||||||
|
throw new BusinessException(ResponseStatus.BOOK_EXISTS);
|
||||||
|
|
||||||
|
}
|
||||||
|
singleTask.setCreateTime(new Date());
|
||||||
|
crawlSingleTaskMapper.insertSelective(singleTask);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CrawlSingleTask> listCrawlSingleTaskByPage(int page, int pageSize) {
|
||||||
|
PageHelper.startPage(page, pageSize);
|
||||||
|
SelectStatementProvider render = select(CrawlSingleTaskDynamicSqlSupport.crawlSingleTask.allColumns())
|
||||||
|
.from(CrawlSingleTaskDynamicSqlSupport.crawlSingleTask)
|
||||||
|
.orderBy(CrawlSingleTaskDynamicSqlSupport.createTime.descending())
|
||||||
|
.build()
|
||||||
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
|
return crawlSingleTaskMapper.selectMany(render);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delCrawlSingleTask(Long id) {
|
||||||
|
crawlSingleTaskMapper.deleteByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CrawlSingleTask getCrawlSingleTask() {
|
||||||
|
|
||||||
|
List<CrawlSingleTask> list = crawlSingleTaskMapper.selectMany(select(CrawlSingleTaskDynamicSqlSupport.crawlSingleTask.allColumns())
|
||||||
|
.from(CrawlSingleTaskDynamicSqlSupport.crawlSingleTask)
|
||||||
|
.where(CrawlSingleTaskDynamicSqlSupport.taskStatus,isEqualTo((byte)2))
|
||||||
|
.orderBy(CrawlSingleTaskDynamicSqlSupport.createTime)
|
||||||
|
.limit(1)
|
||||||
|
.build()
|
||||||
|
.render(RenderingStrategies.MYBATIS3));
|
||||||
|
|
||||||
|
return list.size() > 0 ? list.get(0) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateCrawlSingleTask(CrawlSingleTask task, Byte status) {
|
||||||
|
byte excCount = task.getExcCount();
|
||||||
|
excCount+=1;
|
||||||
|
task.setExcCount(excCount);
|
||||||
|
if(status == 1 || excCount == 5){
|
||||||
|
//当采集成功或者采集次数等于5,则更新采集最终状态,并停止采集
|
||||||
|
task.setTaskStatus(status);
|
||||||
|
}
|
||||||
|
crawlSingleTaskMapper.updateByPrimaryKeySelective(task);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析分类列表
|
* 解析分类列表
|
||||||
*/
|
*/
|
||||||
@ -167,36 +224,13 @@ public class CrawlServiceImpl implements CrawlService {
|
|||||||
boolean isFindBookId = bookIdMatcher.find();
|
boolean isFindBookId = bookIdMatcher.find();
|
||||||
while (isFindBookId) {
|
while (isFindBookId) {
|
||||||
try {
|
try {
|
||||||
String bookId = bookIdMatcher.group(1);
|
if(Thread.currentThread().isInterrupted()){
|
||||||
Book book = CrawlParser.parseBook(ruleBean, bookId);
|
return;
|
||||||
//这里只做新书入库,查询是否存在这本书
|
|
||||||
Book existBook = bookService.queryBookByBookNameAndAuthorName(book.getBookName(), book.getAuthorName());
|
|
||||||
//如果该小说不存在,则可以解析入库,但是标记该小说正在入库,30分钟之后才允许再次入库
|
|
||||||
if (existBook == null) {
|
|
||||||
//没有该书,可以入库
|
|
||||||
book.setCatId(catId);
|
|
||||||
//根据分类ID查询分类
|
|
||||||
book.setCatName(bookService.queryCatNameByCatId(catId));
|
|
||||||
if (catId == 7) {
|
|
||||||
//女频
|
|
||||||
book.setWorkDirection((byte) 1);
|
|
||||||
} else {
|
|
||||||
//男频
|
|
||||||
book.setWorkDirection((byte) 0);
|
|
||||||
}
|
|
||||||
book.setCrawlBookId(bookId);
|
|
||||||
book.setCrawlSourceId(sourceId);
|
|
||||||
book.setCrawlLastTime(new Date());
|
|
||||||
book.setId(new IdWorker().nextId());
|
|
||||||
//解析章节目录
|
|
||||||
Map<Integer, List> indexAndContentList = CrawlParser.parseBookIndexAndContent(bookId, book, ruleBean, new HashMap<>(0));
|
|
||||||
|
|
||||||
bookService.saveBookAndIndexAndContent(book, (List<BookIndex>) indexAndContentList.get(CrawlParser.BOOK_INDEX_LIST_KEY), (List<BookContent>) indexAndContentList.get(CrawlParser.BOOK_CONTENT_LIST_KEY));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
//只更新书籍的爬虫相关字段
|
|
||||||
bookService.updateCrawlProperties(existBook.getId(), sourceId, bookId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String bookId = bookIdMatcher.group(1);
|
||||||
|
parseBookAndSave(catId, ruleBean, sourceId, bookId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
@ -227,6 +261,43 @@ public class CrawlServiceImpl implements CrawlService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean parseBookAndSave(int catId, RuleBean ruleBean, Integer sourceId, String bookId) {
|
||||||
|
Book book = CrawlParser.parseBook(ruleBean, bookId);
|
||||||
|
if(book.getBookName() == null || book.getAuthorName() == null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//这里只做新书入库,查询是否存在这本书
|
||||||
|
Book existBook = bookService.queryBookByBookNameAndAuthorName(book.getBookName(), book.getAuthorName());
|
||||||
|
//如果该小说不存在,则可以解析入库,但是标记该小说正在入库,30分钟之后才允许再次入库
|
||||||
|
if (existBook == null) {
|
||||||
|
//没有该书,可以入库
|
||||||
|
book.setCatId(catId);
|
||||||
|
//根据分类ID查询分类
|
||||||
|
book.setCatName(bookService.queryCatNameByCatId(catId));
|
||||||
|
if (catId == 7) {
|
||||||
|
//女频
|
||||||
|
book.setWorkDirection((byte) 1);
|
||||||
|
} else {
|
||||||
|
//男频
|
||||||
|
book.setWorkDirection((byte) 0);
|
||||||
|
}
|
||||||
|
book.setCrawlBookId(bookId);
|
||||||
|
book.setCrawlSourceId(sourceId);
|
||||||
|
book.setCrawlLastTime(new Date());
|
||||||
|
book.setId(new IdWorker().nextId());
|
||||||
|
//解析章节目录
|
||||||
|
Map<Integer, List> indexAndContentList = CrawlParser.parseBookIndexAndContent(bookId, book, ruleBean, new HashMap<>(0));
|
||||||
|
|
||||||
|
bookService.saveBookAndIndexAndContent(book, (List<BookIndex>) indexAndContentList.get(CrawlParser.BOOK_INDEX_LIST_KEY), (List<BookContent>) indexAndContentList.get(CrawlParser.BOOK_CONTENT_LIST_KEY));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//只更新书籍的爬虫相关字段
|
||||||
|
bookService.updateCrawlProperties(existBook.getId(), sourceId, bookId);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateCrawlSourceStatus(Integer sourceId, Byte sourceStatus) {
|
public void updateCrawlSourceStatus(Integer sourceId, Byte sourceStatus) {
|
||||||
CrawlSource source = new CrawlSource();
|
CrawlSource source = new CrawlSource();
|
||||||
|
@ -14,4 +14,14 @@ public class Constants {
|
|||||||
* 访问量默认值
|
* 访问量默认值
|
||||||
*/
|
*/
|
||||||
public static final Long VISIT_COUNT_DEFAULT = 100L;
|
public static final Long VISIT_COUNT_DEFAULT = 100L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 爬取小说http请求中无效的内容长度
|
||||||
|
*/
|
||||||
|
public static final int INVALID_HTML_LENGTH = 1500;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 爬取小说http请求失败重试次数
|
||||||
|
*/
|
||||||
|
public static final Integer HTTP_FAIL_RETRY_COUNT = 5;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.java2nb.novel.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.java2nb.novel.entity.CrawlSingleTask;
|
||||||
|
import com.java2nb.novel.entity.CrawlSource;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CrawlSingleTaskVO extends CrawlSingleTask {
|
||||||
|
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,7 @@
|
|||||||
.user_l .log_list { width:350px }
|
.user_l .log_list { width:350px }
|
||||||
.user_l .s_input { margin-bottom:25px; font-size:14px }
|
.user_l .s_input { margin-bottom:25px; font-size:14px }
|
||||||
.s_input { width:348px; height:30px; line-height:38px\9; vertical-align:middle; border:1px solid #ddd; border-radius:2px }
|
.s_input { width:348px; height:30px; line-height:38px\9; vertical-align:middle; border:1px solid #ddd; border-radius:2px }
|
||||||
.icon_name, .icon_key, .icon_code { width:312px; padding-left:36px; background:url(../images/icon_user.png) no-repeat 13px 13px }
|
.icon_name, .icon_key, .icon_code { width:312px; padding-left:36px}
|
||||||
.icon_key { background-position: 13px -51px }
|
.icon_key { background-position: 13px -51px }
|
||||||
.icon_code { background-position: 13px -117px; width:200px; float:left }
|
.icon_code { background-position: 13px -117px; width:200px; float:left }
|
||||||
.code_pic { height:38px; float:right }
|
.code_pic { height:38px; float:right }
|
||||||
@ -37,7 +37,7 @@
|
|||||||
.fast_tit .title { background:#fff; font-size:16px; padding:3px 14px; position:relative; display:inline-block; z-index:999 }
|
.fast_tit .title { background:#fff; font-size:16px; padding:3px 14px; position:relative; display:inline-block; z-index:999 }
|
||||||
/*userinfo*/
|
/*userinfo*/
|
||||||
.my_l { width:198px; float:left; font-size: 13px; padding-top: 20px; }
|
.my_l { width:198px; float:left; font-size: 13px; padding-top: 20px; }
|
||||||
.my_l li a { display:block; height:42px; line-height:42px; padding-left:62px; border-left:4px solid #fff; background:url(../images/icon_user.png) no-repeat; margin-bottom:5px; color: #666 }
|
.my_l li a { display:block; height:42px; line-height:42px; padding-left:62px; border-left:4px solid #fff; margin-bottom:5px; color: #666 }
|
||||||
.my_l li .on { background-color:#fafafa; border-left:2px solid #f80; color:#000; border-radius: 0 2px 2px 0 }
|
.my_l li .on { background-color:#fafafa; border-left:2px solid #f80; color:#000; border-radius: 0 2px 2px 0 }
|
||||||
.my_l .link_1 { background-position:32px -188px }
|
.my_l .link_1 { background-position:32px -188px }
|
||||||
.my_l .link_2 { background-position:32px -230px }
|
.my_l .link_2 { background-position:32px -230px }
|
||||||
|
@ -0,0 +1,188 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||||
|
<title>爬虫管理系统-小说精品屋</title>
|
||||||
|
<link rel="stylesheet" href="/css/base.css?v=1"/>
|
||||||
|
<link rel="stylesheet" href="/css/user.css"/>
|
||||||
|
</head>
|
||||||
|
</head>
|
||||||
|
<body class="">
|
||||||
|
|
||||||
|
<div class="header">
|
||||||
|
<div class="mainNav" id="mainNav">
|
||||||
|
<div class="box_center cf"
|
||||||
|
style="text-align: center;height: 44px;line-height: 48px;color: #fff;font-size: 16px;">
|
||||||
|
|
||||||
|
小说精品屋爬虫管理
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="main box_center cf">
|
||||||
|
<div class="userBox cf">
|
||||||
|
<div class="my_l">
|
||||||
|
|
||||||
|
<ul class="log_list">
|
||||||
|
<li><a class="link_1" href="/">爬虫源管理</a></li>
|
||||||
|
<li><a class="link_1 on" href="/crawl/crawlSingleTask_list.html">单本采集管理</a></li>
|
||||||
|
<!--<li><a class="link_1 " href="/user/userinfo.html">批量小说爬取</a></li>
|
||||||
|
<li><a class="link_4 " href="/user/favorites.html">单本小说爬取</a></li>-->
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="my_r">
|
||||||
|
<div class="my_bookshelf">
|
||||||
|
|
||||||
|
<div class="userBox cf">
|
||||||
|
<form method="post" action="./register.html" id="form2">
|
||||||
|
|
||||||
|
<div class="user_l">
|
||||||
|
<div></div>
|
||||||
|
<h3>采集信息填写(示例均为笔趣阁:http://www.mcmssc.com)</h3>
|
||||||
|
<ul class="log_list">
|
||||||
|
<li><span id="LabErr"></span></li>
|
||||||
|
<input type="hidden" id="sourceName" class="s_input icon_name" >
|
||||||
|
<b>采集源:</b>
|
||||||
|
<li><select id="sourceId" class="s_input icon_key">
|
||||||
|
</select></li>
|
||||||
|
<b>采集分类:</b>
|
||||||
|
<li><select id="catId" class="s_input icon_key">
|
||||||
|
<option value="1">玄幻奇幻</option>
|
||||||
|
<option value="2">武侠仙侠</option>
|
||||||
|
<option value="3">都市言情</option>
|
||||||
|
<option value="4">历史军事</option>
|
||||||
|
<option value="5">科幻灵异</option>
|
||||||
|
<option value="6">网游竞技</option>
|
||||||
|
<option value="7">女生频道</option>
|
||||||
|
</select>
|
||||||
|
</li>
|
||||||
|
示例:<b>73_73911</b>
|
||||||
|
<li><input type="text" id="sourceBookId" class="s_input icon_key"
|
||||||
|
placeholder="采集的源站小说ID"/></li>
|
||||||
|
示例:<b>苏厨</b>
|
||||||
|
<li><input type="text" id="bookName" class="s_input icon_key"
|
||||||
|
placeholder="采集的小说名"/></li>
|
||||||
|
示例:<b>二子从周</b>
|
||||||
|
<li><input type="text" id="authorName" class="s_input icon_key"
|
||||||
|
placeholder="采集的小说作者名"/></li>
|
||||||
|
|
||||||
|
<!--示例:<b>https://m.xdingdiann.com/sort/0/1.html</b>
|
||||||
|
<li><input type="text" id="updateBookListUrl" class="s_input icon_key"
|
||||||
|
placeholder="小说更新列表url"></li>-->
|
||||||
|
|
||||||
|
|
||||||
|
<li><input type="button" onclick="addCrawlSingleTask()" name="btnRegister" value="提交"
|
||||||
|
id="btnRegister" class="btn_red"></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
<script src="/javascript/jquery-1.8.0.min.js" type="text/javascript"></script>
|
||||||
|
<script src="/layui/layui.all.js" type="text/javascript"></script>
|
||||||
|
<script src="/javascript/header.js" type="text/javascript"></script>
|
||||||
|
<script src="/javascript/user.js" type="text/javascript"></script>
|
||||||
|
<script language="javascript" type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/crawl/listCrawlByPage",
|
||||||
|
data: {'curr':1,'limit':100},
|
||||||
|
dataType: "json",
|
||||||
|
success: function (data) {
|
||||||
|
if (data.code == 200) {
|
||||||
|
var crawlSourceList = data.data.list;
|
||||||
|
if (crawlSourceList.length > 0) {
|
||||||
|
var crawlSourceListHtml = "";
|
||||||
|
for(var i=0;i<crawlSourceList.length;i++){
|
||||||
|
var crawlSource = crawlSourceList[i];
|
||||||
|
crawlSourceListHtml+=("<option value=\""+crawlSource.id+"\">"+crawlSource.sourceName+"</option>");
|
||||||
|
}
|
||||||
|
$("#sourceId").html(crawlSourceListHtml);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else if (data.code == 1001) {
|
||||||
|
//未登录
|
||||||
|
location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href);
|
||||||
|
|
||||||
|
}else {
|
||||||
|
layer.alert(data.msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
layer.alert('网络异常');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function addCrawlSingleTask() {
|
||||||
|
|
||||||
|
var sourceId = $("#sourceId").find("option:selected").val();
|
||||||
|
|
||||||
|
var catId = $("#catId").find("option:selected").val();
|
||||||
|
|
||||||
|
var sourceName = $("#sourceId").find("option:selected").html();
|
||||||
|
|
||||||
|
|
||||||
|
var sourceBookId = $("#sourceBookId").val();
|
||||||
|
|
||||||
|
if (!sourceBookId){
|
||||||
|
layer.alert("采集的源站小说ID不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bookName = $("#bookName").val();
|
||||||
|
|
||||||
|
if (!bookName){
|
||||||
|
layer.alert("采集的小说名不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var authorName = $("#authorName").val();
|
||||||
|
|
||||||
|
if (!authorName){
|
||||||
|
layer.alert("采集的小说作者名不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/crawl/addCrawlSingleTask",
|
||||||
|
data: {'sourceId': sourceId, 'sourceName': sourceName,'catId':catId,'sourceBookId' : sourceBookId,'bookName':bookName,'authorName':authorName},
|
||||||
|
dataType: "json",
|
||||||
|
success: function (data) {
|
||||||
|
if (data.code == 200) {
|
||||||
|
|
||||||
|
window.location.href = '/crawl/crawlSingleTask_list.html';
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
layer.alert(data.msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
layer.alert('网络异常');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</html>
|
@ -0,0 +1,230 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||||
|
<title>爬虫管理系统-小说精品屋</title>
|
||||||
|
<link rel="stylesheet" href="/css/base.css?v=1"/>
|
||||||
|
<link rel="stylesheet" href="/css/user.css"/>
|
||||||
|
</head>
|
||||||
|
</head>
|
||||||
|
<body class="">
|
||||||
|
|
||||||
|
<div class="header">
|
||||||
|
<div class="mainNav" id="mainNav">
|
||||||
|
<div class="box_center cf"
|
||||||
|
style="text-align: center;height: 44px;line-height: 48px;color: #fff;font-size: 16px;">
|
||||||
|
|
||||||
|
小说精品屋爬虫管理
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="main box_center cf">
|
||||||
|
<div class="userBox cf">
|
||||||
|
<div class="my_l">
|
||||||
|
|
||||||
|
<ul class="log_list">
|
||||||
|
<li><a class="link_1" href="/">爬虫源管理</a></li>
|
||||||
|
<li><a class="link_1 on" href="/crawl/crawlSingleTask_list.html">单本采集管理</a></li>
|
||||||
|
<!-- <li><a class="link_1 " href="/user/userinfo.html">批量小说爬取</a></li>
|
||||||
|
<li><a class="link_4 " href="/user/favorites.html">单本小说爬取</a></li>-->
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="my_r">
|
||||||
|
<div class="my_bookshelf">
|
||||||
|
<div class="title cf">
|
||||||
|
<h2 class="fl">单本采集任务列表</h2>
|
||||||
|
<div class="fr"><a href="/crawl/crawlSingleTask_add.html" class="btn_red">增加单本采集任务</a></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="divData" class="updateTable">
|
||||||
|
<table cellpadding="0" cellspacing="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="style">
|
||||||
|
序号
|
||||||
|
</th>
|
||||||
|
<th class="name">
|
||||||
|
采集小说名
|
||||||
|
</th>
|
||||||
|
<th class="name">
|
||||||
|
采集小说作者名
|
||||||
|
</th>
|
||||||
|
<th class="goread">
|
||||||
|
采集次数
|
||||||
|
</th>
|
||||||
|
<th class="goread">
|
||||||
|
状态
|
||||||
|
</th>
|
||||||
|
<th class="name">
|
||||||
|
创建时间
|
||||||
|
</th>
|
||||||
|
<th class="goread">
|
||||||
|
操作
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="crawlSourceList">
|
||||||
|
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="pageBox cf" id="shellPage">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--<div id="divData" class="updateTable">
|
||||||
|
<table cellpadding="0" cellspacing="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th class="name">
|
||||||
|
爬虫源(已开启的爬虫源)
|
||||||
|
</th>
|
||||||
|
<th class="chapter">
|
||||||
|
成功爬取数量(websocket实现)
|
||||||
|
</th>
|
||||||
|
<th class="time">
|
||||||
|
目标爬取数量
|
||||||
|
</th>
|
||||||
|
<th class="goread">
|
||||||
|
状态(正在运行,已停止)(一次只能运行一个爬虫源)
|
||||||
|
</th>
|
||||||
|
<th class="goread">
|
||||||
|
操作(启动,停止)
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="bookShelfList">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="pageBox cf" id="shellPage">
|
||||||
|
</div>
|
||||||
|
</div>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
<script src="/javascript/jquery-1.8.0.min.js" type="text/javascript"></script>
|
||||||
|
<script src="/layui/layui.all.js" type="text/javascript"></script>
|
||||||
|
<script src="/javascript/header.js" type="text/javascript"></script>
|
||||||
|
<script src="/javascript/user.js" type="text/javascript"></script>
|
||||||
|
<script language="javascript" type="text/javascript">
|
||||||
|
search(1, 10);
|
||||||
|
|
||||||
|
function search(curr, limit) {
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/crawl/listCrawlSingleTaskByPage",
|
||||||
|
data: {'curr': curr, 'limit': limit},
|
||||||
|
dataType: "json",
|
||||||
|
success: function (data) {
|
||||||
|
if (data.code == 200) {
|
||||||
|
var crawlSourceList = data.data.list;
|
||||||
|
if (crawlSourceList.length > 0) {
|
||||||
|
var crawlSourceListHtml = "";
|
||||||
|
for (var i = 0; i < crawlSourceList.length; i++) {
|
||||||
|
var crawlSource = crawlSourceList[i];
|
||||||
|
crawlSourceListHtml += (" <tr class=\"book_list\" vals=\"291\">\n" +
|
||||||
|
" <td class=\"style bookclass\">\n" +
|
||||||
|
" [" + (i + 1) + "]\n" +
|
||||||
|
" </td>\n" +
|
||||||
|
" <td class=\"name\">\n" +
|
||||||
|
" " + crawlSource.bookName + "\n" +
|
||||||
|
" </td>\n" +
|
||||||
|
" <td class=\"name\">\n" +
|
||||||
|
" " + crawlSource.authorName + "\n" +
|
||||||
|
" </td>\n" +
|
||||||
|
" <td class=\"goread\">\n" +
|
||||||
|
" " + crawlSource.excCount + "\n" +
|
||||||
|
" </td>\n" +
|
||||||
|
" <td class=\"goread\">\n" +
|
||||||
|
" " + (crawlSource.taskStatus == 0 ? '采集失败' : (crawlSource.taskStatus == 1 ? '采集成功' : (crawlSource.excCount>0?'采集中':'排队中'))) + "\n" +
|
||||||
|
" </td>\n" +
|
||||||
|
" <td class=\"name\" valsc=\"291|2037554|1\">"
|
||||||
|
+ crawlSource.createTime + "</td>\n" +
|
||||||
|
|
||||||
|
" <td class=\"goread\" id='opt" + crawlSource.id + "'><a href='javascript:del(" + crawlSource.id + ")'>删除 </a></td> </tr>");
|
||||||
|
}
|
||||||
|
$("#crawlSourceList").html(crawlSourceListHtml);
|
||||||
|
|
||||||
|
layui.use('laypage', function () {
|
||||||
|
var laypage = layui.laypage;
|
||||||
|
|
||||||
|
//执行一个laypage实例
|
||||||
|
laypage.render({
|
||||||
|
elem: 'shellPage' //注意,这里的 test1 是 ID,不用加 # 号
|
||||||
|
, count: data.data.total //数据总数,从服务端得到,
|
||||||
|
, curr: data.data.pageNum
|
||||||
|
, limit: data.data.pageSize
|
||||||
|
, jump: function (obj, first) {
|
||||||
|
|
||||||
|
|
||||||
|
//obj包含了当前分页的所有参数,比如:
|
||||||
|
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
|
||||||
|
console.log(obj.limit); //得到每页显示的条数
|
||||||
|
|
||||||
|
|
||||||
|
//首次不执行
|
||||||
|
if (!first) {
|
||||||
|
search(obj.curr, obj.limit);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
layer.alert(data.msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
layer.alert('网络异常');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function del(id) {
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/crawl/delCrawlSingleTask",
|
||||||
|
data: {'id': id},
|
||||||
|
dataType: "json",
|
||||||
|
success: function (data) {
|
||||||
|
if (data.code == 200) {
|
||||||
|
location.reload();
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
layer.alert(data.msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
layer.alert('网络异常');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</html>
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
<ul class="log_list">
|
<ul class="log_list">
|
||||||
<li><a class="link_1 on" href="/">爬虫源管理</a></li>
|
<li><a class="link_1 on" href="/">爬虫源管理</a></li>
|
||||||
|
<li><a class="link_1" href="/crawl/crawlSingleTask_list.html">单本采集管理</a></li>
|
||||||
<!--<li><a class="link_1 " href="/user/userinfo.html">批量小说爬取</a></li>
|
<!--<li><a class="link_1 " href="/user/userinfo.html">批量小说爬取</a></li>
|
||||||
<li><a class="link_4 " href="/user/favorites.html">单本小说爬取</a></li>-->
|
<li><a class="link_4 " href="/user/favorites.html">单本小说爬取</a></li>-->
|
||||||
</ul>
|
</ul>
|
||||||
@ -57,6 +58,9 @@
|
|||||||
<li><span id="LabErr"></span></li>
|
<li><span id="LabErr"></span></li>
|
||||||
示例:<b>新顶点小说网</b>
|
示例:<b>新顶点小说网</b>
|
||||||
<li><input type="text" id="sourceName" class="s_input icon_name" placeholder="源站名"></li>
|
<li><input type="text" id="sourceName" class="s_input icon_name" placeholder="源站名"></li>
|
||||||
|
<!--示例:<b>https://m.xdingdiann.com/sort/0/1.html</b>
|
||||||
|
<li><input type="text" id="updateBookListUrl" class="s_input icon_key"
|
||||||
|
placeholder="小说更新列表url"></li>-->
|
||||||
示例:<b>http://m.xdingdiann.com/sort/{catId}/{page}.html</b> ({catId}代表分类ID,{page}代表分页页码)
|
示例:<b>http://m.xdingdiann.com/sort/{catId}/{page}.html</b> ({catId}代表分类ID,{page}代表分页页码)
|
||||||
<li><input type="text" id="bookListUrl" class="s_input icon_key"
|
<li><input type="text" id="bookListUrl" class="s_input icon_key"
|
||||||
placeholder="分类列表页URL规则"></li>
|
placeholder="分类列表页URL规则"></li>
|
||||||
@ -95,6 +99,9 @@
|
|||||||
示例:<b><img src="([^>]+)"\s+onerror="this.src=</b>
|
示例:<b><img src="([^>]+)"\s+onerror="this.src=</b>
|
||||||
<li><input type="text" id="picUrlPatten" class="s_input icon_key"
|
<li><input type="text" id="picUrlPatten" class="s_input icon_key"
|
||||||
placeholder="小说图片路径的正则表达式:"></li>
|
placeholder="小说图片路径的正则表达式:"></li>
|
||||||
|
<b>可空,适用于图片路径为相对路径的源站,加上小说图片路径,则为完整的可访问的图片路径</b>
|
||||||
|
<li><input type="text" id="picUrlPrefix" class="s_input icon_key"
|
||||||
|
placeholder="小说图片访问路径前缀:"></li>
|
||||||
示例:<b>状态:([^/]+)</li></b>
|
示例:<b>状态:([^/]+)</li></b>
|
||||||
<li><input type="text" id="statusPatten" class="s_input icon_key"
|
<li><input type="text" id="statusPatten" class="s_input icon_key"
|
||||||
placeholder="小说状态的正则表达式:"></li>
|
placeholder="小说状态的正则表达式:"></li>
|
||||||
@ -125,6 +132,9 @@
|
|||||||
示例:<b>http://m.xdingdiann.com/ddk{bookId}/all.html</b> (bookId代表小说ID)
|
示例:<b>http://m.xdingdiann.com/ddk{bookId}/all.html</b> (bookId代表小说ID)
|
||||||
<li><input type="text" id="bookIndexUrl" class="s_input icon_key"
|
<li><input type="text" id="bookIndexUrl" class="s_input icon_key"
|
||||||
placeholder="小说目录页的URL规则:"></li>
|
placeholder="小说目录页的URL规则:"></li>
|
||||||
|
<b>可空,适用于最新章节列表和全部章节列表在同一个页面的源站</b>
|
||||||
|
<li><input type="text" id="bookIndexStart" class="s_input icon_key"
|
||||||
|
placeholder="小说目录页内容开始截取字符串:"></li>
|
||||||
示例:<b><a\s+style=""\s+href="/ddk\d+/(\d+)\.html">[^/]+</a></b>
|
示例:<b><a\s+style=""\s+href="/ddk\d+/(\d+)\.html">[^/]+</a></b>
|
||||||
<li><input type="text" id="indexIdPatten" class="s_input icon_key"
|
<li><input type="text" id="indexIdPatten" class="s_input icon_key"
|
||||||
placeholder="目录页目录ID正则表达式:"></li>
|
placeholder="目录页目录ID正则表达式:"></li>
|
||||||
@ -278,6 +288,12 @@
|
|||||||
crawlRule.picUrlPatten = picUrlPatten;
|
crawlRule.picUrlPatten = picUrlPatten;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var picUrlPrefix = $("#picUrlPrefix").val();
|
||||||
|
|
||||||
|
if (picUrlPrefix.length > 0) {
|
||||||
|
crawlRule.picUrlPrefix = picUrlPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
var statusPatten = $("#statusPatten").val();
|
var statusPatten = $("#statusPatten").val();
|
||||||
if (statusPatten.length > 0) {
|
if (statusPatten.length > 0) {
|
||||||
crawlRule.statusPatten = statusPatten;
|
crawlRule.statusPatten = statusPatten;
|
||||||
@ -345,6 +361,13 @@
|
|||||||
|
|
||||||
crawlRule.bookIndexUrl = bookIndexUrl;
|
crawlRule.bookIndexUrl = bookIndexUrl;
|
||||||
|
|
||||||
|
|
||||||
|
var bookIndexStart = $("#bookIndexStart").val();
|
||||||
|
|
||||||
|
if (bookIndexStart.length > 0) {
|
||||||
|
crawlRule.bookIndexStart = bookIndexStart;
|
||||||
|
}
|
||||||
|
|
||||||
var indexIdPatten = $("#indexIdPatten").val();
|
var indexIdPatten = $("#indexIdPatten").val();
|
||||||
|
|
||||||
if (indexIdPatten.length == 0) {
|
if (indexIdPatten.length == 0) {
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
<ul class="log_list">
|
<ul class="log_list">
|
||||||
<li><a class="link_1 on" href="/">爬虫源管理</a></li>
|
<li><a class="link_1 on" href="/">爬虫源管理</a></li>
|
||||||
|
<li><a class="link_1" href="/crawl/crawlSingleTask_list.html">单本采集管理</a></li>
|
||||||
<!-- <li><a class="link_1 " href="/user/userinfo.html">批量小说爬取</a></li>
|
<!-- <li><a class="link_1 " href="/user/userinfo.html">批量小说爬取</a></li>
|
||||||
<li><a class="link_4 " href="/user/favorites.html">单本小说爬取</a></li>-->
|
<li><a class="link_4 " href="/user/favorites.html">单本小说爬取</a></li>-->
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>novel</artifactId>
|
<artifactId>novel</artifactId>
|
||||||
<groupId>com.java2nb</groupId>
|
<groupId>com.java2nb</groupId>
|
||||||
<version>2.0.1</version>
|
<version>2.6.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -27,11 +27,57 @@
|
|||||||
<version>${jjwt.version}</version>
|
<version>${jjwt.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.searchbox</groupId>
|
||||||
|
<artifactId>jest</artifactId>
|
||||||
|
<version>${jest.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--aliyunOSS-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun.oss</groupId>
|
||||||
|
<artifactId>aliyun-sdk-oss</artifactId>
|
||||||
|
<version>${aliyun-sdk-oss.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-fileupload</groupId>
|
||||||
|
<artifactId>commons-fileupload</artifactId>
|
||||||
|
<version>${commons-fileupload.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--FastDfs-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.tobato</groupId>
|
||||||
|
<artifactId>fastdfs-client</artifactId>
|
||||||
|
<version>${fastdfs-client.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!--引入redisson分布式锁-->
|
||||||
|
<!-- <dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
|
<version>${redisson.version}</version>
|
||||||
|
</dependency>-->
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alipay.sdk</groupId>
|
<groupId>com.alipay.sdk</groupId>
|
||||||
<artifactId>alipay-sdk-java</artifactId>
|
<artifactId>alipay-sdk-java</artifactId>
|
||||||
<version>4.9.153.ALL</version>
|
<version>${alipay-sdk-java.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package com.java2nb.novel;
|
package com.java2nb.novel;
|
||||||
|
|
||||||
|
import com.github.tobato.fastdfs.FdfsClientConfig;
|
||||||
|
import io.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.scheduling.TaskScheduler;
|
import org.springframework.scheduling.TaskScheduler;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
@ -18,6 +21,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
@MapperScan(basePackages = {"com.java2nb.novel.mapper"})
|
@MapperScan(basePackages = {"com.java2nb.novel.mapper"})
|
||||||
|
@Import(FdfsClientConfig.class)
|
||||||
public class FrontNovelApplication {
|
public class FrontNovelApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -55,7 +55,7 @@ public class AuthorController extends BaseController{
|
|||||||
* 发布小说
|
* 发布小说
|
||||||
* */
|
* */
|
||||||
@PostMapping("addBook")
|
@PostMapping("addBook")
|
||||||
public ResultBean addBook(Book book,HttpServletRequest request){
|
public ResultBean addBook(@RequestParam("bookDesc") String bookDesc,Book book,HttpServletRequest request){
|
||||||
|
|
||||||
//查询作家信息
|
//查询作家信息
|
||||||
Author author = authorService.queryAuthor(getUserDetails(request).getId());
|
Author author = authorService.queryAuthor(getUserDetails(request).getId());
|
||||||
@ -67,6 +67,10 @@ public class AuthorController extends BaseController{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//bookDesc不能使用book对象来接收,否则会自动去掉前面的空格
|
||||||
|
book.setBookDesc(bookDesc
|
||||||
|
.replaceAll("\\n","<br>")
|
||||||
|
.replaceAll("\\s"," "));
|
||||||
//发布小说
|
//发布小说
|
||||||
bookService.addBook(book,author.getId(),author.getPenName());
|
bookService.addBook(book,author.getId(),author.getPenName());
|
||||||
|
|
||||||
@ -109,6 +113,8 @@ public class AuthorController extends BaseController{
|
|||||||
return ResultBean.fail(ResponseStatus.AUTHOR_STATUS_FORBIDDEN);
|
return ResultBean.fail(ResponseStatus.AUTHOR_STATUS_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content = content.replaceAll("\\n","<br>")
|
||||||
|
.replaceAll("\\s"," ");
|
||||||
//发布章节内容
|
//发布章节内容
|
||||||
bookService.addBookContent(bookId,indexName,content,author.getId());
|
bookService.addBookContent(bookId,indexName,content,author.getId());
|
||||||
|
|
||||||
|
@ -4,14 +4,14 @@ import com.github.pagehelper.PageInfo;
|
|||||||
import com.java2nb.novel.core.bean.ResultBean;
|
import com.java2nb.novel.core.bean.ResultBean;
|
||||||
import com.java2nb.novel.core.bean.UserDetails;
|
import com.java2nb.novel.core.bean.UserDetails;
|
||||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||||
import com.java2nb.novel.entity.Book;
|
|
||||||
import com.java2nb.novel.entity.BookComment;
|
import com.java2nb.novel.entity.BookComment;
|
||||||
import com.java2nb.novel.entity.BookIndex;
|
|
||||||
import com.java2nb.novel.search.BookSP;
|
import com.java2nb.novel.search.BookSP;
|
||||||
import com.java2nb.novel.service.BookService;
|
import com.java2nb.novel.service.BookService;
|
||||||
import com.java2nb.novel.vo.BookVO;
|
import com.java2nb.novel.vo.BookVO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,6 +32,11 @@ public class BookController extends BaseController{
|
|||||||
|
|
||||||
private final BookService bookService;
|
private final BookService bookService;
|
||||||
|
|
||||||
|
private final RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
@Value("${spring.rabbitmq.enable}")
|
||||||
|
private Integer enableMq;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询首页小说设置列表数据
|
* 查询首页小说设置列表数据
|
||||||
@ -79,8 +83,8 @@ public class BookController extends BaseController{
|
|||||||
* */
|
* */
|
||||||
@PostMapping("searchByPage")
|
@PostMapping("searchByPage")
|
||||||
public ResultBean searchByPage(BookSP bookSP, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "20") int pageSize){
|
public ResultBean searchByPage(BookSP bookSP, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "20") int pageSize){
|
||||||
List<BookVO> books = bookService.searchByPage(bookSP,page,pageSize);
|
PageInfo<BookVO> pageInfo = bookService.searchByPage(bookSP,page,pageSize);
|
||||||
return ResultBean.ok(new PageInfo<>(books));
|
return ResultBean.ok(pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,7 +109,11 @@ public class BookController extends BaseController{
|
|||||||
* */
|
* */
|
||||||
@PostMapping("addVisitCount")
|
@PostMapping("addVisitCount")
|
||||||
public ResultBean addVisitCount(Long bookId){
|
public ResultBean addVisitCount(Long bookId){
|
||||||
bookService.addVisitCount(bookId);
|
if(enableMq == 1) {
|
||||||
|
rabbitTemplate.convertAndSend("ADD-BOOK-VISIT-EXCHANGE", null, bookId);
|
||||||
|
}else {
|
||||||
|
bookService.addVisitCount(bookId, 1);
|
||||||
|
}
|
||||||
return ResultBean.ok();
|
return ResultBean.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,32 @@
|
|||||||
package com.java2nb.novel.controller;
|
package com.java2nb.novel.controller;
|
||||||
|
|
||||||
|
import com.java2nb.novel.core.bean.ResultBean;
|
||||||
import com.java2nb.novel.core.cache.CacheService;
|
import com.java2nb.novel.core.cache.CacheService;
|
||||||
|
import com.java2nb.novel.core.utils.Constants;
|
||||||
import com.java2nb.novel.core.utils.RandomValidateCodeUtil;
|
import com.java2nb.novel.core.utils.RandomValidateCodeUtil;
|
||||||
|
import com.java2nb.novel.core.utils.RestTemplateUtil;
|
||||||
|
import com.java2nb.novel.core.utils.UUIDUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.codec.Charsets;
|
||||||
|
import org.apache.http.client.utils.DateUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 11797
|
* @author 11797
|
||||||
@ -24,6 +39,9 @@ public class FileController {
|
|||||||
|
|
||||||
private final CacheService cacheService;
|
private final CacheService cacheService;
|
||||||
|
|
||||||
|
@Value("${pic.save.path}")
|
||||||
|
private String picSavePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成验证码
|
* 生成验证码
|
||||||
*/
|
*/
|
||||||
@ -44,5 +62,32 @@ public class FileController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传
|
||||||
|
*/
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/upload")
|
||||||
|
ResultBean upload(@RequestParam("file") MultipartFile file) {
|
||||||
|
Date currentDate = new Date();
|
||||||
|
try {
|
||||||
|
String savePath =
|
||||||
|
Constants.LOCAL_PIC_PREFIX + DateUtils.formatDate(currentDate, "yyyy") + "/" +
|
||||||
|
DateUtils.formatDate(currentDate, "MM") + "/" +
|
||||||
|
DateUtils.formatDate(currentDate, "dd") ;
|
||||||
|
String oriName = file.getOriginalFilename();
|
||||||
|
String saveFileName = UUIDUtil.getUUID32() + oriName.substring(oriName.lastIndexOf("."));
|
||||||
|
File saveFile = new File( picSavePath + savePath, saveFileName);
|
||||||
|
if (!saveFile.getParentFile().exists()) {
|
||||||
|
saveFile.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
file.transferTo(saveFile);
|
||||||
|
return ResultBean.ok(savePath+"/"+saveFileName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return ResultBean.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.java2nb.novel.core.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.EnableMBeanExport;
|
||||||
|
import org.springframework.jmx.support.RegistrationPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@EnableMBeanExport(registration= RegistrationPolicy.IGNORE_EXISTING)
|
||||||
|
public class FdfsConfiguration {
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.java2nb.novel.core.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix="novel.file")
|
||||||
|
public class OssProperties{
|
||||||
|
|
||||||
|
private String endpoint;
|
||||||
|
|
||||||
|
private String keyId;
|
||||||
|
|
||||||
|
private String keySecret;
|
||||||
|
|
||||||
|
private String fileHost;
|
||||||
|
|
||||||
|
private String bucketName;
|
||||||
|
|
||||||
|
private String webUrl;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.java2nb.novel.core.config;
|
||||||
|
|
||||||
|
import org.springframework.amqp.core.*;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "enable", havingValue = "1")
|
||||||
|
public class RabbitConfig {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据库队列
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Queue updateDbQueue() {
|
||||||
|
return new Queue("UPDATE-DB-QUEUE", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据库队列
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Queue updateEsQueue() {
|
||||||
|
return new Queue("UPDATE-ES-QUEUE", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加点击量交换机
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public FanoutExchange addVisitExchange() {
|
||||||
|
return new FanoutExchange("ADD-BOOK-VISIT-EXCHANGE");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新搜索引擎队列绑定到增加点击量交换机中
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Binding updateEsBinding() {
|
||||||
|
|
||||||
|
return BindingBuilder.bind(updateEsQueue()).to(addVisitExchange());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据库绑定到增加点击量交换机中
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Binding updateDbBinding() {
|
||||||
|
return BindingBuilder.bind(updateDbQueue()).to(addVisitExchange());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,107 @@
|
|||||||
|
package com.java2nb.novel.core.listener;
|
||||||
|
|
||||||
|
import com.java2nb.novel.core.cache.CacheKey;
|
||||||
|
import com.java2nb.novel.core.cache.CacheService;
|
||||||
|
import com.java2nb.novel.core.utils.Constants;
|
||||||
|
import com.java2nb.novel.entity.Book;
|
||||||
|
import com.java2nb.novel.service.BookService;
|
||||||
|
import com.java2nb.novel.service.SearchService;
|
||||||
|
import com.java2nb.novel.vo.EsBookVO;
|
||||||
|
import com.rabbitmq.client.Channel;
|
||||||
|
import io.searchbox.client.JestClient;
|
||||||
|
import io.searchbox.core.Index;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.amqp.core.Message;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "enable", havingValue = "1")
|
||||||
|
public class BookVisitAddListener {
|
||||||
|
|
||||||
|
private final BookService bookService;
|
||||||
|
|
||||||
|
private final CacheService cacheService;
|
||||||
|
|
||||||
|
private final SearchService searchService;
|
||||||
|
|
||||||
|
// private final RedissonClient redissonClient;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据库
|
||||||
|
* 流量削峰,每本小说累积10个点击更新一次
|
||||||
|
*/
|
||||||
|
@SneakyThrows
|
||||||
|
@RabbitListener(queues = {"UPDATE-DB-QUEUE"})
|
||||||
|
public void updateDb(Long bookId, Channel channel, Message message) {
|
||||||
|
|
||||||
|
log.debug("收到更新数据库消息:" + bookId);
|
||||||
|
Thread.sleep(1000 * 2);
|
||||||
|
//TODO 操作共享资源visitCount,集群环境下有线程安全问题,引入Redisson框架实现分布式锁
|
||||||
|
//RLock lock = redissonClient.getLock("visitCount");
|
||||||
|
//lock.lock();
|
||||||
|
|
||||||
|
|
||||||
|
//目前visitCount不重要,数据可丢失,暂不实现分布式锁
|
||||||
|
Integer visitCount = (Integer) cacheService.getObject(CacheKey.BOOK_ADD_VISIT_COUNT+bookId);
|
||||||
|
if(visitCount == null){
|
||||||
|
visitCount = 0 ;
|
||||||
|
}
|
||||||
|
cacheService.setObject(CacheKey.BOOK_ADD_VISIT_COUNT+bookId,++visitCount);
|
||||||
|
if(visitCount >= Constants.ADD_MAX_VISIT_COUNT) {
|
||||||
|
bookService.addVisitCount(bookId,visitCount);
|
||||||
|
cacheService.del(CacheKey.BOOK_ADD_VISIT_COUNT+bookId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO 操作共享资源visitCount,集群环境下有线程安全问题,引入Redisson框架实现分布式锁
|
||||||
|
//lock.unlock();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新搜索引擎
|
||||||
|
* 流量削峰,每本小说1个小时更新一次
|
||||||
|
*/
|
||||||
|
@RabbitListener(queues = {"UPDATE-ES-QUEUE"})
|
||||||
|
public void updateEs(Long bookId, Channel channel, Message message) {
|
||||||
|
|
||||||
|
log.debug("收到更新搜索引擎消息:" + bookId);
|
||||||
|
if (cacheService.get(CacheKey.ES_IS_UPDATE_VISIT + bookId) == null) {
|
||||||
|
cacheService.set(CacheKey.ES_IS_UPDATE_VISIT + bookId, "1", 60 * 60);
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000 * 5);
|
||||||
|
Book book = bookService.queryBookDetail(bookId);
|
||||||
|
searchService.importToEs(book);
|
||||||
|
}catch (Exception e){
|
||||||
|
cacheService.del(CacheKey.ES_IS_UPDATE_VISIT + bookId);
|
||||||
|
log.error("更新搜索引擎失败"+bookId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
package com.java2nb.novel.core.schedule;
|
||||||
|
|
||||||
|
import com.java2nb.novel.core.cache.CacheKey;
|
||||||
|
import com.java2nb.novel.core.cache.CacheService;
|
||||||
|
import com.java2nb.novel.core.utils.BeanUtil;
|
||||||
|
import com.java2nb.novel.entity.Book;
|
||||||
|
import com.java2nb.novel.service.BookService;
|
||||||
|
import com.java2nb.novel.service.SearchService;
|
||||||
|
import com.java2nb.novel.vo.EsBookVO;
|
||||||
|
import io.searchbox.client.JestClient;
|
||||||
|
import io.searchbox.core.DocumentResult;
|
||||||
|
import io.searchbox.core.Index;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
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 java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小说导入搜索引擎
|
||||||
|
*
|
||||||
|
* @author Administrator
|
||||||
|
*/
|
||||||
|
@ConditionalOnProperty(prefix = "spring.elasticsearch", name = "enable", havingValue = "1")
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class BookToEsSchedule {
|
||||||
|
|
||||||
|
private final BookService bookService;
|
||||||
|
|
||||||
|
private final CacheService cacheService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private final SearchService searchService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1分钟导入一次
|
||||||
|
*/
|
||||||
|
@Scheduled(fixedRate = 1000 * 60)
|
||||||
|
public void saveToEs() {
|
||||||
|
//TODO 引入Redisson框架实现分布式锁
|
||||||
|
//可以重复更新,只是效率可能略有降低,所以暂不实现分布式锁
|
||||||
|
if (cacheService.get(CacheKey.ES_TRANS_LOCK) == null) {
|
||||||
|
cacheService.set(CacheKey.ES_TRANS_LOCK, "1", 60 * 20);
|
||||||
|
try {
|
||||||
|
//查询需要更新的小说
|
||||||
|
Date lastDate = (Date) cacheService.getObject(CacheKey.ES_LAST_UPDATE_TIME);
|
||||||
|
if (lastDate == null) {
|
||||||
|
lastDate = new SimpleDateFormat("yyyy-MM-dd").parse("2020-01-01");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<Book> books = bookService.queryBookByUpdateTimeByPage(lastDate, 100);
|
||||||
|
for (Book book : books) {
|
||||||
|
searchService.importToEs(book);
|
||||||
|
lastDate = book.getUpdateTime();
|
||||||
|
Thread.sleep(5000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cacheService.setObject(CacheKey.ES_LAST_UPDATE_TIME, lastDate);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
cacheService.del(CacheKey.ES_TRANS_LOCK);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,8 +1,10 @@
|
|||||||
package com.java2nb.novel.core.schedule;
|
package com.java2nb.novel.core.schedule;
|
||||||
|
|
||||||
|
import com.java2nb.novel.core.utils.Constants;
|
||||||
import com.java2nb.novel.entity.Book;
|
import com.java2nb.novel.entity.Book;
|
||||||
import com.java2nb.novel.service.BookService;
|
import com.java2nb.novel.service.BookService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
@ -12,14 +14,15 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网络图片转存本地任务
|
* 将爬取的网络图片转存为自己的存储介质(本地、OSS、fastDfs)任务
|
||||||
|
*
|
||||||
* @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
|
||||||
public class Network2LocalPicSchedule {
|
public class CrawlPicTransSchedule {
|
||||||
|
|
||||||
private final BookService bookService;
|
private final BookService bookService;
|
||||||
|
|
||||||
@ -33,20 +36,18 @@ public class Network2LocalPicSchedule {
|
|||||||
* 10分钟转一次
|
* 10分钟转一次
|
||||||
*/
|
*/
|
||||||
@Scheduled(fixedRate = 1000 * 60 * 10)
|
@Scheduled(fixedRate = 1000 * 60 * 10)
|
||||||
|
@SneakyThrows
|
||||||
public void trans() {
|
public void trans() {
|
||||||
|
|
||||||
log.info("Network2LocalPicSchedule。。。。。。。。。。。。");
|
log.info("Network2LocalPicSchedule。。。。。。。。。。。。");
|
||||||
|
|
||||||
|
|
||||||
Integer offset = 0, limit = 100;
|
List<Book> networkPicBooks = bookService.queryNetworkPicBooks(Constants.LOCAL_PIC_PREFIX,100);
|
||||||
List<Book> networkPicBooks;
|
for (Book book : networkPicBooks) {
|
||||||
do {
|
bookService.updateBookPicToLocal(book.getPicUrl(), book.getId());
|
||||||
networkPicBooks = bookService.queryNetworkPicBooks(limit, offset);
|
//3秒钟转化一张图片,10分钟转化200张
|
||||||
for (Book book : networkPicBooks) {
|
Thread.sleep(3000);
|
||||||
bookService.updateBookPicToLocal(book.getPicUrl(), book.getId());
|
}
|
||||||
}
|
|
||||||
offset += limit;
|
|
||||||
} while (networkPicBooks.size() > 0);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -18,19 +18,20 @@ public class BrowserUtil {
|
|||||||
"lg-d", "lg-g", "lge-", "maui", "maxo", "midp", "mits", "mmef", "mobi", "mot-", "moto", "mwbp", "nec-",
|
"lg-d", "lg-g", "lge-", "maui", "maxo", "midp", "mits", "mmef", "mobi", "mot-", "moto", "mwbp", "nec-",
|
||||||
"newt", "noki", "oper", "palm", "pana", "pant", "phil", "play", "port", "prox", "qwap", "sage", "sams",
|
"newt", "noki", "oper", "palm", "pana", "pant", "phil", "play", "port", "prox", "qwap", "sage", "sams",
|
||||||
"sany", "sch-", "sec-", "send", "seri", "sgh-", "shar", "sie-", "siem", "smal", "smar", "sony", "sph-",
|
"sany", "sch-", "sec-", "send", "seri", "sgh-", "shar", "sie-", "siem", "smal", "smar", "sony", "sph-",
|
||||||
"symb", "t-mo", "teli", "tim-", "tosh", "tsm-", "upg1", "upsi", "vk-v", "voda", "wap-", "wapa", "wapi",
|
"symb", "t-mo", "teli", "tim-", "tsm-", "upg1", "upsi", "vk-v", "voda", "wap-", "wapa", "wapi",
|
||||||
"wapp", "wapr", "webc", "winw", "winw", "xda", "xda-", "Googlebot-Mobile" };
|
"wapp", "wapr", "webc", "winw", "winw", "xda", "xda-", "Googlebot-Mobile" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @Title: JudgelsMobile @Description: TODO(判断是否是手机浏览器) @param @param
|
* 判断是否是手机浏览器
|
||||||
* request @param @return 设定文件 @return boolean 返回类型 @throws
|
|
||||||
*/
|
*/
|
||||||
public static boolean isMobile(HttpServletRequest request) {
|
public static boolean isMobile(HttpServletRequest request) {
|
||||||
boolean isMobile = false;
|
boolean isMobile = false;
|
||||||
if (request.getHeader("User-Agent") != null) {
|
String userAgent = request.getHeader("User-Agent");
|
||||||
|
if (userAgent != null) {
|
||||||
|
userAgent = userAgent.toLowerCase();
|
||||||
for (String mobileAgent : mobileAgents) {
|
for (String mobileAgent : mobileAgents) {
|
||||||
if (request.getHeader("User-Agent").toLowerCase().indexOf(mobileAgent) > 0) {
|
if (userAgent.indexOf(mobileAgent) > 0) {
|
||||||
isMobile = true;
|
isMobile = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ public class Constants {
|
|||||||
public static final String TEMPLATE_PATH_PREFIX_KEY = "templatePathPrefixKey";
|
public static final String TEMPLATE_PATH_PREFIX_KEY = "templatePathPrefixKey";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地图片保存前缀
|
* 保存图片到自己的存储介质路径前缀
|
||||||
* */
|
* */
|
||||||
public static final String LOCAL_PIC_PREFIX = "/localPic/";
|
public static final String LOCAL_PIC_PREFIX = "/localPic/";
|
||||||
|
|
||||||
@ -30,4 +30,9 @@ public class Constants {
|
|||||||
* 首页设置的小说数量
|
* 首页设置的小说数量
|
||||||
* */
|
* */
|
||||||
public static final int INDEX_BOOK_SETTING_NUM = 32;
|
public static final int INDEX_BOOK_SETTING_NUM = 32;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累积的最大点击量
|
||||||
|
* */
|
||||||
|
public static final Integer ADD_MAX_VISIT_COUNT = 10;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.java2nb.novel.search.BookSP;
|
|||||||
import com.java2nb.novel.vo.BookVO;
|
import com.java2nb.novel.vo.BookVO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,13 +16,13 @@ public interface FrontBookMapper extends BookMapper {
|
|||||||
|
|
||||||
List<BookVO> searchByPage(BookSP params);
|
List<BookVO> searchByPage(BookSP params);
|
||||||
|
|
||||||
void addVisitCount(@Param("bookId") Long bookId);
|
void addVisitCount(@Param("bookId") Long bookId, @Param("visitCount") Integer visitCount);
|
||||||
|
|
||||||
List<Book> listRecBookByCatId(@Param("catId") Integer catId);
|
List<Book> listRecBookByCatId(@Param("catId") Integer catId);
|
||||||
|
|
||||||
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("localPicPrefix") String localPicPrefix, @Param("limit") Integer limit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按评分随机查询小说集合
|
* 按评分随机查询小说集合
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package com.java2nb.novel.service;
|
package com.java2nb.novel.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.java2nb.novel.search.BookSP;
|
import com.java2nb.novel.search.BookSP;
|
||||||
import com.java2nb.novel.vo.BookCommentVO;
|
import com.java2nb.novel.vo.BookCommentVO;
|
||||||
import com.java2nb.novel.vo.BookSettingVO;
|
import com.java2nb.novel.vo.BookSettingVO;
|
||||||
import com.java2nb.novel.entity.*;
|
import com.java2nb.novel.entity.*;
|
||||||
import com.java2nb.novel.vo.BookVO;
|
import com.java2nb.novel.vo.BookVO;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -44,9 +46,9 @@ public interface BookService {
|
|||||||
* @param params 搜索参数
|
* @param params 搜索参数
|
||||||
* @param page 页码
|
* @param page 页码
|
||||||
* @param pageSize 分页大小
|
* @param pageSize 分页大小
|
||||||
* @return 小说集合
|
* @return 小说集合分页信息
|
||||||
* */
|
* */
|
||||||
List<BookVO> searchByPage(BookSP params, int page, int pageSize);
|
PageInfo searchByPage(BookSP params, int page, int pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询小说分类列表
|
* 查询小说分类列表
|
||||||
@ -110,8 +112,8 @@ public interface BookService {
|
|||||||
/**
|
/**
|
||||||
* 增加点击次数
|
* 增加点击次数
|
||||||
* @param bookId 书籍ID
|
* @param bookId 书籍ID
|
||||||
* */
|
* @param visitCount*/
|
||||||
void addVisitCount(Long bookId);
|
void addVisitCount(Long bookId, Integer visitCount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询章节数
|
* 查询章节数
|
||||||
@ -178,16 +180,17 @@ public interface BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询网络图片的小说
|
* 查询网络图片的小说
|
||||||
|
*
|
||||||
|
* @param localPicPrefix
|
||||||
* @param limit 查询条数
|
* @param limit 查询条数
|
||||||
* @param offset 开始行数
|
|
||||||
* @return 返回小说集合
|
* @return 返回小说集合
|
||||||
* */
|
* */
|
||||||
List<Book> queryNetworkPicBooks(Integer limit, Integer offset);
|
List<Book> queryNetworkPicBooks(String localPicPrefix, Integer limit);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新小说网络图片到本地
|
* 更新爬取的小说网络图片到自己的存储介质(本地、OSS、fastDfs)
|
||||||
* @param picUrl 网络图片路径
|
* @param picUrl 爬取的网络图片路径
|
||||||
* @param bookId 小说ID
|
* @param bookId 小说ID
|
||||||
*/
|
*/
|
||||||
void updateBookPicToLocal(String picUrl, Long bookId);
|
void updateBookPicToLocal(String picUrl, Long bookId);
|
||||||
@ -197,6 +200,7 @@ public interface BookService {
|
|||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param page 页码
|
* @param page 页码
|
||||||
* @param pageSize 分页大小
|
* @param pageSize 分页大小
|
||||||
|
* @return 小说集合
|
||||||
* */
|
* */
|
||||||
List<Book> listBookPageByUserId(Long userId, int page, int pageSize);
|
List<Book> listBookPageByUserId(Long userId, int page, int pageSize);
|
||||||
|
|
||||||
@ -224,4 +228,13 @@ public interface BookService {
|
|||||||
* @param authorId 作者ID
|
* @param authorId 作者ID
|
||||||
* */
|
* */
|
||||||
void addBookContent(Long bookId, String indexName, String content, Long authorId);
|
void addBookContent(Long bookId, String indexName, String content, Long authorId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据更新时间分页查询书籍列表
|
||||||
|
* @param startDate 开始时间,包括该时间
|
||||||
|
* @param limit 查询数量
|
||||||
|
* @return 书籍列表
|
||||||
|
* */
|
||||||
|
List<Book> queryBookByUpdateTimeByPage(Date startDate, int limit);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.java2nb.novel.service;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
public interface FileService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将爬取的网络图片转存为自己的存储介质(本地、OSS、fastDfs)
|
||||||
|
* @param picSrc 爬取的网络图片路径
|
||||||
|
* @param picSavePath 保存路径
|
||||||
|
* @return 新图片地址
|
||||||
|
* */
|
||||||
|
String transFile(String picSrc, String picSavePath);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.java2nb.novel.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.java2nb.novel.entity.Book;
|
||||||
|
import com.java2nb.novel.search.BookSP;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
public interface SearchService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入到es
|
||||||
|
* @param book 小说数据
|
||||||
|
*/
|
||||||
|
void importToEs(Book book);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索
|
||||||
|
* @param params 搜索参数
|
||||||
|
* @param page 当前页码
|
||||||
|
* @param pageSize 每页大小
|
||||||
|
* @return 分页信息
|
||||||
|
*/
|
||||||
|
PageInfo searchBook(BookSP params, int page, int pageSize);
|
||||||
|
}
|
@ -2,25 +2,26 @@ package com.java2nb.novel.service.impl;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.java2nb.novel.core.cache.CacheKey;
|
import com.java2nb.novel.core.cache.CacheKey;
|
||||||
import com.java2nb.novel.core.cache.CacheService;
|
import com.java2nb.novel.core.cache.CacheService;
|
||||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||||
import com.java2nb.novel.core.exception.BusinessException;
|
import com.java2nb.novel.core.exception.BusinessException;
|
||||||
import com.java2nb.novel.core.utils.BeanUtil;
|
import com.java2nb.novel.core.utils.*;
|
||||||
import com.java2nb.novel.core.utils.Constants;
|
|
||||||
import com.java2nb.novel.core.utils.FileUtil;
|
|
||||||
import com.java2nb.novel.core.utils.IdWorker;
|
|
||||||
import com.java2nb.novel.entity.*;
|
import com.java2nb.novel.entity.*;
|
||||||
import com.java2nb.novel.entity.Book;
|
import com.java2nb.novel.entity.Book;
|
||||||
import com.java2nb.novel.mapper.*;
|
import com.java2nb.novel.mapper.*;
|
||||||
import com.java2nb.novel.search.BookSP;
|
import com.java2nb.novel.search.BookSP;
|
||||||
import com.java2nb.novel.service.AuthorService;
|
import com.java2nb.novel.service.AuthorService;
|
||||||
import com.java2nb.novel.service.BookService;
|
import com.java2nb.novel.service.BookService;
|
||||||
|
import com.java2nb.novel.service.FileService;
|
||||||
|
import com.java2nb.novel.service.SearchService;
|
||||||
import com.java2nb.novel.vo.BookCommentVO;
|
import com.java2nb.novel.vo.BookCommentVO;
|
||||||
import com.java2nb.novel.vo.BookSettingVO;
|
import com.java2nb.novel.vo.BookSettingVO;
|
||||||
import com.java2nb.novel.vo.BookVO;
|
import com.java2nb.novel.vo.BookVO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.mybatis.dynamic.sql.SortSpecification;
|
import org.mybatis.dynamic.sql.SortSpecification;
|
||||||
import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
||||||
@ -50,14 +51,18 @@ import static org.mybatis.dynamic.sql.select.SelectDSL.select;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
public class BookServiceImpl implements BookService {
|
public class BookServiceImpl implements BookService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地图片保存路径
|
* 本地图片保存路径
|
||||||
* */
|
*/
|
||||||
@Value("${pic.save.path}")
|
@Value("${pic.save.path}")
|
||||||
private String picSavePath;
|
private String picSavePath;
|
||||||
|
|
||||||
|
@Value("${spring.elasticsearch.enable}")
|
||||||
|
private Integer esEnable;
|
||||||
|
|
||||||
private final FrontBookSettingMapper bookSettingMapper;
|
private final FrontBookSettingMapper bookSettingMapper;
|
||||||
|
|
||||||
private final FrontBookMapper bookMapper;
|
private final FrontBookMapper bookMapper;
|
||||||
@ -76,6 +81,10 @@ public class BookServiceImpl implements BookService {
|
|||||||
|
|
||||||
private final AuthorService authorService;
|
private final AuthorService authorService;
|
||||||
|
|
||||||
|
private final SearchService searchService;
|
||||||
|
|
||||||
|
private final FileService fileService;
|
||||||
|
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
@ -83,24 +92,24 @@ public class BookServiceImpl implements BookService {
|
|||||||
String result = cacheService.get(CacheKey.INDEX_BOOK_SETTINGS_KEY);
|
String result = cacheService.get(CacheKey.INDEX_BOOK_SETTINGS_KEY);
|
||||||
if (result == null || result.length() < Constants.OBJECT_JSON_CACHE_EXIST_LENGTH) {
|
if (result == null || result.length() < Constants.OBJECT_JSON_CACHE_EXIST_LENGTH) {
|
||||||
List<BookSettingVO> list = bookSettingMapper.listVO();
|
List<BookSettingVO> list = bookSettingMapper.listVO();
|
||||||
if(list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
//如果首页小说没有被设置,则初始化首页小说设置
|
//如果首页小说没有被设置,则初始化首页小说设置
|
||||||
list = initIndexBookSetting();
|
list = initIndexBookSetting();
|
||||||
}
|
}
|
||||||
result = new ObjectMapper().writeValueAsString(list.stream().collect(Collectors.groupingBy(BookSettingVO::getType)));
|
result = new ObjectMapper().writeValueAsString(list.stream().collect(Collectors.groupingBy(BookSettingVO::getType)));
|
||||||
cacheService.set(CacheKey.INDEX_BOOK_SETTINGS_KEY, result);
|
cacheService.set(CacheKey.INDEX_BOOK_SETTINGS_KEY, result);
|
||||||
}
|
}
|
||||||
return new ObjectMapper().readValue(result,Map.class);
|
return new ObjectMapper().readValue(result, Map.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化首页小说设置
|
* 初始化首页小说设置
|
||||||
* */
|
*/
|
||||||
private List<BookSettingVO> initIndexBookSetting() {
|
private List<BookSettingVO> initIndexBookSetting() {
|
||||||
Date currentDate = new Date();
|
Date currentDate = new Date();
|
||||||
List<Book> books = bookMapper.selectIdsByScoreAndRandom(Constants.INDEX_BOOK_SETTING_NUM);
|
List<Book> books = bookMapper.selectIdsByScoreAndRandom(Constants.INDEX_BOOK_SETTING_NUM);
|
||||||
if(books.size() == Constants.INDEX_BOOK_SETTING_NUM) {
|
if (books.size() == Constants.INDEX_BOOK_SETTING_NUM) {
|
||||||
List<BookSetting> bookSettingList = new ArrayList<>(Constants.INDEX_BOOK_SETTING_NUM);
|
List<BookSetting> bookSettingList = new ArrayList<>(Constants.INDEX_BOOK_SETTING_NUM);
|
||||||
List<BookSettingVO> bookSettingVOList = new ArrayList<>(Constants.INDEX_BOOK_SETTING_NUM);
|
List<BookSettingVO> bookSettingVOList = new ArrayList<>(Constants.INDEX_BOOK_SETTING_NUM);
|
||||||
for (int i = 0; i < books.size(); i++) {
|
for (int i = 0; i < books.size(); i++) {
|
||||||
@ -114,7 +123,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
type = 2;
|
type = 2;
|
||||||
} else if (i < 26) {
|
} else if (i < 26) {
|
||||||
type = 3;
|
type = 3;
|
||||||
}else{
|
} else {
|
||||||
type = 4;
|
type = 4;
|
||||||
}
|
}
|
||||||
BookSettingVO bookSettingVO = new BookSettingVO();
|
BookSettingVO bookSettingVO = new BookSettingVO();
|
||||||
@ -126,8 +135,8 @@ public class BookServiceImpl implements BookService {
|
|||||||
bookSetting.setUpdateTime(currentDate);
|
bookSetting.setUpdateTime(currentDate);
|
||||||
bookSettingList.add(bookSetting);
|
bookSettingList.add(bookSetting);
|
||||||
|
|
||||||
BeanUtils.copyProperties(book,bookSettingVO);
|
BeanUtils.copyProperties(book, bookSettingVO);
|
||||||
BeanUtils.copyProperties(bookSetting,bookSettingVO);
|
BeanUtils.copyProperties(bookSetting, bookSettingVO);
|
||||||
bookSettingVOList.add(bookSettingVO);
|
bookSettingVOList.add(bookSettingVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,25 +173,43 @@ public class BookServiceImpl implements BookService {
|
|||||||
List<BookVO> result = (List<BookVO>) cacheService.getObject(CacheKey.INDEX_UPDATE_BOOK_KEY);
|
List<BookVO> result = (List<BookVO>) cacheService.getObject(CacheKey.INDEX_UPDATE_BOOK_KEY);
|
||||||
if (result == null || result.size() == 0) {
|
if (result == null || result.size() == 0) {
|
||||||
List<Book> bookPOList = listRank((byte) 2, 23);
|
List<Book> bookPOList = listRank((byte) 2, 23);
|
||||||
result = BeanUtil.copyList(bookPOList,BookVO.class);
|
result = BeanUtil.copyList(bookPOList, BookVO.class);
|
||||||
cacheService.setObject(CacheKey.INDEX_UPDATE_BOOK_KEY, result, 60 * 10);
|
cacheService.setObject(CacheKey.INDEX_UPDATE_BOOK_KEY, result, 60 * 10);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BookVO> searchByPage(BookSP params, int page, int pageSize) {
|
public PageInfo searchByPage(BookSP params, int page, int pageSize) {
|
||||||
PageHelper.startPage(page, pageSize);
|
|
||||||
|
|
||||||
if (params.getUpdatePeriod() != null) {
|
if (params.getUpdatePeriod() != null) {
|
||||||
long cur = System.currentTimeMillis();
|
long cur = System.currentTimeMillis();
|
||||||
long period = params.getUpdatePeriod() * 24 * 3600 * 1000;
|
long period = params.getUpdatePeriod() * 24 * 3600 * 1000;
|
||||||
long time = cur - period;
|
long time = cur - period;
|
||||||
params.setUpdateTimeMin(new Date(time));
|
params.setUpdateTimeMin(new Date(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (esEnable == 1) {
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
return searchService.searchBook(params,page,pageSize);
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
PageHelper.startPage(page, pageSize);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(params.getSort())) {
|
if (StringUtils.isNotBlank(params.getSort())) {
|
||||||
OrderByHelper.orderBy(params.getSort() + " desc");
|
OrderByHelper.orderBy(params.getSort() + " desc");
|
||||||
}
|
}
|
||||||
return bookMapper.searchByPage(params);
|
return new PageInfo<>(bookMapper.searchByPage(params));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -197,7 +224,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Book queryBookDetail(Long bookId) {
|
public Book queryBookDetail(Long bookId) {
|
||||||
SelectStatementProvider selectStatement = select(id, catName, catId, picUrl, bookName, authorId, authorName, bookDesc, bookStatus, visitCount, wordCount, lastIndexId, lastIndexName, lastIndexUpdateTime,score,status)
|
SelectStatementProvider selectStatement = select(book.allColumns())
|
||||||
.from(book)
|
.from(book)
|
||||||
.where(id, isEqualTo(bookId))
|
.where(id, isEqualTo(bookId))
|
||||||
.build()
|
.build()
|
||||||
@ -206,15 +233,15 @@ public class BookServiceImpl implements BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BookIndex> queryIndexList(Long bookId,String orderBy, Integer limit) {
|
public List<BookIndex> queryIndexList(Long bookId, String orderBy, Integer limit) {
|
||||||
if(StringUtils.isNotBlank(orderBy)){
|
if (StringUtils.isNotBlank(orderBy)) {
|
||||||
OrderByHelper.orderBy(orderBy);
|
OrderByHelper.orderBy(orderBy);
|
||||||
}
|
}
|
||||||
if(limit != null){
|
if (limit != null) {
|
||||||
PageHelper.startPage(1,limit);
|
PageHelper.startPage(1, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.id, BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.indexNum, BookIndexDynamicSqlSupport.indexName, BookIndexDynamicSqlSupport.updateTime,BookIndexDynamicSqlSupport.isVip)
|
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.id, BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.indexNum, BookIndexDynamicSqlSupport.indexName, BookIndexDynamicSqlSupport.updateTime, BookIndexDynamicSqlSupport.isVip)
|
||||||
.from(bookIndex)
|
.from(bookIndex)
|
||||||
.where(BookIndexDynamicSqlSupport.bookId, isEqualTo(bookId))
|
.where(BookIndexDynamicSqlSupport.bookId, isEqualTo(bookId))
|
||||||
.build()
|
.build()
|
||||||
@ -225,7 +252,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BookIndex queryBookIndex(Long bookIndexId) {
|
public BookIndex queryBookIndex(Long bookIndexId) {
|
||||||
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.id, BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.indexNum, BookIndexDynamicSqlSupport.indexName, BookIndexDynamicSqlSupport.wordCount, BookIndexDynamicSqlSupport.updateTime,BookIndexDynamicSqlSupport.isVip)
|
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.id, BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.indexNum, BookIndexDynamicSqlSupport.indexName, BookIndexDynamicSqlSupport.wordCount, BookIndexDynamicSqlSupport.updateTime, BookIndexDynamicSqlSupport.isVip)
|
||||||
.from(bookIndex)
|
.from(bookIndex)
|
||||||
.where(BookIndexDynamicSqlSupport.id, isEqualTo(bookIndexId))
|
.where(BookIndexDynamicSqlSupport.id, isEqualTo(bookIndexId))
|
||||||
.build()
|
.build()
|
||||||
@ -271,7 +298,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BookContent queryBookContent(Long bookIndexId) {
|
public BookContent queryBookContent(Long bookIndexId) {
|
||||||
SelectStatementProvider selectStatement = select(BookContentDynamicSqlSupport.id,BookContentDynamicSqlSupport.content)
|
SelectStatementProvider selectStatement = select(BookContentDynamicSqlSupport.id, BookContentDynamicSqlSupport.content)
|
||||||
.from(bookContent)
|
.from(bookContent)
|
||||||
.where(BookContentDynamicSqlSupport.indexId, isEqualTo(bookIndexId))
|
.where(BookContentDynamicSqlSupport.indexId, isEqualTo(bookIndexId))
|
||||||
.limit(1)
|
.limit(1)
|
||||||
@ -305,7 +332,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
}
|
}
|
||||||
SelectStatementProvider selectStatement = select(id, catId, catName, bookName, lastIndexId, lastIndexName, authorId, authorName, picUrl, bookDesc, wordCount, lastIndexUpdateTime)
|
SelectStatementProvider selectStatement = select(id, catId, catName, bookName, lastIndexId, lastIndexName, authorId, authorName, picUrl, bookDesc, wordCount, lastIndexUpdateTime)
|
||||||
.from(book)
|
.from(book)
|
||||||
.where(wordCount,isGreaterThan(0))
|
.where(wordCount, isGreaterThan(0))
|
||||||
.orderBy(sortSpecification)
|
.orderBy(sortSpecification)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.build()
|
.build()
|
||||||
@ -315,9 +342,8 @@ public class BookServiceImpl implements BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addVisitCount(Long bookId) {
|
public void addVisitCount(Long bookId, Integer visitCount) {
|
||||||
bookMapper.addVisitCount(bookId);
|
bookMapper.addVisitCount(bookId,visitCount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -349,10 +375,10 @@ public class BookServiceImpl implements BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BookCommentVO> listCommentByPage(Long userId,Long bookId, int page, int pageSize) {
|
public List<BookCommentVO> listCommentByPage(Long userId, Long bookId, int page, int pageSize) {
|
||||||
PageHelper.startPage(page, pageSize);
|
PageHelper.startPage(page, pageSize);
|
||||||
OrderByHelper.orderBy("t1.create_time desc");
|
OrderByHelper.orderBy("t1.create_time desc");
|
||||||
return bookCommentMapper.listCommentByPage(userId,bookId);
|
return bookCommentMapper.listCommentByPage(userId, bookId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@ -361,11 +387,11 @@ public class BookServiceImpl implements BookService {
|
|||||||
//判断该用户是否已评论过该书籍
|
//判断该用户是否已评论过该书籍
|
||||||
SelectStatementProvider selectStatement = select(count(BookCommentDynamicSqlSupport.id))
|
SelectStatementProvider selectStatement = select(count(BookCommentDynamicSqlSupport.id))
|
||||||
.from(bookComment)
|
.from(bookComment)
|
||||||
.where(BookCommentDynamicSqlSupport.createUserId,isEqualTo(userId))
|
.where(BookCommentDynamicSqlSupport.createUserId, isEqualTo(userId))
|
||||||
.and(BookCommentDynamicSqlSupport.bookId,isEqualTo(comment.getBookId()))
|
.and(BookCommentDynamicSqlSupport.bookId, isEqualTo(comment.getBookId()))
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3);
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
if(bookCommentMapper.count(selectStatement)>0){
|
if (bookCommentMapper.count(selectStatement) > 0) {
|
||||||
throw new BusinessException(ResponseStatus.HAS_COMMENTS);
|
throw new BusinessException(ResponseStatus.HAS_COMMENTS);
|
||||||
}
|
}
|
||||||
//增加评论
|
//增加评论
|
||||||
@ -374,7 +400,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
bookCommentMapper.insertSelective(comment);
|
bookCommentMapper.insertSelective(comment);
|
||||||
//增加书籍评论数
|
//增加书籍评论数
|
||||||
bookMapper.addCommentCount(comment.getBookId());
|
bookMapper.addCommentCount(comment.getBookId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -382,14 +408,14 @@ public class BookServiceImpl implements BookService {
|
|||||||
Long authorId;
|
Long authorId;
|
||||||
SelectStatementProvider selectStatement = select(BookAuthorDynamicSqlSupport.id)
|
SelectStatementProvider selectStatement = select(BookAuthorDynamicSqlSupport.id)
|
||||||
.from(BookAuthorDynamicSqlSupport.bookAuthor)
|
.from(BookAuthorDynamicSqlSupport.bookAuthor)
|
||||||
.where(BookAuthorDynamicSqlSupport.penName,isEqualTo(authorName))
|
.where(BookAuthorDynamicSqlSupport.penName, isEqualTo(authorName))
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3);
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
List<BookAuthor> bookAuthors = bookAuthorMapper.selectMany(selectStatement);
|
List<BookAuthor> bookAuthors = bookAuthorMapper.selectMany(selectStatement);
|
||||||
if(bookAuthors.size()>0){
|
if (bookAuthors.size() > 0) {
|
||||||
//作者存在
|
//作者存在
|
||||||
authorId = bookAuthors.get(0).getId();
|
authorId = bookAuthors.get(0).getId();
|
||||||
}else{
|
} else {
|
||||||
//作者不存在,先创建作者
|
//作者不存在,先创建作者
|
||||||
Date currentDate = new Date();
|
Date currentDate = new Date();
|
||||||
authorId = new IdWorker().nextId();
|
authorId = new IdWorker().nextId();
|
||||||
@ -409,18 +435,17 @@ public class BookServiceImpl implements BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long queryIdByNameAndAuthor(String bookName, String author) {
|
public Long queryIdByNameAndAuthor(String bookName, String author) {
|
||||||
//查询小说ID
|
//查询小说ID
|
||||||
SelectStatementProvider selectStatement = select(id)
|
SelectStatementProvider selectStatement = select(id)
|
||||||
.from(book)
|
.from(book)
|
||||||
.where(BookDynamicSqlSupport.bookName,isEqualTo(bookName))
|
.where(BookDynamicSqlSupport.bookName, isEqualTo(bookName))
|
||||||
.and(BookDynamicSqlSupport.authorName,isEqualTo(authorName))
|
.and(BookDynamicSqlSupport.authorName, isEqualTo(authorName))
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3);
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
List<Book> books = bookMapper.selectMany(selectStatement);
|
List<Book> books = bookMapper.selectMany(selectStatement);
|
||||||
if(books.size()>0){
|
if (books.size() > 0) {
|
||||||
return books.get(0).getId();
|
return books.get(0).getId();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -430,7 +455,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
public List<Integer> queryIndexNumByBookId(Long bookId) {
|
public List<Integer> queryIndexNumByBookId(Long bookId) {
|
||||||
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.indexNum)
|
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.indexNum)
|
||||||
.from(BookIndexDynamicSqlSupport.bookIndex)
|
.from(BookIndexDynamicSqlSupport.bookIndex)
|
||||||
.where(BookIndexDynamicSqlSupport.bookId,isEqualTo(bookId))
|
.where(BookIndexDynamicSqlSupport.bookId, isEqualTo(bookId))
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3);
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
|
|
||||||
@ -438,21 +463,21 @@ public class BookServiceImpl implements BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Book> queryNetworkPicBooks(Integer limit, Integer offset) {
|
public List<Book> queryNetworkPicBooks(String localPicPrefix, Integer limit) {
|
||||||
return bookMapper.queryNetworkPicBooks(limit,offset);
|
return bookMapper.queryNetworkPicBooks(localPicPrefix,limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateBookPicToLocal(String picUrl, Long bookId) {
|
public void updateBookPicToLocal(String picUrl, Long bookId) {
|
||||||
|
|
||||||
picUrl = FileUtil.network2Local(picUrl,picSavePath, Constants.LOCAL_PIC_PREFIX);
|
picUrl = fileService.transFile(picUrl, picSavePath);
|
||||||
|
|
||||||
bookMapper.update(update(book)
|
bookMapper.update(update(book)
|
||||||
.set(BookDynamicSqlSupport.picUrl)
|
.set(BookDynamicSqlSupport.picUrl)
|
||||||
.equalTo(picUrl)
|
.equalTo(picUrl)
|
||||||
.set(updateTime)
|
.set(updateTime)
|
||||||
.equalTo(new Date())
|
.equalTo(new Date())
|
||||||
.where(id,isEqualTo(bookId))
|
.where(id, isEqualTo(bookId))
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3));
|
.render(RenderingStrategies.MYBATIS3));
|
||||||
|
|
||||||
@ -461,7 +486,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
@Override
|
@Override
|
||||||
public List<Book> listBookPageByUserId(Long userId, int page, int pageSize) {
|
public List<Book> listBookPageByUserId(Long userId, int page, int pageSize) {
|
||||||
|
|
||||||
PageHelper.startPage(page,pageSize);
|
PageHelper.startPage(page, pageSize);
|
||||||
|
|
||||||
SelectStatementProvider selectStatement = select(id, bookName, visitCount, lastIndexName, status)
|
SelectStatementProvider selectStatement = select(id, bookName, visitCount, lastIndexName, status)
|
||||||
.from(book)
|
.from(book)
|
||||||
@ -476,10 +501,11 @@ public class BookServiceImpl implements BookService {
|
|||||||
@Override
|
@Override
|
||||||
public void addBook(Book book, Long authorId, String penName) {
|
public void addBook(Book book, Long authorId, String penName) {
|
||||||
//判断小说名是否存在
|
//判断小说名是否存在
|
||||||
if(queryIdByNameAndAuthor(book.getBookName(),penName)!=null){
|
if (queryIdByNameAndAuthor(book.getBookName(), penName) != null) {
|
||||||
//该作者发布过此书名的小说
|
//该作者发布过此书名的小说
|
||||||
throw new BusinessException(ResponseStatus.BOOKNAME_EXISTS);
|
throw new BusinessException(ResponseStatus.BOOKNAME_EXISTS);
|
||||||
};
|
}
|
||||||
|
;
|
||||||
book.setAuthorName(penName);
|
book.setAuthorName(penName);
|
||||||
book.setAuthorId(authorId);
|
book.setAuthorId(authorId);
|
||||||
book.setVisitCount(0L);
|
book.setVisitCount(0L);
|
||||||
@ -497,18 +523,18 @@ public class BookServiceImpl implements BookService {
|
|||||||
bookMapper.update(update(book)
|
bookMapper.update(update(book)
|
||||||
.set(BookDynamicSqlSupport.status)
|
.set(BookDynamicSqlSupport.status)
|
||||||
.equalTo(status)
|
.equalTo(status)
|
||||||
.where(id,isEqualTo(bookId))
|
.where(id, isEqualTo(bookId))
|
||||||
.and(BookDynamicSqlSupport.authorId,isEqualTo(authorId))
|
.and(BookDynamicSqlSupport.authorId, isEqualTo(authorId))
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3));
|
.render(RenderingStrategies.MYBATIS3));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public void addBookContent(Long bookId, String indexName, String content, Long authorId) {
|
public void addBookContent(Long bookId, String indexName, String content, Long authorId) {
|
||||||
|
|
||||||
Book book = queryBookDetail(bookId);
|
Book book = queryBookDetail(bookId);
|
||||||
if(!authorId.equals(book.getAuthorId())){
|
if (!authorId.equals(book.getAuthorId())) {
|
||||||
//并不是更新自己的小说
|
//并不是更新自己的小说
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -525,15 +551,15 @@ public class BookServiceImpl implements BookService {
|
|||||||
.set(BookDynamicSqlSupport.lastIndexUpdateTime)
|
.set(BookDynamicSqlSupport.lastIndexUpdateTime)
|
||||||
.equalTo(currentDate)
|
.equalTo(currentDate)
|
||||||
.set(BookDynamicSqlSupport.wordCount)
|
.set(BookDynamicSqlSupport.wordCount)
|
||||||
.equalTo(book.getWordCount()+wordCount)
|
.equalTo(book.getWordCount() + wordCount)
|
||||||
.where(id,isEqualTo(bookId))
|
.where(id, isEqualTo(bookId))
|
||||||
.and(BookDynamicSqlSupport.authorId,isEqualTo(authorId))
|
.and(BookDynamicSqlSupport.authorId, isEqualTo(authorId))
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3));
|
.render(RenderingStrategies.MYBATIS3));
|
||||||
//更新小说目录表
|
//更新小说目录表
|
||||||
int indexNum = 0;
|
int indexNum = 0;
|
||||||
if(book.getLastIndexId() != null){
|
if (book.getLastIndexId() != null) {
|
||||||
indexNum = queryBookIndex(book.getLastIndexId()).getIndexNum()+1;
|
indexNum = queryBookIndex(book.getLastIndexId()).getIndexNum() + 1;
|
||||||
}
|
}
|
||||||
BookIndex lastBookIndex = new BookIndex();
|
BookIndex lastBookIndex = new BookIndex();
|
||||||
lastBookIndex.setId(lastIndexId);
|
lastBookIndex.setId(lastIndexId);
|
||||||
@ -553,7 +579,19 @@ public class BookServiceImpl implements BookService {
|
|||||||
bookContentMapper.insertSelective(bookContent);
|
bookContentMapper.insertSelective(bookContent);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Book> queryBookByUpdateTimeByPage(Date startDate, int limit) {
|
||||||
|
|
||||||
|
|
||||||
|
return bookMapper.selectMany(select(book.allColumns())
|
||||||
|
.from(book)
|
||||||
|
.where(updateTime, isGreaterThan(startDate))
|
||||||
|
.orderBy(updateTime)
|
||||||
|
.limit(limit)
|
||||||
|
.build()
|
||||||
|
.render(RenderingStrategies.MYBATIS3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.java2nb.novel.service.impl;
|
||||||
|
|
||||||
|
import com.github.tobato.fastdfs.domain.StorePath;
|
||||||
|
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||||
|
import com.java2nb.novel.core.utils.Constants;
|
||||||
|
import com.java2nb.novel.core.utils.FileUtil;
|
||||||
|
import com.java2nb.novel.service.FileService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
@ConditionalOnProperty(prefix = "pic.save", name = "storage", havingValue = "fastDfs")
|
||||||
|
public class FastDfsFileServiceImpl implements FileService {
|
||||||
|
|
||||||
|
private final FastFileStorageClient storageClient;
|
||||||
|
|
||||||
|
@Value("${fdfs.webUrl}")
|
||||||
|
private String webUrl;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String transFile(String picSrc, String picSavePath) {
|
||||||
|
|
||||||
|
File file;
|
||||||
|
String filePath = FileUtil.network2Local(picSrc, picSavePath, Constants.LOCAL_PIC_PREFIX);
|
||||||
|
if (filePath.contains(Constants.LOCAL_PIC_PREFIX)) {
|
||||||
|
file = new File(picSavePath + filePath);
|
||||||
|
} else {
|
||||||
|
//默认图片不存储
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileInputStream inputStream = new FileInputStream(file);
|
||||||
|
StorePath storePath = storageClient.uploadFile(inputStream, file.length(),
|
||||||
|
FilenameUtils.getExtension(file.getName()), null);
|
||||||
|
//这里额外加上LOCAL_PIC_PREFIX路径,表明该图片是个人资源,而不是爬虫爬取的网络资源,不需要再次进行转换,
|
||||||
|
// 实际访问时,再通过nginx的rewite指令来重写路径,去掉LOCAL_PIC_PREFIX
|
||||||
|
return webUrl+Constants.LOCAL_PIC_PREFIX+storePath.getFullPath();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
//删除
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "/images/default.gif";
|
||||||
|
}
|
||||||
|
}
|
@ -40,7 +40,7 @@ public class FriendLinkServiceImpl implements FriendLinkService {
|
|||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3);
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
result = friendLinkMapper.selectMany(selectStatement);
|
result = friendLinkMapper.selectMany(selectStatement);
|
||||||
cacheService.setObject(CacheKey.INDEX_LINK_KEY,result);
|
cacheService.setObject(CacheKey.INDEX_LINK_KEY,result,60 * 60 * 24);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.java2nb.novel.service.impl;
|
||||||
|
|
||||||
|
import com.java2nb.novel.core.utils.Constants;
|
||||||
|
import com.java2nb.novel.core.utils.FileUtil;
|
||||||
|
import com.java2nb.novel.service.FileService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@ConditionalOnProperty(prefix = "pic.save", name = "storage", havingValue = "local")
|
||||||
|
public class LocalFileServiceImpl implements FileService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String transFile(String picSrc, String picSavePath){
|
||||||
|
|
||||||
|
return FileUtil.network2Local(picSrc, picSavePath, Constants.LOCAL_PIC_PREFIX);
|
||||||
|
}
|
||||||
|
}
|
@ -42,7 +42,7 @@ public class NewsServiceImpl implements NewsService {
|
|||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3);
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
result = newsMapper.selectMany(selectStatement);
|
result = newsMapper.selectMany(selectStatement);
|
||||||
cacheService.setObject(CacheKey.INDEX_NEWS_KEY,result);
|
cacheService.setObject(CacheKey.INDEX_NEWS_KEY,result,60 * 60 * 12);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.java2nb.novel.service.impl;
|
||||||
|
|
||||||
|
import com.aliyun.oss.OSSClient;
|
||||||
|
import com.aliyun.oss.model.CannedAccessControlList;
|
||||||
|
import com.aliyun.oss.model.CreateBucketRequest;
|
||||||
|
import com.aliyun.oss.model.PutObjectRequest;
|
||||||
|
import com.aliyun.oss.model.PutObjectResult;
|
||||||
|
import com.java2nb.novel.core.config.OssProperties;
|
||||||
|
import com.java2nb.novel.core.utils.Constants;
|
||||||
|
import com.java2nb.novel.core.utils.FileUtil;
|
||||||
|
import com.java2nb.novel.service.FileService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@ConditionalOnProperty(prefix = "pic.save", name = "storage", havingValue = "OSS")
|
||||||
|
@Slf4j
|
||||||
|
public class OssFileServiceImpl implements FileService {
|
||||||
|
|
||||||
|
private final OssProperties ossProperties;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String transFile(String picSrc, String picSavePath) {
|
||||||
|
|
||||||
|
File file;
|
||||||
|
String filePath = FileUtil.network2Local(picSrc, picSavePath, Constants.LOCAL_PIC_PREFIX);
|
||||||
|
if (filePath.contains(Constants.LOCAL_PIC_PREFIX)) {
|
||||||
|
file = new File(picSavePath+filePath);
|
||||||
|
} else {
|
||||||
|
//默认图片不存储
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
filePath = filePath.replaceFirst(picSavePath,"");
|
||||||
|
|
||||||
|
filePath = filePath.startsWith("/") ? filePath.replaceFirst("/","") : filePath;
|
||||||
|
|
||||||
|
|
||||||
|
OSSClient ossClient = new OSSClient(ossProperties.getEndpoint(), ossProperties.getKeyId(), ossProperties.getKeySecret());
|
||||||
|
try {
|
||||||
|
//容器不存在,就创建
|
||||||
|
if (!ossClient.doesBucketExist(ossProperties.getBucketName())) {
|
||||||
|
ossClient.createBucket(ossProperties.getBucketName());
|
||||||
|
CreateBucketRequest createBucketRequest = new CreateBucketRequest(ossProperties.getBucketName());
|
||||||
|
createBucketRequest.setCannedACL(CannedAccessControlList.PublicRead);
|
||||||
|
ossClient.createBucket(createBucketRequest);
|
||||||
|
}
|
||||||
|
//上传文件
|
||||||
|
PutObjectResult result = ossClient.putObject(new PutObjectRequest(ossProperties.getBucketName(), filePath, file));
|
||||||
|
//设置权限 这里是公开读
|
||||||
|
ossClient.setBucketAcl(ossProperties.getBucketName(), CannedAccessControlList.PublicRead);
|
||||||
|
|
||||||
|
if(result != null) {
|
||||||
|
return ossProperties.getWebUrl() + "/" + filePath;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
//关闭
|
||||||
|
ossClient.shutdown();
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "/images/default.gif";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,202 @@
|
|||||||
|
package com.java2nb.novel.service.impl;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||||
|
import com.java2nb.novel.core.exception.BusinessException;
|
||||||
|
import com.java2nb.novel.core.utils.StringUtil;
|
||||||
|
import com.java2nb.novel.entity.Book;
|
||||||
|
import com.java2nb.novel.search.BookSP;
|
||||||
|
import com.java2nb.novel.service.SearchService;
|
||||||
|
import com.java2nb.novel.vo.EsBookVO;
|
||||||
|
import io.searchbox.client.JestClient;
|
||||||
|
import io.searchbox.core.*;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||||
|
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
|
||||||
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class SearchServiceImpl implements SearchService {
|
||||||
|
|
||||||
|
private final String INDEX = "novel";
|
||||||
|
|
||||||
|
private final String TYPE = "book";
|
||||||
|
|
||||||
|
private final JestClient jestClient;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SneakyThrows
|
||||||
|
public void importToEs(Book book) {
|
||||||
|
//导入到ES
|
||||||
|
EsBookVO esBookVO = new EsBookVO();
|
||||||
|
BeanUtils.copyProperties(book, esBookVO, "lastIndexUpdateTime");
|
||||||
|
esBookVO.setLastIndexUpdateTime(new SimpleDateFormat("yyyy/MM/dd HH:mm").format(book.getLastIndexUpdateTime()));
|
||||||
|
Index action = new Index.Builder(esBookVO).index(INDEX).type(TYPE).id(book.getId().toString()).build();
|
||||||
|
|
||||||
|
jestClient.execute(action);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public PageInfo searchBook(BookSP params, int page, int pageSize) {
|
||||||
|
List<EsBookVO> bookList = new ArrayList<>(0);
|
||||||
|
|
||||||
|
//使用搜索引擎搜索
|
||||||
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||||
|
// 构造查询哪个字段
|
||||||
|
if (StringUtils.isNoneBlank(params.getKeyword())) {
|
||||||
|
boolQueryBuilder = boolQueryBuilder.must(QueryBuilders.queryStringQuery(params.getKeyword()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 作品方向
|
||||||
|
if (params.getWorkDirection() != null) {
|
||||||
|
boolQueryBuilder.filter(QueryBuilders.termQuery("workDirection", params.getWorkDirection()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分类
|
||||||
|
if (params.getCatId() != null) {
|
||||||
|
boolQueryBuilder.filter(QueryBuilders.termQuery("catId", params.getCatId()));
|
||||||
|
}
|
||||||
|
if (params.getBookStatus() != null) {
|
||||||
|
boolQueryBuilder.filter(QueryBuilders.termQuery("bookStatus", params.getBookStatus()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.getWordCountMin() == null) {
|
||||||
|
params.setWordCountMin(0);
|
||||||
|
}
|
||||||
|
if (params.getWordCountMax() == null) {
|
||||||
|
params.setWordCountMax(Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolQueryBuilder.filter(QueryBuilders.rangeQuery("wordCount").gte(params.getWordCountMin()).lte(params.getWordCountMax()));
|
||||||
|
|
||||||
|
if (params.getUpdateTimeMin() != null) {
|
||||||
|
boolQueryBuilder.filter(QueryBuilders.rangeQuery("lastIndexUpdateTime").gte(new SimpleDateFormat("yyyy/MM/dd HH:mm").format(params.getUpdateTimeMin())));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
||||||
|
searchSourceBuilder.query(boolQueryBuilder);
|
||||||
|
|
||||||
|
|
||||||
|
Count count = new Count.Builder().addIndex(INDEX).addType(TYPE)
|
||||||
|
.query(searchSourceBuilder.toString()).build();
|
||||||
|
CountResult results = jestClient.execute(count);
|
||||||
|
Double total = results.getCount();
|
||||||
|
|
||||||
|
|
||||||
|
// 高亮字段
|
||||||
|
HighlightBuilder highlightBuilder = new HighlightBuilder();
|
||||||
|
highlightBuilder.field("authorName");
|
||||||
|
highlightBuilder.field("bookName");
|
||||||
|
highlightBuilder.field("bookDesc");
|
||||||
|
highlightBuilder.field("lastIndexName");
|
||||||
|
highlightBuilder.field("catName");
|
||||||
|
highlightBuilder.preTags("<span style='color:red'>").postTags("</span>");
|
||||||
|
highlightBuilder.fragmentSize(20000);
|
||||||
|
searchSourceBuilder.highlighter(highlightBuilder);
|
||||||
|
|
||||||
|
|
||||||
|
//设置排序
|
||||||
|
if (params.getSort() != null) {
|
||||||
|
searchSourceBuilder.sort(StringUtil.camelName(params.getSort()), SortOrder.DESC);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置分页
|
||||||
|
searchSourceBuilder.from((page - 1) * pageSize);
|
||||||
|
searchSourceBuilder.size(pageSize);
|
||||||
|
|
||||||
|
// 构建Search对象
|
||||||
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(INDEX).addType(TYPE).build();
|
||||||
|
log.debug(search.toString());
|
||||||
|
SearchResult result;
|
||||||
|
result = jestClient.execute(search);
|
||||||
|
log.debug(result.getJsonString());
|
||||||
|
if (result.isSucceeded()) {
|
||||||
|
|
||||||
|
Map resultMap = new ObjectMapper().readValue(result.getJsonString(), Map.class);
|
||||||
|
if (resultMap.get("hits") != null) {
|
||||||
|
Map hitsMap = (Map) resultMap.get("hits");
|
||||||
|
if (hitsMap.size() > 0 && hitsMap.get("hits") != null) {
|
||||||
|
List hitsList = (List) hitsMap.get("hits");
|
||||||
|
if (hitsList.size() > 0 && result.getSourceAsString() != null) {
|
||||||
|
|
||||||
|
JavaType jt = new ObjectMapper().getTypeFactory().constructParametricType(ArrayList.class, EsBookVO.class);
|
||||||
|
bookList = new ObjectMapper().readValue("[" + result.getSourceAsString() + "]", jt);
|
||||||
|
|
||||||
|
if (bookList != null) {
|
||||||
|
for (int i = 0; i < bookList.size(); i++) {
|
||||||
|
hitsMap = (Map) hitsList.get(i);
|
||||||
|
Map highlightMap = (Map) hitsMap.get("highlight");
|
||||||
|
if (highlightMap != null && highlightMap.size() > 0) {
|
||||||
|
|
||||||
|
List<String> authorNameList = (List<String>) highlightMap.get("authorName");
|
||||||
|
if (authorNameList != null && authorNameList.size() > 0) {
|
||||||
|
bookList.get(i).setAuthorName(authorNameList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> bookNameList = (List<String>) highlightMap.get("bookName");
|
||||||
|
if (bookNameList != null && bookNameList.size() > 0) {
|
||||||
|
bookList.get(i).setBookName(bookNameList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> bookDescList = (List<String>) highlightMap.get("bookDesc");
|
||||||
|
if (bookDescList != null && bookDescList.size() > 0) {
|
||||||
|
bookList.get(i).setBookDesc(bookDescList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> lastIndexNameList = (List<String>) highlightMap.get("lastIndexName");
|
||||||
|
if (lastIndexNameList != null && lastIndexNameList.size() > 0) {
|
||||||
|
bookList.get(i).setLastIndexName(lastIndexNameList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> catNameList = (List<String>) highlightMap.get("catName");
|
||||||
|
if (catNameList != null && catNameList.size() > 0) {
|
||||||
|
bookList.get(i).setCatName(catNameList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PageInfo<EsBookVO> pageInfo = new PageInfo<>(bookList);
|
||||||
|
pageInfo.setTotal(total.longValue());
|
||||||
|
pageInfo.setPageNum(page);
|
||||||
|
pageInfo.setPageSize(pageSize);
|
||||||
|
return pageInfo;
|
||||||
|
}
|
||||||
|
throw new BusinessException(ResponseStatus.ES_SEARCH_FAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
85
novel-front/src/main/java/com/java2nb/novel/vo/EsBookVO.java
Normal file
85
novel-front/src/main/java/com/java2nb/novel/vo/EsBookVO.java
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package com.java2nb.novel.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.java2nb.novel.entity.Book;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EsBookVO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
|
private Byte workDirection;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer catId;
|
||||||
|
|
||||||
|
|
||||||
|
private String catName;
|
||||||
|
|
||||||
|
|
||||||
|
private String picUrl;
|
||||||
|
|
||||||
|
|
||||||
|
private String bookName;
|
||||||
|
|
||||||
|
|
||||||
|
private Long authorId;
|
||||||
|
|
||||||
|
|
||||||
|
private String authorName;
|
||||||
|
|
||||||
|
|
||||||
|
private String bookDesc;
|
||||||
|
|
||||||
|
|
||||||
|
private Float score;
|
||||||
|
|
||||||
|
|
||||||
|
private Byte bookStatus;
|
||||||
|
|
||||||
|
|
||||||
|
private Long visitCount;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer wordCount;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer commentCount;
|
||||||
|
|
||||||
|
|
||||||
|
private Long lastIndexId;
|
||||||
|
|
||||||
|
|
||||||
|
private String lastIndexName;
|
||||||
|
|
||||||
|
private String lastIndexUpdateTime;
|
||||||
|
|
||||||
|
|
||||||
|
private Byte isVip;
|
||||||
|
|
||||||
|
|
||||||
|
private Byte status;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private Integer crawlSourceId;
|
||||||
|
|
||||||
|
|
||||||
|
private String crawlBookId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private Byte crawlIsStop;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
16
novel-front/src/main/resources/application-fastdfs.yml
Normal file
16
novel-front/src/main/resources/application-fastdfs.yml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#FastDfs的配置 ====================================
|
||||||
|
#读取inputsream阻塞时间
|
||||||
|
fdfs:
|
||||||
|
connect-timeout: 600
|
||||||
|
so-timeout: 1500
|
||||||
|
#tracker地址
|
||||||
|
trackerList: 127.0.0.1:22122
|
||||||
|
#缩略图配置
|
||||||
|
thumbImage:
|
||||||
|
height: 150
|
||||||
|
width: 150
|
||||||
|
#通过nginx 访问地址
|
||||||
|
webUrl: http://127.0.0.1/
|
||||||
|
#获取连接池最大数量
|
||||||
|
pool.max-total: 200
|
||||||
|
|
9
novel-front/src/main/resources/application-oss.yml
Normal file
9
novel-front/src/main/resources/application-oss.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#OSS
|
||||||
|
novel:
|
||||||
|
file:
|
||||||
|
endpoint: oss-cn-shenzhen.aliyuncs.com #不同的服务器,地址不同
|
||||||
|
key-id: dhjjrue6767778878 #去OSS控制台获取
|
||||||
|
key-secret: dssdkkrkelrkellk44554 #去OSS控制台获取
|
||||||
|
bucket-name: novel #这个自己创建bucket时的命名,控制台创建也行,代码创建也行
|
||||||
|
file-host: pic #文件路径
|
||||||
|
web-url: https://xxyimg.oss-cn-hangzhou.aliyuncs.com #OSS文件的web访问地址
|
@ -4,7 +4,30 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: dev
|
||||||
include: alipay
|
include: alipay,oss,fastdfs
|
||||||
|
|
||||||
|
|
||||||
|
rabbitmq:
|
||||||
|
enable: 0
|
||||||
|
host: 127.0.0.1
|
||||||
|
username: guest
|
||||||
|
password: guest
|
||||||
|
virtual-host: /novel-plus
|
||||||
|
template:
|
||||||
|
# 缺省的交换机名称,此处配置后,发送消息如果不指定交换机就会使用这个
|
||||||
|
exchange: novel.exchange
|
||||||
|
publisher-confirms: false
|
||||||
|
|
||||||
|
|
||||||
|
elasticsearch:
|
||||||
|
#是否开启搜索引擎,1:开启,0:不开启
|
||||||
|
enable: 0
|
||||||
|
jest:
|
||||||
|
uris: http://127.0.0.1:9200
|
||||||
|
|
||||||
|
redisson:
|
||||||
|
singleServerConfig:
|
||||||
|
address: 127.0.0.1:6379
|
||||||
|
|
||||||
jwt:
|
jwt:
|
||||||
secret: novel!#20191230
|
secret: novel!#20191230
|
||||||
|
@ -34,8 +34,9 @@
|
|||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="addVisitCount" parameterType="long">
|
<update id="addVisitCount" >
|
||||||
update book set visit_count = visit_count + 1 where id = #{bookId}
|
update book set visit_count = visit_count + ${visitCount}
|
||||||
|
where id = #{bookId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="listRecBookByCatId" parameterType="int" resultType="com.java2nb.novel.entity.Book">
|
<select id="listRecBookByCatId" parameterType="int" resultType="com.java2nb.novel.entity.Book">
|
||||||
@ -54,8 +55,9 @@
|
|||||||
<select id="queryNetworkPicBooks" resultType="com.java2nb.novel.entity.Book">
|
<select id="queryNetworkPicBooks" resultType="com.java2nb.novel.entity.Book">
|
||||||
select
|
select
|
||||||
id,pic_url from book
|
id,pic_url from book
|
||||||
where pic_url like 'http://%' or pic_url like 'https://%'
|
where pic_url like 'http%'
|
||||||
limit #{offset},#{limit}
|
and pic_url not like concat('%',#{localPicPrefix},'%')
|
||||||
|
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">
|
||||||
|
BIN
novel-front/src/main/resources/static/images/default.gif
Normal file
BIN
novel-front/src/main/resources/static/images/default.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,217 @@
|
|||||||
|
jQuery.extend({
|
||||||
|
createUploadIframe: function(id, uri)
|
||||||
|
{
|
||||||
|
//create frame
|
||||||
|
var frameId = 'jUploadFrame' + id;
|
||||||
|
var iframeHtml = '<iframe id="' + frameId + '" name="' + frameId + '" style="position:absolute; top:-9999px; left:-9999px"';
|
||||||
|
if(window.ActiveXObject)
|
||||||
|
{
|
||||||
|
if(typeof uri== 'boolean'){
|
||||||
|
iframeHtml += ' src="' + 'javascript:false' + '"';
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(typeof uri== 'string'){
|
||||||
|
iframeHtml += ' src="' + uri + '"';
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iframeHtml += ' />';
|
||||||
|
jQuery(iframeHtml).appendTo(document.body);
|
||||||
|
|
||||||
|
return jQuery('#' + frameId).get(0);
|
||||||
|
},
|
||||||
|
createUploadForm: function(id,fileElementId,data,fileElement)
|
||||||
|
{
|
||||||
|
//create form
|
||||||
|
var formId = 'jUploadForm' + id;
|
||||||
|
var fileId = 'jUploadFile' + id;
|
||||||
|
var form = jQuery('<form action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
|
||||||
|
if(data)
|
||||||
|
{
|
||||||
|
for(var i in data)
|
||||||
|
{
|
||||||
|
jQuery('<input type="hidden" name="' + i + '" value="' + data[i] + '" />').appendTo(form);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var oldElement;
|
||||||
|
if(fileElement == null)
|
||||||
|
oldElement = jQuery('#' + fileElementId);
|
||||||
|
else
|
||||||
|
oldElement = fileElement;
|
||||||
|
|
||||||
|
var newElement = jQuery(oldElement).clone();
|
||||||
|
jQuery(oldElement).attr('id', fileId);
|
||||||
|
jQuery(oldElement).before(newElement);
|
||||||
|
jQuery(oldElement).appendTo(form);
|
||||||
|
|
||||||
|
//set attributes
|
||||||
|
jQuery(form).css('position', 'absolute');
|
||||||
|
jQuery(form).css('top', '-1200px');
|
||||||
|
jQuery(form).css('left', '-1200px');
|
||||||
|
jQuery(form).appendTo('body');
|
||||||
|
return form;
|
||||||
|
},
|
||||||
|
|
||||||
|
ajaxFileUpload: function(s) {
|
||||||
|
// TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
|
||||||
|
s = jQuery.extend({}, jQuery.ajaxSettings, s);
|
||||||
|
var id = new Date().getTime()
|
||||||
|
var form = jQuery.createUploadForm(id, s.fileElementId, (typeof(s.data)=='undefined'?false:s.data),s.fileElement);
|
||||||
|
var io = jQuery.createUploadIframe(id, s.secureuri);
|
||||||
|
var frameId = 'jUploadFrame' + id;
|
||||||
|
var formId = 'jUploadForm' + id;
|
||||||
|
// Watch for a new set of requests
|
||||||
|
if ( s.global && ! jQuery.active++ )
|
||||||
|
{
|
||||||
|
jQuery.event.trigger( "ajaxStart" );
|
||||||
|
}
|
||||||
|
var requestDone = false;
|
||||||
|
// Create the request object
|
||||||
|
var xml = {}
|
||||||
|
if ( s.global )
|
||||||
|
jQuery.event.trigger("ajaxSend", [xml, s]);
|
||||||
|
// Wait for a response to come back
|
||||||
|
var uploadCallback = function(isTimeout)
|
||||||
|
{
|
||||||
|
var io = document.getElementById(frameId);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(io.contentWindow)
|
||||||
|
{
|
||||||
|
xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
|
||||||
|
xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
|
||||||
|
|
||||||
|
}else if(io.contentDocument)
|
||||||
|
{
|
||||||
|
xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null;
|
||||||
|
xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;
|
||||||
|
}
|
||||||
|
}catch(e)
|
||||||
|
{
|
||||||
|
jQuery.handleError(s, xml, null, e);
|
||||||
|
}
|
||||||
|
if ( xml || isTimeout == "timeout")
|
||||||
|
{
|
||||||
|
requestDone = true;
|
||||||
|
var status;
|
||||||
|
try {
|
||||||
|
status = isTimeout != "timeout" ? "success" : "error";
|
||||||
|
// Make sure that the request was successful or notmodified
|
||||||
|
if ( status != "error" )
|
||||||
|
{
|
||||||
|
// process the data (runs the xml through httpData regardless of callback)
|
||||||
|
var data = jQuery.uploadHttpData( xml, s.dataType );
|
||||||
|
// If a local callback was specified, fire it and pass it the data
|
||||||
|
if ( s.success )
|
||||||
|
s.success( data, status );
|
||||||
|
|
||||||
|
// Fire the global callback
|
||||||
|
if( s.global )
|
||||||
|
jQuery.event.trigger( "ajaxSuccess", [xml, s] );
|
||||||
|
} else
|
||||||
|
jQuery.handleError(s, xml, status);
|
||||||
|
} catch(e)
|
||||||
|
{
|
||||||
|
status = "error";
|
||||||
|
jQuery.handleError(s, xml, status, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The request was completed
|
||||||
|
if( s.global )
|
||||||
|
jQuery.event.trigger( "ajaxComplete", [xml, s] );
|
||||||
|
|
||||||
|
// Handle the global AJAX counter
|
||||||
|
if ( s.global && ! --jQuery.active )
|
||||||
|
jQuery.event.trigger( "ajaxStop" );
|
||||||
|
|
||||||
|
// Process result
|
||||||
|
if ( s.complete )
|
||||||
|
s.complete(xml, status);
|
||||||
|
|
||||||
|
jQuery(io).unbind()
|
||||||
|
|
||||||
|
setTimeout(function()
|
||||||
|
{ try
|
||||||
|
{
|
||||||
|
jQuery(io).remove();
|
||||||
|
jQuery(form).remove();
|
||||||
|
|
||||||
|
} catch(e)
|
||||||
|
{
|
||||||
|
jQuery.handleError(s, xml, null, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 100)
|
||||||
|
|
||||||
|
xml = null
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Timeout checker
|
||||||
|
if ( s.timeout > 0 )
|
||||||
|
{
|
||||||
|
setTimeout(function(){
|
||||||
|
// Check to see if the request is still happening
|
||||||
|
if( !requestDone ) uploadCallback( "timeout" );
|
||||||
|
}, s.timeout);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
var form = jQuery('#' + formId);
|
||||||
|
jQuery(form).attr('action', s.url);
|
||||||
|
jQuery(form).attr('method', 'POST');
|
||||||
|
jQuery(form).attr('target', frameId);
|
||||||
|
if(form.encoding)
|
||||||
|
{
|
||||||
|
jQuery(form).attr('encoding', 'multipart/form-data');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jQuery(form).attr('enctype', 'multipart/form-data');
|
||||||
|
}
|
||||||
|
jQuery(form).submit();
|
||||||
|
|
||||||
|
} catch(e)
|
||||||
|
{
|
||||||
|
jQuery.handleError(s, xml, null, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery('#' + frameId).load(uploadCallback);
|
||||||
|
return {abort: function(){
|
||||||
|
try
|
||||||
|
{
|
||||||
|
jQuery('#' + frameId).remove();
|
||||||
|
jQuery(form).remove();
|
||||||
|
}
|
||||||
|
catch(e){}
|
||||||
|
}};
|
||||||
|
},
|
||||||
|
|
||||||
|
uploadHttpData: function( r, type ) {
|
||||||
|
var data = !type;
|
||||||
|
data = type == "xml" || data ? r.responseXML : r.responseText;
|
||||||
|
|
||||||
|
// If the type is "script", eval it in global context
|
||||||
|
if ( type == "script" )
|
||||||
|
jQuery.globalEval( data );
|
||||||
|
// Get the JavaScript object, if JSON is used.
|
||||||
|
if ( type == "json" )
|
||||||
|
data = jQuery.parseJSON(jQuery(data).text());
|
||||||
|
// evaluate scripts within html
|
||||||
|
if ( type == "html" )
|
||||||
|
jQuery("<div>").html(data).evalScripts();
|
||||||
|
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
|
||||||
|
handleError: function( s, xml, status, e ) {
|
||||||
|
// If a local callback was specified, fire it
|
||||||
|
if ( s.error )
|
||||||
|
s.error( xml, status, e );
|
||||||
|
|
||||||
|
// Fire the global callback
|
||||||
|
if ( s.global )
|
||||||
|
jQuery.event.trigger( "ajaxError", [xml, s, e] );
|
||||||
|
}
|
||||||
|
});
|
@ -8,6 +8,9 @@
|
|||||||
<title>作家管理系统-小说精品屋</title>
|
<title>作家管理系统-小说精品屋</title>
|
||||||
<link rel="stylesheet" href="/css/base.css?v=1"/>
|
<link rel="stylesheet" href="/css/base.css?v=1"/>
|
||||||
<link rel="stylesheet" href="/css/user.css"/>
|
<link rel="stylesheet" href="/css/user.css"/>
|
||||||
|
<style type="text/css">
|
||||||
|
.opacity{-khtml-opacity:0.0;-moz-opacity:0.0;filter:alpha(opacity=0);filter:"alpha(opacity=0)";opacity:0.0; filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);/*兼容ie8及以下*/}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
</head>
|
</head>
|
||||||
<body class="">
|
<body class="">
|
||||||
@ -74,8 +77,15 @@
|
|||||||
<input type="hidden" id="catName" name="catName" value="玄幻奇幻"/>
|
<input type="hidden" id="catName" name="catName" value="玄幻奇幻"/>
|
||||||
<b>小说名:</b>
|
<b>小说名:</b>
|
||||||
<li><input type="text" id="bookName" name="bookName" class="s_input" ></li>
|
<li><input type="text" id="bookName" name="bookName" class="s_input" ></li>
|
||||||
<b>小说封面图片路径:</b>
|
<b>小说封面:</b>
|
||||||
<li><input type="text" id="picUrl" name="picUrl" class="s_input" ></li>
|
<li style="position: relative">
|
||||||
|
<input class="opacity" onchange="picChange()"
|
||||||
|
type="file" id="file0" name="file"
|
||||||
|
title="点击更换图片"
|
||||||
|
style="z-index: 100;cursor: pointer;left: 0px; top: 0px; width: 100px; height: 130px; opacity: 0; position: absolute; "
|
||||||
|
/>
|
||||||
|
<img style="width:100px;height: 130px" id="picImage" src="/images/default.gif" alt="">
|
||||||
|
<input type="hidden" id="picUrl" name="picUrl" class="s_input" value="/images/default.gif"></li>
|
||||||
<b>小说介绍:</b>
|
<b>小说介绍:</b>
|
||||||
|
|
||||||
<li><textarea name="bookDesc" rows="5" cols="53" id="bookDesc"
|
<li><textarea name="bookDesc" rows="5" cols="53" id="bookDesc"
|
||||||
@ -126,37 +136,78 @@
|
|||||||
|
|
||||||
</body>
|
</body>
|
||||||
<script src="/javascript/jquery-1.8.0.min.js" type="text/javascript"></script>
|
<script src="/javascript/jquery-1.8.0.min.js" type="text/javascript"></script>
|
||||||
|
<script src="/javascript/ajaxfileupload.js" type="text/javascript"></script>
|
||||||
|
|
||||||
<script src="/layui/layui.all.js" type="text/javascript"></script>
|
<script src="/layui/layui.all.js" type="text/javascript"></script>
|
||||||
<script src="/javascript/header.js" type="text/javascript"></script>
|
<script src="/javascript/header.js" type="text/javascript"></script>
|
||||||
<script src="/javascript/user.js" type="text/javascript"></script>
|
<script src="/javascript/user.js" type="text/javascript"></script>
|
||||||
<script language="javascript" type="text/javascript">
|
<script language="javascript" type="text/javascript">
|
||||||
|
|
||||||
|
function picChange() {
|
||||||
|
var file = $("#file0").val(); //文件名称
|
||||||
|
if (file != "") {
|
||||||
|
|
||||||
|
$.ajaxFileUpload({
|
||||||
|
url : "/file/upload", //用于文件上传的服务器端请求地址
|
||||||
|
secureuri : false, //是否需要安全协议,一般设置为false
|
||||||
|
fileElementId : "file0", //文件上传域的ID
|
||||||
|
dataType : "json", //返回值类型 一般设置为json
|
||||||
|
type : "post",
|
||||||
|
success : function(data) { //服务器成功响应处理函数
|
||||||
|
if (data.code == 200) {
|
||||||
|
$("#picImage").attr("src", data.data);
|
||||||
|
$("#picUrl").val(data.data);
|
||||||
|
}else {
|
||||||
|
layer.alert('图片上传失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert("请选择上传文件!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var lock = false;
|
||||||
function addBook() {
|
function addBook() {
|
||||||
|
if(lock){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lock = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var bookName = $("#bookName").val();
|
var bookName = $("#bookName").val();
|
||||||
if(!bookName){
|
if(!bookName){
|
||||||
$("#LabErr").html("小说名不能为空!");
|
$("#LabErr").html("小说名不能为空!");
|
||||||
|
lock = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(bookName.length > 20){
|
if(bookName.length > 20){
|
||||||
$("#LabErr").html("小说名太长!");
|
$("#LabErr").html("小说名太长!");
|
||||||
|
lock = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var picUrl = $("#picUrl").val();
|
var picUrl = $("#picUrl").val();
|
||||||
if(!picUrl){
|
if(!picUrl){
|
||||||
$("#LabErr").html("封面图片不能为空!");
|
$("#LabErr").html("封面图片不能为空!");
|
||||||
|
lock = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bookDesc = $("#bookDesc").val();
|
var bookDesc = $("#bookDesc").val();
|
||||||
if(!bookDesc){
|
if(!bookDesc){
|
||||||
$("#LabErr").html("简介不能为空!");
|
$("#LabErr").html("简介不能为空!");
|
||||||
|
lock = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/author/addBook",
|
url: "/author/addBook",
|
||||||
@ -171,11 +222,13 @@
|
|||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
lock = false;
|
||||||
$("#LabErr").html(data.msg);
|
$("#LabErr").html(data.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
|
lock = false;
|
||||||
layer.alert('网络异常');
|
layer.alert('网络异常');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -58,10 +58,8 @@
|
|||||||
<b>章节名:</b>
|
<b>章节名:</b>
|
||||||
<li><input type="text" id="bookIndex" name="bookIndex" class="s_input" ></li>
|
<li><input type="text" id="bookIndex" name="bookIndex" class="s_input" ></li>
|
||||||
<b>章节内容:</b>
|
<b>章节内容:</b>
|
||||||
<input type="hidden" id="bookContent" name="bookContent" >
|
<textarea name="bookContent" rows="30" cols="80" id="bookContent"
|
||||||
<div style="width:600px" id="contentEditor">
|
class="textarea"></textarea>
|
||||||
|
|
||||||
</div>
|
|
||||||
<li style="margin-top: 10px"><input type="button" onclick="addBookContent()" name="btnRegister" value="提交"
|
<li style="margin-top: 10px"><input type="button" onclick="addBookContent()" name="btnRegister" value="提交"
|
||||||
id="btnRegister" class="btn_red">
|
id="btnRegister" class="btn_red">
|
||||||
|
|
||||||
@ -114,43 +112,18 @@
|
|||||||
<script src="/javascript/header.js" type="text/javascript"></script>
|
<script src="/javascript/header.js" type="text/javascript"></script>
|
||||||
<script src="/javascript/user.js" type="text/javascript"></script>
|
<script src="/javascript/user.js" type="text/javascript"></script>
|
||||||
<script src="/javascript/common.js" type="text/javascript"></script>
|
<script src="/javascript/common.js" type="text/javascript"></script>
|
||||||
<script type="text/javascript" src="/wangEditor/release/wangEditor.js"></script>
|
|
||||||
|
|
||||||
<script language="javascript" type="text/javascript">
|
<script language="javascript" type="text/javascript">
|
||||||
|
|
||||||
var E = window.wangEditor;
|
|
||||||
var editor2 = new E('#contentEditor');
|
|
||||||
// 自定义菜单配置
|
|
||||||
editor2.customConfig.menus = [
|
|
||||||
'head', // 标题
|
|
||||||
'bold', // 粗体
|
|
||||||
'fontSize', // 字号
|
|
||||||
'fontName', // 字体
|
|
||||||
'italic', // 斜体
|
|
||||||
'underline', // 下划线
|
|
||||||
'strikeThrough', // 删除线
|
|
||||||
'foreColor', // 文字颜色
|
|
||||||
//'backColor', // 背景颜色
|
|
||||||
//'link', // 插入链接
|
|
||||||
'list', // 列表
|
|
||||||
'justify', // 对齐方式
|
|
||||||
'quote', // 引用
|
|
||||||
'emoticon', // 表情
|
|
||||||
'image', // 插入图片
|
|
||||||
//'table', // 表格
|
|
||||||
//'video', // 插入视频
|
|
||||||
//'code', // 插入代码
|
|
||||||
'undo', // 撤销
|
|
||||||
'redo' // 重复
|
|
||||||
];
|
|
||||||
editor2.customConfig.onchange = function (html) {
|
|
||||||
// html 即变化之后的内容
|
|
||||||
$("#bookContent").val(html);
|
|
||||||
}
|
|
||||||
editor2.create();
|
|
||||||
|
|
||||||
|
var lock = false;
|
||||||
function addBookContent() {
|
function addBookContent() {
|
||||||
|
|
||||||
|
if(lock){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lock = true;
|
||||||
|
|
||||||
|
|
||||||
var bookId = getSearchString("bookId");
|
var bookId = getSearchString("bookId");
|
||||||
|
|
||||||
@ -158,12 +131,14 @@
|
|||||||
var indexName = $("#bookIndex").val();
|
var indexName = $("#bookIndex").val();
|
||||||
if(!indexName){
|
if(!indexName){
|
||||||
$("#LabErr").html("章节名不能为空!");
|
$("#LabErr").html("章节名不能为空!");
|
||||||
|
lock = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var content = $("#bookContent").val();
|
var content = $("#bookContent").val();
|
||||||
if(!content && content.length<=13){
|
if(!content){
|
||||||
$("#LabErr").html("章节内容不能为空!");
|
$("#LabErr").html("章节内容不能为空!");
|
||||||
|
lock = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,11 +157,13 @@
|
|||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
lock = false;
|
||||||
$("#LabErr").html(data.msg);
|
$("#LabErr").html(data.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
|
lock = false;
|
||||||
layer.alert('网络异常');
|
layer.alert('网络异常');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -159,7 +159,7 @@
|
|||||||
|
|
||||||
if(sortBy != false){
|
if(sortBy != false){
|
||||||
searchData.sort = sortBy;
|
searchData.sort = sortBy;
|
||||||
}else{
|
}else if(!keyword){
|
||||||
sortBy = "last_index_update_time";
|
sortBy = "last_index_update_time";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,9 +179,13 @@
|
|||||||
for (var i = 0; i < bookList.length; i++) {
|
for (var i = 0; i < bookList.length; i++) {
|
||||||
var book = bookList[i];
|
var book = bookList[i];
|
||||||
|
|
||||||
var end = book.bookDesc.indexOf("<");
|
/*var end = book.bookDesc.indexOf("<");
|
||||||
if(end != -1) {
|
if(end != -1) {
|
||||||
book.bookDesc = book.bookDesc.substring(0,end);
|
book.bookDesc = book.bookDesc.substring(0,end);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if(book.bookDesc){
|
||||||
|
book.bookDesc = book.bookDesc.replace(/<[^>]+>/g,"").replace(/\s+/g,"").replace(/ /g,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
bookListHtml += ("<div class=\"layui-row\" style=\"margin-bottom:10px;padding:10px;background: #f2f2f2\">\n" +
|
bookListHtml += ("<div class=\"layui-row\" style=\"margin-bottom:10px;padding:10px;background: #f2f2f2\">\n" +
|
||||||
@ -202,7 +206,7 @@
|
|||||||
" </a>\n" +
|
" </a>\n" +
|
||||||
" <div style=\"margin-top: 5px;color: #4c6978;\">类别:"+book.catName+"</div>\n" +
|
" <div style=\"margin-top: 5px;color: #4c6978;\">类别:"+book.catName+"</div>\n" +
|
||||||
" <div style=\"margin-top: 5px;color: #4c6978;\">状态:"+(book.bookStatus==0?'连载':'完结')+"</div>\n" +
|
" <div style=\"margin-top: 5px;color: #4c6978;\">状态:"+(book.bookStatus==0?'连载':'完结')+"</div>\n" +
|
||||||
" <div style=\"margin-top: 5px;color: #4c6978;\">更新:<i>"+book.lastIndexUpdateTime+"</i>\n" +
|
" <div style=\"margin-top: 5px;color: #4c6978;\">更新:<i>"+book.lastIndexUpdateTime.substr(0,11)+"</i>\n" +
|
||||||
" </div>\n" +
|
" </div>\n" +
|
||||||
" <div style=\"margin-top: 5px;color: #4c6978;\">简介:"+(book.bookDesc?(book.bookDesc.length>20?(book.bookDesc.substr(0,20)+"..."):book.bookDesc):book.bookDesc)+"</div>\n" +
|
" <div style=\"margin-top: 5px;color: #4c6978;\">简介:"+(book.bookDesc?(book.bookDesc.length>20?(book.bookDesc.substr(0,20)+"..."):book.bookDesc):book.bookDesc)+"</div>\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
|
@ -58,13 +58,13 @@
|
|||||||
<ul class="layui-nav app" lay-filter="" style="display:none;padding:0 10px;text-align: center">
|
<ul class="layui-nav app" lay-filter="" style="display:none;padding:0 10px;text-align: center">
|
||||||
<li class="layui-nav-item"><a>分类</a>
|
<li class="layui-nav-item"><a>分类</a>
|
||||||
<dl class="layui-nav-child">
|
<dl class="layui-nav-child">
|
||||||
<dd><a href="/book/book_ranking.html?catId=1">玄幻小说</a></dd>
|
<dd><a href="/book/book_ranking.html?catId=1&sort=last_index_update_time">玄幻小说</a></dd>
|
||||||
<dd><a href="/book/book_ranking.html?catId=2">修真小说</a></dd>
|
<dd><a href="/book/book_ranking.html?catId=2&sort=last_index_update_time">修真小说</a></dd>
|
||||||
<dd><a href="/book/book_ranking.html?catId=3">都市小说</a></dd>
|
<dd><a href="/book/book_ranking.html?catId=3&sort=last_index_update_time">都市小说</a></dd>
|
||||||
<dd><a href="/book/book_ranking.html?catId=4">历史小说</a></dd>
|
<dd><a href="/book/book_ranking.html?catId=4&sort=last_index_update_time">历史小说</a></dd>
|
||||||
<dd><a href="/book/book_ranking.html?catId=6">网游小说</a></dd>
|
<dd><a href="/book/book_ranking.html?catId=6&sort=last_index_update_time">网游小说</a></dd>
|
||||||
<dd><a href="/book/book_ranking.html?catId=5">科幻小说</a></dd>
|
<dd><a href="/book/book_ranking.html?catId=5&sort=last_index_update_time">科幻小说</a></dd>
|
||||||
<dd><a href="/book/book_ranking.html?catId=7">女频小说</a></dd>
|
<dd><a href="/book/book_ranking.html?catId=7&sort=last_index_update_time">女频小说</a></dd>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
<li class="layui-nav-item"><a>全本</a>
|
<li class="layui-nav-item"><a>全本</a>
|
||||||
@ -95,13 +95,13 @@
|
|||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="layui-nav pc" lay-filter="" style="padding:0 36px;text-align: center">
|
<ul class="layui-nav pc" lay-filter="" style="padding:0 36px;text-align: center">
|
||||||
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=1">玄幻小说</a></li>
|
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=1&sort=last_index_update_time">玄幻小说</a></li>
|
||||||
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=2">修真小说</a></li>
|
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=2&sort=last_index_update_time">修真小说</a></li>
|
||||||
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=3">都市小说</a></li>
|
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=3&sort=last_index_update_time">都市小说</a></li>
|
||||||
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=4">历史小说</a></li>
|
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=4&sort=last_index_update_time">历史小说</a></li>
|
||||||
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=6">网游小说</a></li>
|
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=6&sort=last_index_update_time">网游小说</a></li>
|
||||||
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=5">科幻小说</a></li>
|
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=5&sort=last_index_update_time">科幻小说</a></li>
|
||||||
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=7">女频小说</a></li>
|
<li class="layui-nav-item"><a href="/book/book_ranking.html?catId=7&sort=last_index_update_time">女频小说</a></li>
|
||||||
<li class="layui-nav-item"><a>完本小说</a>
|
<li class="layui-nav-item"><a>完本小说</a>
|
||||||
<dl class="layui-nav-child"> <!-- 二级菜单 -->
|
<dl class="layui-nav-child"> <!-- 二级菜单 -->
|
||||||
<dd><a href="/book/book_ranking.html?bookStatus=1">全部小说</a></dd>
|
<dd><a href="/book/book_ranking.html?bookStatus=1">全部小说</a></dd>
|
||||||
@ -276,6 +276,10 @@
|
|||||||
for (var i = 0; i < 6; i++) {
|
for (var i = 0; i < 6; i++) {
|
||||||
var hotRecBook = hotRecBooks[i];
|
var hotRecBook = hotRecBooks[i];
|
||||||
|
|
||||||
|
if(hotRecBook.bookDesc){
|
||||||
|
hotRecBook.bookDesc = hotRecBook.bookDesc.replace(/<[^>]+>/g,"").replace(/\s+/g,"");
|
||||||
|
}
|
||||||
|
|
||||||
hotRecBooksHtml += ("<div style=\"margin-bottom: 5px\" class=\"layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4\">\n" +
|
hotRecBooksHtml += ("<div style=\"margin-bottom: 5px\" class=\"layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4\">\n" +
|
||||||
" <a href=\"/book/"+hotRecBook.bookId+".html\">\n" +
|
" <a href=\"/book/"+hotRecBook.bookId+".html\">\n" +
|
||||||
" <div class=\"layui-col-xs5 layui-col-sm4 layui-col-md4 layui-col-lg4\" >\n" +
|
" <div class=\"layui-col-xs5 layui-col-sm4 layui-col-md4 layui-col-lg4\" >\n" +
|
||||||
@ -323,9 +327,8 @@
|
|||||||
for (var i = 0; i < 10; i++) {
|
for (var i = 0; i < 10; i++) {
|
||||||
|
|
||||||
var updateRankBook = updateRankBooks[i];
|
var updateRankBook = updateRankBooks[i];
|
||||||
var end = updateRankBook.bookDesc.indexOf("<");
|
if(updateRankBook.bookDesc){
|
||||||
if(end != -1) {
|
updateRankBook.bookDesc = updateRankBook.bookDesc.replace(/<[^>]+>/g,"").replace(/\s+/g,"");
|
||||||
updateRankBook.bookDesc = updateRankBook.bookDesc.substring(0,end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRankBookHtml += ("<div style=\"padding-bottom: 30px\"\n" +
|
updateRankBookHtml += ("<div style=\"padding-bottom: 30px\"\n" +
|
||||||
|
11
pom.xml
11
pom.xml
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.java2nb</groupId>
|
<groupId>com.java2nb</groupId>
|
||||||
<artifactId>novel</artifactId>
|
<artifactId>novel</artifactId>
|
||||||
<version>2.0.1</version>
|
<version>2.6.2</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>novel-common</module>
|
<module>novel-common</module>
|
||||||
<module>novel-front</module>
|
<module>novel-front</module>
|
||||||
@ -36,6 +36,15 @@
|
|||||||
<orderbyhelper.version>1.0.2</orderbyhelper.version>
|
<orderbyhelper.version>1.0.2</orderbyhelper.version>
|
||||||
<commons-lang3.version>3.4</commons-lang3.version>
|
<commons-lang3.version>3.4</commons-lang3.version>
|
||||||
<jjwt.version>0.9.0</jjwt.version>
|
<jjwt.version>0.9.0</jjwt.version>
|
||||||
|
<elasticsearch.version>6.2.2</elasticsearch.version>
|
||||||
|
<jest.version>6.3.1</jest.version>
|
||||||
|
<redis.version>1.4.1.RELEASE</redis.version>
|
||||||
|
<redisson.version>3.12.5</redisson.version>
|
||||||
|
<sharding.jdbc.version>3.0.0</sharding.jdbc.version>
|
||||||
|
<aliyun-sdk-oss.version>2.4.0</aliyun-sdk-oss.version>
|
||||||
|
<commons-fileupload.version>1.3.1</commons-fileupload.version>
|
||||||
|
<fastdfs-client.version>1.26.1-RELEASE</fastdfs-client.version>
|
||||||
|
<alipay-sdk-java.version>4.9.153.ALL</alipay-sdk-java.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
1111
sql/20200513.sql
1111
sql/20200513.sql
File diff suppressed because it is too large
Load Diff
3
sql/20200518.sql
Normal file
3
sql/20200518.sql
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
INSERT INTO `crawl_source` (`id`, `source_name`, `crawl_rule`, `source_status`, `create_time`, `update_time`) VALUES ('4', '书趣阁', '{\r\n \"bookListUrl\": \"http://m.shuquge.com/sort/{catId}/0_{page}.html\",\r\n \"catIdRule\": {\r\n \"catId1\": \"1\",\r\n \"catId2\": \"2\",\r\n \"catId3\": \"3\",\r\n \"catId4\": \"4\",\r\n \"catId5\": \"7\",\r\n \"catId6\": \"6\",\r\n \"catId7\": \"8\"\r\n },\r\n \"bookIdPatten\": \"href=\\\"/s/(\\\\d+)\\\\.html\\\"\",\r\n \"pagePatten\": \"第(\\\\d+)/\\\\d+页\",\r\n \"totalPagePatten\": \"第\\\\d+/(\\\\d+)页\",\r\n \"bookDetailUrl\": \"http://m.shuquge.com/s/{bookId}.html\",\r\n \"bookNamePatten\": \"<a\\\\s+href=\\\"/s/\\\\d+\\\\.html\\\"><h2>([^/]+)</h2></a>\",\r\n \"authorNamePatten\": \"<p>作者:([^/]+)</p>\",\r\n \"picUrlPatten\": \"src=\\\"(http://www.shuquge.com/files/article/image/\\\\d+/\\\\d+/\\\\d+s\\\\.jpg)\\\"\",\r\n \"statusPatten\": \"<p>状态:([^/]+)</p>\",\r\n \"bookStatusRule\": {\r\n \"连载中\": 0,\r\n \"完本\": 1\r\n },\r\n \"descStart\": \"<div class=\\\"intro_info\\\">\",\r\n \"descEnd\": \"最新章节推荐地址\",\r\n \"bookIndexUrl\": \"http://www.shuquge.com/txt/{bookId}/index.html\",\r\n \"bookIndexStart\": \"》正文\",\r\n \"indexIdPatten\": \"<dd><a\\\\s+href=\\\"(\\\\d+)\\\\.html\\\">[^/]+</a></dd>\",\r\n \"indexNamePatten\": \"<dd><a\\\\s+href=\\\"\\\\d+\\\\.html\\\">([^/]+)</a></dd>\",\r\n \"bookContentUrl\": \"http://www.shuquge.com/txt/{bookId}/{indexId}.html\",\r\n \"contentStart\": \"<div id=\\\"content\\\" class=\\\"showtxt\\\">\",\r\n \"contentEnd\": \"http://www.shuquge.com\"\r\n}', '1', '2020-05-18 12:02:34', '2020-05-18 12:02:34');
|
||||||
|
INSERT INTO `crawl_source` (`id`, `source_name`, `crawl_rule`, `source_status`, `create_time`, `update_time`) VALUES ('5', '笔趣阁', '{\"bookListUrl\":\"http://m.mcmssc.com/xclass/{catId}/{page}.html\",\"catIdRule\":{\"catId1\":\"1\",\"catId2\":\"2\",\"catId3\":\"3\",\"catId4\":\"4\",\"catId5\":\"5\",\"catId6\":\"6\",\"catId7\":\"7\"},\"bookIdPatten\":\"href=\\\"/(\\\\d+_\\\\d+)/\\\"\",\"pagePatten\":\"class=\\\"page_txt\\\"\\\\s+value=\\\"(\\\\d+)/\\\\d+\\\"\\\\s+size=\",\"totalPagePatten\":\"class=\\\"page_txt\\\"\\\\s+value=\\\"\\\\d+/(\\\\d+)\\\"\\\\s+size=\",\"bookDetailUrl\":\"http://m.mcmssc.com/{bookId}/\",\"bookNamePatten\":\"<span\\\\s+class=\\\"title\\\">([^/]+)</span>\",\"authorNamePatten\":\"<a\\\\s+href=\\\"/author/\\\\d+/\\\">([^/]+)</a>\",\"picUrlPatten\":\"<img\\\\s+src=\\\"([^>]+)\\\"\\\\s+onerror=\",\"picUrlPrefix\":\"http://m.mcmssc.com/\",\"statusPatten\":\">状态:([^/]+)<\",\"bookStatusRule\":{\"连载\":0,\"全本\":1},\"visitCountPatten\":\">点击:(\\\\d+)<\",\"descStart\":\"<p class=\\\"review\\\">\",\"descEnd\":\"</p>\",\"bookIndexUrl\":\"http://m.mcmssc.com/{bookId}/all.html\",\"indexIdPatten\":\"<a\\\\s+href=\\\"/\\\\d+_\\\\d+/(\\\\d+)\\\\.html\\\">[^/]+</a>\",\"indexNamePatten\":\"<a\\\\s+href=\\\"/\\\\d+_\\\\d+/\\\\d+\\\\.html\\\">([^/]+)</a>\",\"bookContentUrl\":\"http://www.mcmssc.com/{bookId}/{indexId}.html\",\"contentStart\":\"</p>\",\"contentEnd\":\"<div align=\\\"center\\\">\"}', '1', '2020-05-18 15:57:41', '2020-05-18 15:57:41');
|
||||||
|
UPDATE `crawl_source` SET `source_name` = '书趣阁', `crawl_rule` = '{\n \"bookListUrl\": \"http://m.shuquge.com/sort/{catId}/0_{page}.html\",\n \"catIdRule\": {\n \"catId1\": \"1\",\n \"catId2\": \"2\",\n \"catId3\": \"3\",\n \"catId4\": \"4\",\n \"catId5\": \"7\",\n \"catId6\": \"6\",\n \"catId7\": \"8\"\n },\n \"bookIdPatten\": \"href=\\\"/s/(\\\\d+)\\\\.html\\\"\",\n \"pagePatten\": \"第(\\\\d+)/\\\\d+页\",\n \"totalPagePatten\": \"第\\\\d+/(\\\\d+)页\",\n \"bookDetailUrl\": \"http://m.shuquge.com/s/{bookId}.html\",\n \"bookNamePatten\": \"<a\\\\s+href=\\\"/s/\\\\d+\\\\.html\\\"><h2>([^/]+)</h2></a>\",\n \"authorNamePatten\": \"<p>作者:([^/]+)</p>\",\n \"picUrlPatten\": \"src=\\\"(http://www.shuquge.com/files/article/image/\\\\d+/\\\\d+/\\\\d+s\\\\.jpg)\\\"\",\n \"statusPatten\": \"<p>状态:([^/]+)</p>\",\n \"bookStatusRule\": {\n \"连载中\": 0,\n \"完本\": 1\n },\n \"descStart\": \"<div class=\\\"intro_info\\\">\",\n \"descEnd\": \"最新章节推荐地址\",\n \"bookIndexUrl\": \"http://www.shuquge.com/txt/{bookId}/index.html\",\n \"bookIndexStart\": \"<dt>《\",\n \"indexIdPatten\": \"<dd><a\\\\s+href=\\\"(\\\\d+)\\\\.html\\\">[^/]+</a></dd>\",\n \"indexNamePatten\": \"<dd><a\\\\s+href=\\\"\\\\d+\\\\.html\\\">([^/]+)</a></dd>\",\n \"bookContentUrl\": \"http://www.shuquge.com/txt/{bookId}/{indexId}.html\",\n \"contentStart\": \"<div id=\\\"content\\\" class=\\\"showtxt\\\">\",\n \"contentEnd\": \"http://www.shuquge.com\"\n}', `source_status` = 1, `create_time` = '2020-05-18 12:02:34', `update_time` = '2020-05-18 12:02:34' WHERE `id` = 4;
|
2
sql/20200608.sql
Normal file
2
sql/20200608.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
INSERT INTO `crawl_source` (`id`, `source_name`, `crawl_rule`, `source_status`, `create_time`, `update_time`) VALUES
|
||||||
|
(6, '新笔趣阁', '{\n \"bookListUrl\": \"http://www.xbiquge.la/fenlei/{catId}_{page}.html\",\n \"catIdRule\": {\n \"catId1\": \"1\",\n \"catId2\": \"2\",\n \"catId3\": \"3\",\n \"catId4\": \"4\",\n \"catId5\": \"6\",\n \"catId6\": \"5\"\n },\n \"bookIdPatten\": \"<a\\\\s+href=\\\"http://www.xbiquge.la/(\\\\d+/\\\\d+)/\\\"\\\\s+target=\\\"_blank\\\">\",\n \"pagePatten\": \"<em\\\\s+id=\\\"pagestats\\\">(\\\\d+)/\\\\d+</em>\",\n \"totalPagePatten\": \"<em\\\\s+id=\\\"pagestats\\\">\\\\d+/(\\\\d+)</em>\",\n \"bookDetailUrl\": \"http://www.xbiquge.la/{bookId}/\",\n \"bookNamePatten\": \"<h1>([^/]+)</h1>\",\n \"authorNamePatten\": \"者:([^/]+)</p>\",\n \"picUrlPatten\": \"src=\\\"(http://www.xbiquge.la/files/article/image/\\\\d+/\\\\d+/\\\\d+s\\\\.jpg)\\\"\",\n \"bookStatusRule\": {},\n \"descStart\": \"<div id=\\\"intro\\\">\",\n \"descEnd\": \"</div>\",\n \"upadateTimePatten\": \"<p>最后更新:(\\\\d+-\\\\d+-\\\\d+\\\\s\\\\d+:\\\\d+:\\\\d+)</p>\",\n \"upadateTimeFormatPatten\": \"yyyy-MM-dd HH:mm:ss\",\n \"bookIndexUrl\": \"http://www.xbiquge.la/{bookId}/\",\n \"indexIdPatten\": \"<a\\\\s+href=\'/\\\\d+/\\\\d+/(\\\\d+)\\\\.html\'\\\\s+>[^/]+</a>\",\n \"indexNamePatten\": \"<a\\\\s+href=\'/\\\\d+/\\\\d+/\\\\d+\\\\.html\'\\\\s+>([^/]+)</a>\",\n \"bookContentUrl\": \"http://www.xbiquge.la/{bookId}/{indexId}.html\",\n \"contentStart\": \"<div id=\\\"content\\\">\",\n \"contentEnd\": \"<p>\"\n}', 0, '2020-05-23 22:46:58', '2020-05-23 22:46:58');
|
40
sql/20200615.sql
Normal file
40
sql/20200615.sql
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
Navicat MySQL Data Transfer
|
||||||
|
|
||||||
|
Source Server : localhost
|
||||||
|
Source Server Version : 50725
|
||||||
|
Source Host : localhost:3306
|
||||||
|
Source Database : novel_plus
|
||||||
|
|
||||||
|
Target Server Type : MYSQL
|
||||||
|
Target Server Version : 50725
|
||||||
|
File Encoding : 65001
|
||||||
|
|
||||||
|
Date: 2020-06-15 15:06:55
|
||||||
|
*/
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS=0;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for crawl_single_task
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `crawl_single_task`;
|
||||||
|
CREATE TABLE `crawl_single_task` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`source_id` int(11) DEFAULT NULL COMMENT '爬虫源ID',
|
||||||
|
`source_name` varchar(50) DEFAULT NULL COMMENT '爬虫源名',
|
||||||
|
`source_book_id` varchar(255) DEFAULT NULL COMMENT '源站小说ID',
|
||||||
|
`cat_id` int(11) DEFAULT NULL COMMENT '分类ID',
|
||||||
|
`book_name` varchar(50) DEFAULT NULL COMMENT '爬取的小说名',
|
||||||
|
`author_name` varchar(50) DEFAULT NULL COMMENT '爬取的小说作者名',
|
||||||
|
`task_status` tinyint(1) DEFAULT '2' COMMENT '任务状态,0:失败,1:成功,2;未执行',
|
||||||
|
`exc_count` tinyint(2) DEFAULT '0' COMMENT '已经执行次数,最多执行5次',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COMMENT='抓取单本小说任务表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of crawl_single_task
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `crawl_single_task` VALUES ('6', '2', '百书斋', '1', '1', '1', '1', '0', '5', '2020-06-15 14:36:07');
|
||||||
|
INSERT INTO `crawl_single_task` VALUES ('7', '5', '笔趣阁', '108_108291', '1', '衍天志之不朽仙', '白衣少年丶', '1', '1', '2020-06-15 14:46:08');
|
@ -2,19 +2,65 @@
|
|||||||
Navicat MySQL Data Transfer
|
Navicat MySQL Data Transfer
|
||||||
|
|
||||||
Source Server : localhost
|
Source Server : localhost
|
||||||
Source Server Version : 50624
|
Source Server Version : 50725
|
||||||
Source Host : localhost:3306
|
Source Host : localhost:3306
|
||||||
Source Database : novel_biz
|
Source Database : novel_plus
|
||||||
|
|
||||||
Target Server Type : MYSQL
|
Target Server Type : MYSQL
|
||||||
Target Server Version : 50624
|
Target Server Version : 50725
|
||||||
File Encoding : 65001
|
File Encoding : 65001
|
||||||
|
|
||||||
Date: 2020-05-02 10:53:04
|
Date: 2020-05-18 13:59:04
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS=0;
|
SET FOREIGN_KEY_CHECKS=0;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for author
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `author`;
|
||||||
|
CREATE TABLE `author` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`user_id` bigint(20) DEFAULT NULL COMMENT '用户ID',
|
||||||
|
`invite_code` varchar(20) DEFAULT NULL COMMENT '邀请码',
|
||||||
|
`pen_name` varchar(20) DEFAULT NULL COMMENT '笔名',
|
||||||
|
`tel_phone` varchar(20) DEFAULT NULL COMMENT '手机号码',
|
||||||
|
`chat_account` varchar(50) DEFAULT NULL COMMENT 'QQ或微信账号',
|
||||||
|
`email` varchar(50) DEFAULT NULL COMMENT '电子邮箱',
|
||||||
|
`work_direction` tinyint(4) DEFAULT NULL COMMENT '作品方向,0:男频,1:女频',
|
||||||
|
`status` tinyint(4) DEFAULT '0' COMMENT '0:正常,1:封禁',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='作者表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of author
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `author` VALUES ('1', null, 'reerer', 'abc', '13560487656', '23484388', '23484388@qq.com', '0', '0', null);
|
||||||
|
INSERT INTO `author` VALUES ('2', '1255060328322027520', 'rwrr445554', '梦入神机', '13560421324', '1179705413', 'reerer@qq.com', '0', '0', '2020-05-13 14:01:31');
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for author_code
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `author_code`;
|
||||||
|
CREATE TABLE `author_code` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`invite_code` varchar(100) DEFAULT NULL COMMENT '邀请码',
|
||||||
|
`validity_time` datetime DEFAULT NULL COMMENT '有效时间',
|
||||||
|
`is_use` tinyint(1) DEFAULT '0' COMMENT '是否使用过,0:未使用,1:使用过',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`create_user_id` bigint(20) DEFAULT NULL COMMENT '创建人ID',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `key_code` (`invite_code`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT='作家邀请码表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of author_code
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `author_code` VALUES ('3', 'reerer', '2020-05-27 22:43:45', '1', '2020-05-13 11:40:56', '1');
|
||||||
|
INSERT INTO `author_code` VALUES ('4', '123456', '2020-05-28 00:00:00', '0', '2020-05-13 14:09:55', '1');
|
||||||
|
INSERT INTO `author_code` VALUES ('5', 'ww34343', '2020-05-21 00:00:00', '0', '2020-05-13 14:18:58', '1');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for book
|
-- Table structure for book
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
@ -49,7 +95,7 @@ CREATE TABLE `book` (
|
|||||||
UNIQUE KEY `key_uq_bookName_authorName` (`book_name`,`author_name`) USING BTREE,
|
UNIQUE KEY `key_uq_bookName_authorName` (`book_name`,`author_name`) USING BTREE,
|
||||||
KEY `key_lastIndexUpdateTime` (`last_index_update_time`) USING BTREE,
|
KEY `key_lastIndexUpdateTime` (`last_index_update_time`) USING BTREE,
|
||||||
KEY `key_createTime` (`create_time`) USING BTREE
|
KEY `key_createTime` (`create_time`) USING BTREE
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1256127379949019137 DEFAULT CHARSET=utf8mb4 COMMENT='小说表';
|
) ENGINE=InnoDB AUTO_INCREMENT=1262260513468559361 DEFAULT CHARSET=utf8mb4 COMMENT='小说表';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of book
|
-- Records of book
|
||||||
@ -156,7 +202,7 @@ CREATE TABLE `book_content` (
|
|||||||
`content` mediumtext COMMENT '小说章节内容',
|
`content` mediumtext COMMENT '小说章节内容',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
|
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=3342428 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
|
) ENGINE=InnoDB AUTO_INCREMENT=3347665 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of book_content
|
-- Records of book_content
|
||||||
@ -179,7 +225,7 @@ CREATE TABLE `book_index` (
|
|||||||
UNIQUE KEY `key_uq_bookId_indexNum` (`book_id`,`index_num`) USING BTREE,
|
UNIQUE KEY `key_uq_bookId_indexNum` (`book_id`,`index_num`) USING BTREE,
|
||||||
KEY `key_bookId` (`book_id`) USING BTREE,
|
KEY `key_bookId` (`book_id`) USING BTREE,
|
||||||
KEY `key_indexNum` (`index_num`) USING BTREE
|
KEY `key_indexNum` (`index_num`) USING BTREE
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1256373101432717313 DEFAULT CHARSET=utf8mb4 COMMENT='小说目录表';
|
) ENGINE=InnoDB AUTO_INCREMENT=1262260612777095169 DEFAULT CHARSET=utf8mb4 COMMENT='小说目录表';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of book_index
|
-- Records of book_index
|
||||||
@ -303,13 +349,15 @@ CREATE TABLE `crawl_source` (
|
|||||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COMMENT='爬虫源表';
|
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COMMENT='爬虫源表';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of crawl_source
|
-- Records of crawl_source
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `crawl_source` VALUES ('2', '百书斋', '{\r\n \"bookListUrl\": \"https://m.baishuzhai.com/blhb/{catId}/{page}.html\",\r\n \"catIdRule\": {\r\n \"catId1\": \"1\",\r\n \"catId2\": \"2\",\r\n \"catId3\": \"3\",\r\n \"catId4\": \"4\",\r\n \"catId5\": \"5\",\r\n \"catId6\": \"6\",\r\n \"catId7\": \"7\"\r\n },\r\n \"bookIdPatten\": \"href=\\\"/ibook/(\\\\d+/\\\\d+)/\\\"\",\r\n \"pagePatten\": \"value=\\\"(\\\\d+)/\\\\d+\\\"\",\r\n \"totalPagePatten\": \"value=\\\"\\\\d+/(\\\\d+)\\\"\",\r\n \"bookDetailUrl\": \"https://m.baishuzhai.com/ibook/{bookId}/\",\r\n \"bookNamePatten\": \"<span class=\\\"title\\\">([^/]+)</span>\",\r\n \"authorNamePatten\": \">作者:([^/]+)<\",\r\n \"picUrlPatten\": \"<img src=\\\"([^>]+)\\\"\\\\s+onerror=\\\"this.src=\",\r\n \"statusPatten\": \"状态:([^/]+)</li>\",\r\n \"bookStatusRule\": {\r\n \"连载\": 0,\r\n \"完成\": 1\r\n },\r\n \"scorePatten\": \"<em>([^<]+)</em>\",\r\n \"descStart\": \"<p class=\\\"review\\\">\",\r\n \"descEnd\": \"</p>\",\r\n \"upadateTimePatten\": \"更新:(\\\\d+-\\\\d+-\\\\d+)</li>\",\r\n \"upadateTimeFormatPatten\": \"yy-MM-dd\",\r\n \"bookIndexUrl\": \"https://m.baishuzhai.com/ibook/{bookId}/all.html\",\r\n \"indexIdPatten\": \"<a\\\\s+style=\\\"\\\"\\\\s+href=\\\"/ibook/\\\\d+/\\\\d+/(\\\\d+)\\\\.html\\\">[^/]+</a>\",\r\n \"indexNamePatten\": \"<a\\\\s+style=\\\"\\\"\\\\s+href=\\\"/ibook/\\\\d+/\\\\d+/\\\\d+\\\\.html\\\">([^/]+)</a>\",\r\n \"bookContentUrl\": \"https://baishuzhai.com/ibook/{bookId}/{indexId}.html\",\r\n \"contentStart\": \"id=\\\"content\\\">\",\r\n \"contentEnd\": \"<script>\"\r\n}', '0', '2020-05-01 14:22:50', '2020-05-01 14:22:50');
|
INSERT INTO `crawl_source` VALUES ('2', '百书斋', '{\r\n \"bookListUrl\": \"https://m.baishuzhai.com/blhb/{catId}/{page}.html\",\r\n \"catIdRule\": {\r\n \"catId1\": \"1\",\r\n \"catId2\": \"2\",\r\n \"catId3\": \"3\",\r\n \"catId4\": \"4\",\r\n \"catId5\": \"5\",\r\n \"catId6\": \"6\",\r\n \"catId7\": \"7\"\r\n },\r\n \"bookIdPatten\": \"href=\\\"/ibook/(\\\\d+/\\\\d+)/\\\"\",\r\n \"pagePatten\": \"value=\\\"(\\\\d+)/\\\\d+\\\"\",\r\n \"totalPagePatten\": \"value=\\\"\\\\d+/(\\\\d+)\\\"\",\r\n \"bookDetailUrl\": \"https://m.baishuzhai.com/ibook/{bookId}/\",\r\n \"bookNamePatten\": \"<span class=\\\"title\\\">([^/]+)</span>\",\r\n \"authorNamePatten\": \">作者:([^/]+)<\",\r\n \"picUrlPatten\": \"<img src=\\\"([^>]+)\\\"\\\\s+onerror=\\\"this.src=\",\r\n \"statusPatten\": \"状态:([^/]+)</li>\",\r\n \"bookStatusRule\": {\r\n \"连载\": 0,\r\n \"完成\": 1\r\n },\r\n \"scorePatten\": \"<em>([^<]+)</em>\",\r\n \"descStart\": \"<p class=\\\"review\\\">\",\r\n \"descEnd\": \"</p>\",\r\n \"upadateTimePatten\": \"更新:(\\\\d+-\\\\d+-\\\\d+)</li>\",\r\n \"upadateTimeFormatPatten\": \"yy-MM-dd\",\r\n \"bookIndexUrl\": \"https://m.baishuzhai.com/ibook/{bookId}/all.html\",\r\n \"indexIdPatten\": \"<a\\\\s+style=\\\"\\\"\\\\s+href=\\\"/ibook/\\\\d+/\\\\d+/(\\\\d+)\\\\.html\\\">[^/]+</a>\",\r\n \"indexNamePatten\": \"<a\\\\s+style=\\\"\\\"\\\\s+href=\\\"/ibook/\\\\d+/\\\\d+/\\\\d+\\\\.html\\\">([^/]+)</a>\",\r\n \"bookContentUrl\": \"https://baishuzhai.com/ibook/{bookId}/{indexId}.html\",\r\n \"contentStart\": \"id=\\\"content\\\">\",\r\n \"contentEnd\": \"<script>\"\r\n}', '0', '2020-05-01 14:22:50', '2020-05-01 14:22:50');
|
||||||
INSERT INTO `crawl_source` VALUES ('3', '书包网', '{\r\n \"bookListUrl\": \"https://www.bookbao8.com/booklist-p_{page}-c_{catId}-t_0-o_0.html\",\r\n \"catIdRule\": {\r\n \"catId1\": \"5\",\r\n \"catId2\": \"4\",\r\n \"catId3\": \"8\",\r\n \"catId4\": \"9\",\r\n \"catId5\": \"3\",\r\n \"catId6\": \"7\"\r\n },\r\n \"bookIdPatten\": \"href=\\\"/book/(\\\\d+/\\\\d+/id_[^.]+).html\\\"\",\r\n \"pagePatten\": \"<span\\\\s+class=\\\"current\\\">([^<]+)</span>\",\r\n \"totalPagePatten\": \"/共(\\\\d+)页\",\r\n \"bookDetailUrl\": \"https://www.bookbao8.com/book/{bookId}.html\",\r\n \"bookNamePatten\": \"<div\\\\s+id=\\\"info\\\">\\\\s*<h1>([^<]+)</h1>\",\r\n \"authorNamePatten\": \"<p>作者:<a\\\\s+href=\\\"/Search/[^\\\"]+\\\"\\\\s+target=\\\"_blank\\\">([^<]+)</a></p>\",\r\n \"picUrlPatten\": \"<div\\\\s+id=\\\"fmimg\\\">\\\\s*<img\\\\s+alt=\\\"[^\\\"]+\\\"\\\\s+src=\\\"([^\\\"]+)\\\"\",\r\n \"statusPatten\": \"<p>状态:([^<]+)</p>\",\r\n \"bookStatusRule\": {\r\n \"连载中\": 0,\r\n \"已完结\": 1\r\n },\r\n \"visitCountPatten\": \"<em\\\\s+id=\\\"hits\\\">(\\\\d+)</em>\",\r\n \"descStart\": \"<div class=\\\"infocontent\\\">\",\r\n \"descEnd\": \"</div>\",\r\n \"upadateTimePatten\": \"<p>更新时间:(\\\\d+-\\\\d+-\\\\d+\\\\s\\\\d+:\\\\d+:\\\\d+)</p>\",\r\n \"upadateTimeFormatPatten\": \"yyyy-MM-dd HH:mm:ss\",\r\n \"bookIndexUrl\": \"https://www.bookbao8.com/book/{bookId}.html\",\r\n \"indexIdPatten\": \"<li>\\\\s*<a\\\\s+href=\\\"/views/\\\\d+/\\\\d+/id_[^_]+_(\\\\d+).html\\\"\\\\s+target=\\\"_blank\\\">\",\r\n \"indexNamePatten\": \"<li>\\\\s*<a\\\\s+href=\\\"/views/\\\\d+/\\\\d+/id_[^_]+_\\\\d+.html\\\"\\\\s+target=\\\"_blank\\\">([^<]+)</a>\",\r\n \"bookContentUrl\": \"https://www.bookbao8.com/views/{bookId}_{indexId}.html\",\r\n \"contentStart\": \"<dd id=\\\"contents\\\">\",\r\n \"contentEnd\": \"</dd>\"\r\n}', '0', '2020-05-04 17:42:22', '2020-05-04 17:42:22');
|
INSERT INTO `crawl_source` VALUES ('3', '书包网', '{\r\n \"bookListUrl\": \"https://www.bookbao8.com/booklist-p_{page}-c_{catId}-t_0-o_0.html\",\r\n \"catIdRule\": {\r\n \"catId1\": \"5\",\r\n \"catId2\": \"4\",\r\n \"catId3\": \"8\",\r\n \"catId4\": \"9\",\r\n \"catId5\": \"3\",\r\n \"catId6\": \"7\"\r\n },\r\n \"bookIdPatten\": \"href=\\\"/book/(\\\\d+/\\\\d+/id_[^.]+).html\\\"\",\r\n \"pagePatten\": \"<span\\\\s+class=\\\"current\\\">([^<]+)</span>\",\r\n \"totalPagePatten\": \"/共(\\\\d+)页\",\r\n \"bookDetailUrl\": \"https://www.bookbao8.com/book/{bookId}.html\",\r\n \"bookNamePatten\": \"<div\\\\s+id=\\\"info\\\">\\\\s*<h1>([^<]+)</h1>\",\r\n \"authorNamePatten\": \"<p>作者:<a\\\\s+href=\\\"/Search/[^\\\"]+\\\"\\\\s+target=\\\"_blank\\\">([^<]+)</a></p>\",\r\n \"picUrlPatten\": \"<div\\\\s+id=\\\"fmimg\\\">\\\\s*<img\\\\s+alt=\\\"[^\\\"]+\\\"\\\\s+src=\\\"([^\\\"]+)\\\"\",\r\n \"statusPatten\": \"<p>状态:([^<]+)</p>\",\r\n \"bookStatusRule\": {\r\n \"连载中\": 0,\r\n \"已完结\": 1\r\n },\r\n \"visitCountPatten\": \"<em\\\\s+id=\\\"hits\\\">(\\\\d+)</em>\",\r\n \"descStart\": \"<div class=\\\"infocontent\\\">\",\r\n \"descEnd\": \"</div>\",\r\n \"upadateTimePatten\": \"<p>更新时间:(\\\\d+-\\\\d+-\\\\d+\\\\s\\\\d+:\\\\d+:\\\\d+)</p>\",\r\n \"upadateTimeFormatPatten\": \"yyyy-MM-dd HH:mm:ss\",\r\n \"bookIndexUrl\": \"https://www.bookbao8.com/book/{bookId}.html\",\r\n \"indexIdPatten\": \"<li>\\\\s*<a\\\\s+href=\\\"/views/\\\\d+/\\\\d+/id_[^_]+_(\\\\d+).html\\\"\\\\s+target=\\\"_blank\\\">\",\r\n \"indexNamePatten\": \"<li>\\\\s*<a\\\\s+href=\\\"/views/\\\\d+/\\\\d+/id_[^_]+_\\\\d+.html\\\"\\\\s+target=\\\"_blank\\\">([^<]+)</a>\",\r\n \"bookContentUrl\": \"https://www.bookbao8.com/views/{bookId}_{indexId}.html\",\r\n \"contentStart\": \"<dd id=\\\"contents\\\">\",\r\n \"contentEnd\": \"</dd>\"\r\n}', '0', '2020-05-04 17:42:22', '2020-05-04 17:42:22');
|
||||||
|
INSERT INTO `crawl_source` VALUES ('4', '书趣阁', '{\r\n \"bookListUrl\": \"http://m.shuquge.com/sort/{catId}/0_{page}.html\",\r\n \"catIdRule\": {\r\n \"catId1\": \"1\",\r\n \"catId2\": \"2\",\r\n \"catId3\": \"3\",\r\n \"catId4\": \"4\",\r\n \"catId5\": \"7\",\r\n \"catId6\": \"6\",\r\n \"catId7\": \"8\"\r\n },\r\n \"bookIdPatten\": \"href=\\\"/s/(\\\\d+)\\\\.html\\\"\",\r\n \"pagePatten\": \"第(\\\\d+)/\\\\d+页\",\r\n \"totalPagePatten\": \"第\\\\d+/(\\\\d+)页\",\r\n \"bookDetailUrl\": \"http://m.shuquge.com/s/{bookId}.html\",\r\n \"bookNamePatten\": \"<a\\\\s+href=\\\"/s/\\\\d+\\\\.html\\\"><h2>([^/]+)</h2></a>\",\r\n \"authorNamePatten\": \"<p>作者:([^/]+)</p>\",\r\n \"picUrlPatten\": \"src=\\\"(http://www.shuquge.com/files/article/image/\\\\d+/\\\\d+/\\\\d+s\\\\.jpg)\\\"\",\r\n \"statusPatten\": \"<p>状态:([^/]+)</p>\",\r\n \"bookStatusRule\": {\r\n \"连载中\": 0,\r\n \"完本\": 1\r\n },\r\n \"descStart\": \"<div class=\\\"intro_info\\\">\",\r\n \"descEnd\": \"最新章节推荐地址\",\r\n \"bookIndexUrl\": \"http://www.shuquge.com/txt/{bookId}/index.html\",\r\n \"bookIndexStart\": \"》正文\",\r\n \"indexIdPatten\": \"<dd><a\\\\s+href=\\\"(\\\\d+)\\\\.html\\\">[^/]+</a></dd>\",\r\n \"indexNamePatten\": \"<dd><a\\\\s+href=\\\"\\\\d+\\\\.html\\\">([^/]+)</a></dd>\",\r\n \"bookContentUrl\": \"http://www.shuquge.com/txt/{bookId}/{indexId}.html\",\r\n \"contentStart\": \"<div id=\\\"content\\\" class=\\\"showtxt\\\">\",\r\n \"contentEnd\": \"http://www.shuquge.com\"\r\n}', '1', '2020-05-18 12:02:34', '2020-05-18 12:02:34');
|
||||||
|
INSERT INTO `crawl_source` (`id`, `source_name`, `crawl_rule`, `source_status`, `create_time`, `update_time`) VALUES ('5', '笔趣阁', '{\"bookListUrl\":\"http://m.mcmssc.com/xclass/{catId}/{page}.html\",\"catIdRule\":{\"catId1\":\"1\",\"catId2\":\"2\",\"catId3\":\"3\",\"catId4\":\"4\",\"catId5\":\"5\",\"catId6\":\"6\",\"catId7\":\"7\"},\"bookIdPatten\":\"href=\\\"/(\\\\d+_\\\\d+)/\\\"\",\"pagePatten\":\"class=\\\"page_txt\\\"\\\\s+value=\\\"(\\\\d+)/\\\\d+\\\"\\\\s+size=\",\"totalPagePatten\":\"class=\\\"page_txt\\\"\\\\s+value=\\\"\\\\d+/(\\\\d+)\\\"\\\\s+size=\",\"bookDetailUrl\":\"http://m.mcmssc.com/{bookId}/\",\"bookNamePatten\":\"<span\\\\s+class=\\\"title\\\">([^/]+)</span>\",\"authorNamePatten\":\"<a\\\\s+href=\\\"/author/\\\\d+/\\\">([^/]+)</a>\",\"picUrlPatten\":\"<img\\\\s+src=\\\"([^>]+)\\\"\\\\s+onerror=\",\"picUrlPrefix\":\"http://m.mcmssc.com/\",\"statusPatten\":\">状态:([^/]+)<\",\"bookStatusRule\":{\"连载\":0,\"全本\":1},\"visitCountPatten\":\">点击:(\\\\d+)<\",\"descStart\":\"<p class=\\\"review\\\">\",\"descEnd\":\"</p>\",\"bookIndexUrl\":\"http://m.mcmssc.com/{bookId}/all.html\",\"indexIdPatten\":\"<a\\\\s+href=\\\"/\\\\d+_\\\\d+/(\\\\d+)\\\\.html\\\">[^/]+</a>\",\"indexNamePatten\":\"<a\\\\s+href=\\\"/\\\\d+_\\\\d+/\\\\d+\\\\.html\\\">([^/]+)</a>\",\"bookContentUrl\":\"http://www.mcmssc.com/{bookId}/{indexId}.html\",\"contentStart\":\"</p>\",\"contentEnd\":\"<div align=\\\"center\\\">\"}', '1', '2020-05-18 15:57:41', '2020-05-18 15:57:41');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for friend_link
|
-- Table structure for friend_link
|
||||||
@ -378,6 +426,27 @@ CREATE TABLE `news_category` (
|
|||||||
INSERT INTO `news_category` VALUES ('1', '招募', '10', null, null, null, null);
|
INSERT INTO `news_category` VALUES ('1', '招募', '10', null, null, null, null);
|
||||||
INSERT INTO `news_category` VALUES ('3', '公告', '11', null, null, null, null);
|
INSERT INTO `news_category` VALUES ('3', '公告', '11', null, null, null, null);
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for order_pay
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `order_pay`;
|
||||||
|
CREATE TABLE `order_pay` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`out_trade_no` bigint(20) NOT NULL COMMENT '商户订单号',
|
||||||
|
`trade_no` varchar(64) DEFAULT NULL COMMENT '支付宝/微信交易号',
|
||||||
|
`pay_channel` tinyint(1) NOT NULL DEFAULT '1' COMMENT '支付渠道,1:支付宝,2:微信',
|
||||||
|
`total_amount` int(11) NOT NULL COMMENT '交易金额(单位元)',
|
||||||
|
`user_id` bigint(20) NOT NULL COMMENT '支付用户ID',
|
||||||
|
`pay_status` tinyint(1) DEFAULT '2' COMMENT '支付状态:0:支付失败,1:支付成功,2:待支付',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COMMENT='充值订单';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of order_pay
|
||||||
|
-- ----------------------------
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_data_perm
|
-- Table structure for sys_data_perm
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
@ -456,7 +525,7 @@ CREATE TABLE `sys_dict` (
|
|||||||
KEY `sys_dict_value` (`value`),
|
KEY `sys_dict_value` (`value`),
|
||||||
KEY `sys_dict_label` (`name`),
|
KEY `sys_dict_label` (`name`),
|
||||||
KEY `sys_dict_del_flag` (`del_flag`)
|
KEY `sys_dict_del_flag` (`del_flag`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=140 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='字典表';
|
) ENGINE=InnoDB AUTO_INCREMENT=142 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='字典表';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of sys_dict
|
-- Records of sys_dict
|
||||||
@ -589,6 +658,8 @@ INSERT INTO `sys_dict` VALUES ('136', '富文本', '6', 'page_type', '页面显
|
|||||||
INSERT INTO `sys_dict` VALUES ('137', '上传图片【单文件】', '7', 'page_type', '页面显示类型', '7', null, null, null, null, null, '', null);
|
INSERT INTO `sys_dict` VALUES ('137', '上传图片【单文件】', '7', 'page_type', '页面显示类型', '7', null, null, null, null, null, '', null);
|
||||||
INSERT INTO `sys_dict` VALUES ('138', '隐藏域', '11', 'page_type', '页面显示类型', '11', null, null, null, null, null, '', null);
|
INSERT INTO `sys_dict` VALUES ('138', '隐藏域', '11', 'page_type', '页面显示类型', '11', null, null, null, null, null, '', null);
|
||||||
INSERT INTO `sys_dict` VALUES ('139', '不显示', '12', 'page_type', '页面显示类型', '12', null, null, null, null, null, '', null);
|
INSERT INTO `sys_dict` VALUES ('139', '不显示', '12', 'page_type', '页面显示类型', '12', null, null, null, null, null, '', null);
|
||||||
|
INSERT INTO `sys_dict` VALUES ('140', '男频', '0', 'work_direction', '作品方向', '0', null, null, null, null, null, '', null);
|
||||||
|
INSERT INTO `sys_dict` VALUES ('141', '女频', '1', 'work_direction', '作品方向', '1', null, null, null, null, null, '', null);
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_file
|
-- Table structure for sys_file
|
||||||
@ -664,7 +735,7 @@ CREATE TABLE `sys_gen_columns` (
|
|||||||
`is_required` tinyint(1) DEFAULT NULL COMMENT '是否必填',
|
`is_required` tinyint(1) DEFAULT NULL COMMENT '是否必填',
|
||||||
`dict_type` varchar(100) CHARACTER SET utf8 DEFAULT '' COMMENT '页面显示为下拉时使用,字典类型从字典表中取出',
|
`dict_type` varchar(100) CHARACTER SET utf8 DEFAULT '' COMMENT '页面显示为下拉时使用,字典类型从字典表中取出',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=801 DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB AUTO_INCREMENT=815 DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of sys_gen_columns
|
-- Records of sys_gen_columns
|
||||||
@ -728,6 +799,20 @@ INSERT INTO `sys_gen_columns` VALUES ('797', 'fb_order', 'push_time', 'datetime'
|
|||||||
INSERT INTO `sys_gen_columns` VALUES ('798', 'fb_order', 'push_ip', 'varchar', 'String', '推送IP', '31', '推送IP', '6', '0', 'del_flag');
|
INSERT INTO `sys_gen_columns` VALUES ('798', 'fb_order', 'push_ip', 'varchar', 'String', '推送IP', '31', '推送IP', '6', '0', 'del_flag');
|
||||||
INSERT INTO `sys_gen_columns` VALUES ('799', 'fb_order', 'mcht_id', 'bigint', 'BigDecimal', '商户id', '90', '商户id', '3', '0', 'theme');
|
INSERT INTO `sys_gen_columns` VALUES ('799', 'fb_order', 'mcht_id', 'bigint', 'BigDecimal', '商户id', '90', '商户id', '3', '0', 'theme');
|
||||||
INSERT INTO `sys_gen_columns` VALUES ('800', 'fb_order', 'sn', 'char', 'String', 'QR编号', '100', 'QR编号', '1', '0', 'del_flag');
|
INSERT INTO `sys_gen_columns` VALUES ('800', 'fb_order', 'sn', 'char', 'String', 'QR编号', '100', 'QR编号', '1', '0', 'del_flag');
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('801', 'author', 'user_id', 'bigint', 'Long', '用户ID', '2', '用户ID', '1', '0', null);
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('802', 'author', 'invite_code', 'varchar', 'String', '邀请码', '3', '邀请码', '1', '0', null);
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('803', 'author', 'pen_name', 'varchar', 'String', '笔名', '4', '笔名', '1', '0', null);
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('804', 'author', 'tel_phone', 'varchar', 'String', '手机号码', '5', '手机号码', '1', '0', null);
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('805', 'author', 'chat_account', 'varchar', 'String', 'QQ或微信账号', '6', 'QQ或微信账号', '1', '0', null);
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('806', 'author', 'email', 'varchar', 'String', '电子邮箱', '7', '电子邮箱', '1', '0', null);
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('807', 'author', 'work_direction', 'tinyint', 'Integer', '作品方向,0:男频,1:女频', '8', '作品方向,0:男频,1:女频', '2', '0', 'work_direction');
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('808', 'author', 'status', 'tinyint', 'Integer', '0:正常,1:封禁', '10', '0:正常,1:封禁', '1', '0', null);
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('809', 'author', 'create_time', 'datetime', 'Date', '创建时间', '9', '入驻时间', '4', '0', null);
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('810', 'author_code', 'invite_code', 'varchar', 'String', '邀请码', '2', '邀请码', '1', '1', null);
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('811', 'author_code', 'validity_time', 'datetime', 'Date', '有效时间', '3', '有效时间', '4', '1', null);
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('812', 'author_code', 'is_use', 'tinyint', 'Integer', '是否使用过,0:未使用,1:使用过', '4', '是否使用过,0:未使用,1:使用过', '1', '0', null);
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('813', 'author_code', 'create_time', 'datetime', 'Date', '创建时间', '5', '创建时间', '4', '0', null);
|
||||||
|
INSERT INTO `sys_gen_columns` VALUES ('814', 'author_code', 'create_user_id', 'bigint', 'Long', '创建人ID', '6', '创建人ID', '1', '0', null);
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_gen_table
|
-- Table structure for sys_gen_table
|
||||||
@ -807,11 +892,54 @@ CREATE TABLE `sys_log` (
|
|||||||
`ip` varchar(64) DEFAULT NULL COMMENT 'IP地址',
|
`ip` varchar(64) DEFAULT NULL COMMENT 'IP地址',
|
||||||
`gmt_create` datetime DEFAULT NULL COMMENT '创建时间',
|
`gmt_create` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1369 DEFAULT CHARSET=utf8 COMMENT='系统日志';
|
) ENGINE=InnoDB AUTO_INCREMENT=1412 DEFAULT CHARSET=utf8 COMMENT='系统日志';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of sys_log
|
-- Records of sys_log
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
INSERT INTO `sys_log` VALUES ('1369', '-1', '获取用户信息为空', '登录', '462', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 11:09:21');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1370', '-1', '获取用户信息为空', '登录', '19', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 11:09:26');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1371', '1', 'admin', '登录', '98', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 11:09:33');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1372', '1', 'admin', '请求访问主页', '372', 'com.java2nb.system.controller.LoginController.index()', null, '127.0.0.1', '2020-05-13 11:09:33');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1373', '1', 'admin', '请求访问主页', '28', 'com.java2nb.system.controller.LoginController.index()', null, '127.0.0.1', '2020-05-13 11:12:41');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1374', '1', 'admin', '编辑角色', '11', 'com.java2nb.system.controller.RoleController.edit()', null, '127.0.0.1', '2020-05-13 11:18:42');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1375', '1', 'admin', '添加菜单', '2', 'com.java2nb.system.controller.MenuController.add()', null, '127.0.0.1', '2020-05-13 11:19:55');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1376', '1', 'admin', '保存菜单', '225', 'com.java2nb.system.controller.MenuController.save()', null, '127.0.0.1', '2020-05-13 11:24:42');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1377', '1', 'admin', '编辑菜单', '15', 'com.java2nb.system.controller.MenuController.edit()', null, '127.0.0.1', '2020-05-13 11:24:54');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1378', '1', 'admin', '编辑菜单', '11', 'com.java2nb.system.controller.MenuController.edit()', null, '127.0.0.1', '2020-05-13 11:24:58');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1379', '1', 'admin', '更新菜单', '241', 'com.java2nb.system.controller.MenuController.update()', null, '127.0.0.1', '2020-05-13 11:25:12');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1380', '1', 'admin', '编辑菜单', '8', 'com.java2nb.system.controller.MenuController.edit()', null, '127.0.0.1', '2020-05-13 11:25:16');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1381', '1', 'admin', '更新菜单', '199', 'com.java2nb.system.controller.MenuController.update()', null, '127.0.0.1', '2020-05-13 11:25:26');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1382', '1', 'admin', '编辑角色', '13', 'com.java2nb.system.controller.RoleController.edit()', null, '127.0.0.1', '2020-05-13 11:26:11');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1383', '1', 'admin', '更新角色', '931', 'com.java2nb.system.controller.RoleController.update()', null, '127.0.0.1', '2020-05-13 11:26:36');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1384', '-1', '获取用户信息为空', '登录', '11', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 11:27:02');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1385', '1', 'admin', '登录', '19', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 11:27:08');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1386', '1', 'admin', '请求访问主页', '27', 'com.java2nb.system.controller.LoginController.index()', null, '127.0.0.1', '2020-05-13 11:27:08');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1387', '1', 'admin', '登录', '272', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 11:27:56');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1388', '1', 'admin', '请求访问主页', '109', 'com.java2nb.system.controller.LoginController.index()', null, '127.0.0.1', '2020-05-13 11:27:56');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1389', '1', 'admin', '编辑角色', '8', 'com.java2nb.system.controller.RoleController.edit()', null, '127.0.0.1', '2020-05-13 11:30:36');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1390', '1', 'admin', '更新角色', '567', 'com.java2nb.system.controller.RoleController.update()', null, '127.0.0.1', '2020-05-13 11:30:42');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1391', '-1', '获取用户信息为空', '登录', '246', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 11:31:38');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1392', '1', 'admin', '登录', '38', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 11:31:42');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1393', '1', 'admin', '请求访问主页', '110', 'com.java2nb.system.controller.LoginController.index()', null, '127.0.0.1', '2020-05-13 11:31:43');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1394', '1', 'admin', 'error', null, 'http://127.0.0.1/test/order/list', 'org.springframework.jdbc.BadSqlGrammarException: \r\n### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Table \'novel_plus.fb_order\' doesn\'t exist\r\n### The error may exist in file [E:\\baseprojectparent\\novel-plus\\novel-admin\\target\\classes\\mybatis\\test\\OrderMapper.xml]\r\n### The error may involve defaultParameterMap\r\n### The error occurred while setting parameters\r\n### SQL: select `id`,`fb_merchant_code`,`merchant_order_sn`,`order_sn`,`platform_order_no`,`trade_no`,`order_state`,`fn_coupon`,`red_packet`,`total_fee`,`order_price`,`fee`,`body`,`attach`,`store_id`,`cashier_id`,`device_no`,`user_id`,`user_logon_id`,`pay_time`,`pay_channel`,`no_cash_coupon_fee`,`cash_coupon_fee`,`cash_fee`,`sign`,`options`,`create_time`,`push_time`,`push_ip`,`mcht_id`,`sn` from fb_order order by id desc limit ?, ?\r\n### Cause: java.sql.SQLSyntaxErrorException: Table \'novel_plus.fb_order\' doesn\'t exist\n; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Table \'novel_plus.fb_order\' doesn\'t exist', null, '2020-05-13 11:33:27');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1395', '1', 'admin', '登录', '276', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 11:39:20');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1396', '1', 'admin', '请求访问主页', '95', 'com.java2nb.system.controller.LoginController.index()', null, '127.0.0.1', '2020-05-13 11:39:20');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1397', '1', 'admin', '登录', '285', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 11:47:00');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1398', '1', 'admin', '请求访问主页', '90', 'com.java2nb.system.controller.LoginController.index()', null, '127.0.0.1', '2020-05-13 11:47:00');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1399', '1', 'admin', '登录', '251', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 11:48:28');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1400', '1', 'admin', '请求访问主页', '95', 'com.java2nb.system.controller.LoginController.index()', null, '127.0.0.1', '2020-05-13 11:48:28');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1401', '1', 'admin', '登录', '302', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 14:09:33');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1402', '1', 'admin', '请求访问主页', '88', 'com.java2nb.system.controller.LoginController.index()', null, '127.0.0.1', '2020-05-13 14:09:34');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1403', '1', 'admin', '请求更改用户密码', '3', 'com.java2nb.system.controller.UserController.resetPwd()', null, '127.0.0.1', '2020-05-13 14:11:49');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1404', '1', 'admin', 'admin提交更改用户密码', '140', 'com.java2nb.system.controller.UserController.adminResetPwd()', null, '127.0.0.1', '2020-05-13 14:11:50');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1405', '1', 'admin', '请求更改用户密码', '4', 'com.java2nb.system.controller.UserController.resetPwd()', null, '127.0.0.1', '2020-05-13 14:12:11');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1406', '1', 'admin', '登录', '275', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 14:14:26');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1407', '1', 'admin', '请求访问主页', '73', 'com.java2nb.system.controller.LoginController.index()', null, '127.0.0.1', '2020-05-13 14:14:27');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1408', '1', 'admin', 'error', null, 'http://127.0.0.1/novel/author/update', 'org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors\nField error in object \'authorDO\' on field \'id\': rejected value [1,1]; codes [typeMismatch.authorDO.id,typeMismatch.id,typeMismatch.java.lang.Long,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [authorDO.id,id]; arguments []; default message [id]]; default message [Failed to convert property value of type \'java.lang.String\' to required type \'java.lang.Long\' for property \'id\'; nested exception is java.lang.NumberFormatException: For input string: \"1,1\"]', null, '2020-05-13 14:14:38');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1409', '1', 'admin', 'error', null, 'http://127.0.0.1/novel/author/update', 'org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors\nField error in object \'authorDO\' on field \'id\': rejected value [1,1]; codes [typeMismatch.authorDO.id,typeMismatch.id,typeMismatch.java.lang.Long,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [authorDO.id,id]; arguments []; default message [id]]; default message [Failed to convert property value of type \'java.lang.String\' to required type \'java.lang.Long\' for property \'id\'; nested exception is java.lang.NumberFormatException: For input string: \"1,1\"]', null, '2020-05-13 14:14:47');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1410', '1', 'admin', '登录', '261', 'com.java2nb.system.controller.LoginController.ajaxLogin()', null, '127.0.0.1', '2020-05-13 14:18:07');
|
||||||
|
INSERT INTO `sys_log` VALUES ('1411', '1', 'admin', '请求访问主页', '83', 'com.java2nb.system.controller.LoginController.index()', null, '127.0.0.1', '2020-05-13 14:18:07');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_menu
|
-- Table structure for sys_menu
|
||||||
@ -829,7 +957,7 @@ CREATE TABLE `sys_menu` (
|
|||||||
`gmt_create` datetime DEFAULT NULL COMMENT '创建时间',
|
`gmt_create` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
`gmt_modified` datetime DEFAULT NULL COMMENT '修改时间',
|
`gmt_modified` datetime DEFAULT NULL COMMENT '修改时间',
|
||||||
PRIMARY KEY (`menu_id`)
|
PRIMARY KEY (`menu_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=215 DEFAULT CHARSET=utf8 COMMENT='菜单管理';
|
) ENGINE=InnoDB AUTO_INCREMENT=234 DEFAULT CHARSET=utf8 COMMENT='菜单管理';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of sys_menu
|
-- Records of sys_menu
|
||||||
@ -886,6 +1014,19 @@ INSERT INTO `sys_menu` VALUES ('211', '209', '新增', null, 'system:dataPerm:ad
|
|||||||
INSERT INTO `sys_menu` VALUES ('212', '209', '修改', null, 'system:dataPerm:edit', '2', null, '6', null, null);
|
INSERT INTO `sys_menu` VALUES ('212', '209', '修改', null, 'system:dataPerm:edit', '2', null, '6', null, null);
|
||||||
INSERT INTO `sys_menu` VALUES ('213', '209', '删除', null, 'system:dataPerm:remove', '2', null, '6', null, null);
|
INSERT INTO `sys_menu` VALUES ('213', '209', '删除', null, 'system:dataPerm:remove', '2', null, '6', null, null);
|
||||||
INSERT INTO `sys_menu` VALUES ('214', '209', '批量删除', null, 'system:dataPerm:batchRemove', '2', null, '6', null, null);
|
INSERT INTO `sys_menu` VALUES ('214', '209', '批量删除', null, 'system:dataPerm:batchRemove', '2', null, '6', null, null);
|
||||||
|
INSERT INTO `sys_menu` VALUES ('221', '0', '作家管理', '', '', '0', 'fa fa-user-o', '10', null, null);
|
||||||
|
INSERT INTO `sys_menu` VALUES ('222', '221', '作者列表', 'novel/author', 'novel:author:author', '1', 'fa', '6', null, null);
|
||||||
|
INSERT INTO `sys_menu` VALUES ('223', '222', '查看', null, 'novel:author:detail', '2', null, '6', null, null);
|
||||||
|
INSERT INTO `sys_menu` VALUES ('224', '222', '新增', null, 'novel:author:add', '2', null, '6', null, null);
|
||||||
|
INSERT INTO `sys_menu` VALUES ('225', '222', '修改', null, 'novel:author:edit', '2', null, '6', null, null);
|
||||||
|
INSERT INTO `sys_menu` VALUES ('226', '222', '删除', null, 'novel:author:remove', '2', null, '6', null, null);
|
||||||
|
INSERT INTO `sys_menu` VALUES ('227', '222', '批量删除', null, 'novel:author:batchRemove', '2', null, '6', null, null);
|
||||||
|
INSERT INTO `sys_menu` VALUES ('228', '221', '邀请码管理', 'novel/authorCode', 'novel:authorCode:authorCode', '1', 'fa', '3', null, null);
|
||||||
|
INSERT INTO `sys_menu` VALUES ('229', '228', '查看', null, 'novel:authorCode:detail', '2', null, '6', null, null);
|
||||||
|
INSERT INTO `sys_menu` VALUES ('230', '228', '新增', null, 'novel:authorCode:add', '2', null, '6', null, null);
|
||||||
|
INSERT INTO `sys_menu` VALUES ('231', '228', '修改', null, 'novel:authorCode:edit', '2', null, '6', null, null);
|
||||||
|
INSERT INTO `sys_menu` VALUES ('232', '228', '删除', null, 'novel:authorCode:remove', '2', null, '6', null, null);
|
||||||
|
INSERT INTO `sys_menu` VALUES ('233', '228', '批量删除', null, 'novel:authorCode:batchRemove', '2', null, '6', null, null);
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_role
|
-- Table structure for sys_role
|
||||||
@ -919,22 +1060,22 @@ CREATE TABLE `sys_role_data_perm` (
|
|||||||
`role_id` bigint(20) DEFAULT NULL COMMENT '角色ID',
|
`role_id` bigint(20) DEFAULT NULL COMMENT '角色ID',
|
||||||
`perm_id` bigint(20) DEFAULT NULL COMMENT '权限ID',
|
`perm_id` bigint(20) DEFAULT NULL COMMENT '权限ID',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=63 DEFAULT CHARSET=utf8 COMMENT='角色与数据权限对应关系';
|
) ENGINE=InnoDB AUTO_INCREMENT=79 DEFAULT CHARSET=utf8 COMMENT='角色与数据权限对应关系';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of sys_role_data_perm
|
-- Records of sys_role_data_perm
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `sys_role_data_perm` VALUES ('49', '1', '214');
|
|
||||||
INSERT INTO `sys_role_data_perm` VALUES ('50', '1', '213');
|
|
||||||
INSERT INTO `sys_role_data_perm` VALUES ('51', '1', '212');
|
|
||||||
INSERT INTO `sys_role_data_perm` VALUES ('52', '1', '211');
|
|
||||||
INSERT INTO `sys_role_data_perm` VALUES ('53', '1', '210');
|
|
||||||
INSERT INTO `sys_role_data_perm` VALUES ('54', '1', '1199168630769283072');
|
|
||||||
INSERT INTO `sys_role_data_perm` VALUES ('55', '1', '-1');
|
|
||||||
INSERT INTO `sys_role_data_perm` VALUES ('56', '1', '1199168630454710272');
|
|
||||||
INSERT INTO `sys_role_data_perm` VALUES ('60', '60', '211');
|
INSERT INTO `sys_role_data_perm` VALUES ('60', '60', '211');
|
||||||
INSERT INTO `sys_role_data_perm` VALUES ('61', '60', '-1');
|
INSERT INTO `sys_role_data_perm` VALUES ('61', '60', '-1');
|
||||||
INSERT INTO `sys_role_data_perm` VALUES ('62', '60', '1199170283966787584');
|
INSERT INTO `sys_role_data_perm` VALUES ('62', '60', '1199170283966787584');
|
||||||
|
INSERT INTO `sys_role_data_perm` VALUES ('71', '1', '214');
|
||||||
|
INSERT INTO `sys_role_data_perm` VALUES ('72', '1', '213');
|
||||||
|
INSERT INTO `sys_role_data_perm` VALUES ('73', '1', '212');
|
||||||
|
INSERT INTO `sys_role_data_perm` VALUES ('74', '1', '211');
|
||||||
|
INSERT INTO `sys_role_data_perm` VALUES ('75', '1', '210');
|
||||||
|
INSERT INTO `sys_role_data_perm` VALUES ('76', '1', '1260412100929482752');
|
||||||
|
INSERT INTO `sys_role_data_perm` VALUES ('77', '1', '-1');
|
||||||
|
INSERT INTO `sys_role_data_perm` VALUES ('78', '1', '1260412099998347264');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_role_menu
|
-- Table structure for sys_role_menu
|
||||||
@ -945,7 +1086,7 @@ CREATE TABLE `sys_role_menu` (
|
|||||||
`role_id` bigint(20) DEFAULT NULL COMMENT '角色ID',
|
`role_id` bigint(20) DEFAULT NULL COMMENT '角色ID',
|
||||||
`menu_id` bigint(20) DEFAULT NULL COMMENT '菜单ID',
|
`menu_id` bigint(20) DEFAULT NULL COMMENT '菜单ID',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=4704 DEFAULT CHARSET=utf8 COMMENT='角色与菜单对应关系';
|
) ENGINE=InnoDB AUTO_INCREMENT=4830 DEFAULT CHARSET=utf8 COMMENT='角色与菜单对应关系';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of sys_role_menu
|
-- Records of sys_role_menu
|
||||||
@ -1166,59 +1307,6 @@ INSERT INTO `sys_role_menu` VALUES ('3280', '59', '3');
|
|||||||
INSERT INTO `sys_role_menu` VALUES ('3281', '59', '78');
|
INSERT INTO `sys_role_menu` VALUES ('3281', '59', '78');
|
||||||
INSERT INTO `sys_role_menu` VALUES ('3282', '59', '1');
|
INSERT INTO `sys_role_menu` VALUES ('3282', '59', '1');
|
||||||
INSERT INTO `sys_role_menu` VALUES ('3283', '59', '-1');
|
INSERT INTO `sys_role_menu` VALUES ('3283', '59', '-1');
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4505', '1', '208');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4506', '1', '207');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4507', '1', '206');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4508', '1', '205');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4509', '1', '204');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4510', '1', '92');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4511', '1', '57');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4512', '1', '30');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4513', '1', '29');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4514', '1', '28');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4515', '1', '104');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4516', '1', '48');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4517', '1', '214');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4518', '1', '213');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4519', '1', '212');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4520', '1', '211');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4521', '1', '210');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4522', '1', '76');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4523', '1', '75');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4524', '1', '74');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4525', '1', '62');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4526', '1', '56');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4527', '1', '55');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4528', '1', '15');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4529', '1', '26');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4530', '1', '25');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4531', '1', '24');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4532', '1', '14');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4533', '1', '13');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4534', '1', '12');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4535', '1', '61');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4536', '1', '22');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4537', '1', '21');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4538', '1', '20');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4539', '1', '83');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4540', '1', '81');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4541', '1', '80');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4542', '1', '79');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4543', '1', '71');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4544', '1', '203');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4545', '1', '202');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4546', '1', '27');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4547', '1', '91');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4548', '1', '77');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4549', '1', '209');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4550', '1', '73');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4551', '1', '7');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4552', '1', '6');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4553', '1', '2');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4554', '1', '3');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4555', '1', '78');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4556', '1', '1');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4557', '1', '-1');
|
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4611', '61', '208');
|
INSERT INTO `sys_role_menu` VALUES ('4611', '61', '208');
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4612', '61', '207');
|
INSERT INTO `sys_role_menu` VALUES ('4612', '61', '207');
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4613', '61', '206');
|
INSERT INTO `sys_role_menu` VALUES ('4613', '61', '206');
|
||||||
@ -1312,6 +1400,72 @@ INSERT INTO `sys_role_menu` VALUES ('4700', '60', '78');
|
|||||||
INSERT INTO `sys_role_menu` VALUES ('4701', '60', '1');
|
INSERT INTO `sys_role_menu` VALUES ('4701', '60', '1');
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4702', '60', '-1');
|
INSERT INTO `sys_role_menu` VALUES ('4702', '60', '-1');
|
||||||
INSERT INTO `sys_role_menu` VALUES ('4703', '60', '3');
|
INSERT INTO `sys_role_menu` VALUES ('4703', '60', '3');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4764', '1', '227');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4765', '1', '226');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4766', '1', '225');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4767', '1', '224');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4768', '1', '223');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4769', '1', '208');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4770', '1', '207');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4771', '1', '206');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4772', '1', '205');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4773', '1', '204');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4774', '1', '92');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4775', '1', '57');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4776', '1', '30');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4777', '1', '29');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4778', '1', '28');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4779', '1', '104');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4780', '1', '48');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4781', '1', '214');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4782', '1', '213');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4783', '1', '212');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4784', '1', '211');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4785', '1', '210');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4786', '1', '76');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4787', '1', '75');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4788', '1', '74');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4789', '1', '62');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4790', '1', '56');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4791', '1', '55');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4792', '1', '15');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4793', '1', '26');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4794', '1', '25');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4795', '1', '24');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4796', '1', '14');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4797', '1', '13');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4798', '1', '12');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4799', '1', '61');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4800', '1', '22');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4801', '1', '21');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4802', '1', '20');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4803', '1', '83');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4804', '1', '81');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4805', '1', '80');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4806', '1', '79');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4807', '1', '71');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4808', '1', '222');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4809', '1', '203');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4810', '1', '202');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4811', '1', '27');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4812', '1', '91');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4813', '1', '77');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4814', '1', '209');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4815', '1', '73');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4816', '1', '7');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4817', '1', '6');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4818', '1', '2');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4819', '1', '3');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4820', '1', '78');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4821', '1', '1');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4822', '1', '228');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4823', '1', '233');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4824', '1', '232');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4825', '1', '231');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4826', '1', '230');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4827', '1', '229');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4828', '1', '221');
|
||||||
|
INSERT INTO `sys_role_menu` VALUES ('4829', '1', '-1');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_user
|
-- Table structure for sys_user
|
||||||
@ -1355,7 +1509,7 @@ INSERT INTO `sys_user` VALUES ('134', 'lyh', '李彦宏', 'dc26092b3244d9d432863
|
|||||||
INSERT INTO `sys_user` VALUES ('135', 'wjl', '王健林', '3967697dfced162cf6a34080259b83aa', '6', 'wjl@bootod.com', null, '1', null, null, null, null, null, null, null, null, null, null, null);
|
INSERT INTO `sys_user` VALUES ('135', 'wjl', '王健林', '3967697dfced162cf6a34080259b83aa', '6', 'wjl@bootod.com', null, '1', null, null, null, null, null, null, null, null, null, null, null);
|
||||||
INSERT INTO `sys_user` VALUES ('136', 'gdg', '郭德纲', '3bb1bda86bc02bf6478cd91e42135d2f', '9', 'gdg@bootdo.com', null, '1', null, null, null, null, null, null, null, null, null, null, null);
|
INSERT INTO `sys_user` VALUES ('136', 'gdg', '郭德纲', '3bb1bda86bc02bf6478cd91e42135d2f', '9', 'gdg@bootdo.com', null, '1', null, null, null, null, null, null, null, null, null, null, null);
|
||||||
INSERT INTO `sys_user` VALUES ('137', 'test2', 'test2', '649169898e69272c0e5bc899baf1e904', null, '1179705413@qq.com', null, '1', null, null, null, null, null, null, null, null, null, null, null);
|
INSERT INTO `sys_user` VALUES ('137', 'test2', 'test2', '649169898e69272c0e5bc899baf1e904', null, '1179705413@qq.com', null, '1', null, null, null, null, null, null, null, null, null, null, null);
|
||||||
INSERT INTO `sys_user` VALUES ('138', 'test3', 'test3', '4428f69c806f51128f3974f948a2f272', '16', '1179705413@qq.com', null, '1', null, null, null, null, null, null, null, null, null, null, null);
|
INSERT INTO `sys_user` VALUES ('138', 'test3', 'test3', '79ba2d0b58d8a2e94f6b18744c8cd280', '16', '1179705413@qq.com', null, '1', null, null, null, null, null, null, null, null, null, null, null);
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_user_role
|
-- Table structure for sys_user_role
|
||||||
@ -1460,6 +1614,29 @@ INSERT INTO `user_bookshelf` VALUES ('39', '1255060328322027520', '1254681071191
|
|||||||
INSERT INTO `user_bookshelf` VALUES ('40', '1255060328322027520', '1254676970567565312', '3264258', '2020-04-30 09:57:18', '2020-04-30 19:19:11');
|
INSERT INTO `user_bookshelf` VALUES ('40', '1255060328322027520', '1254676970567565312', '3264258', '2020-04-30 09:57:18', '2020-04-30 19:19:11');
|
||||||
INSERT INTO `user_bookshelf` VALUES ('41', '1255060328322027520', '1254675594315759616', '1254675594496114688', '2020-04-30 18:37:18', null);
|
INSERT INTO `user_bookshelf` VALUES ('41', '1255060328322027520', '1254675594315759616', '1254675594496114688', '2020-04-30 18:37:18', null);
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for user_buy_record
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `user_buy_record`;
|
||||||
|
CREATE TABLE `user_buy_record` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||||||
|
`book_id` bigint(20) DEFAULT NULL COMMENT '购买的小说ID',
|
||||||
|
`book_name` varchar(50) DEFAULT NULL COMMENT '购买的小说名',
|
||||||
|
`book_index_id` bigint(20) DEFAULT NULL COMMENT '购买的章节ID',
|
||||||
|
`book_index_name` varchar(100) DEFAULT NULL COMMENT '购买的章节名',
|
||||||
|
`buy_amount` int(11) DEFAULT NULL COMMENT '购买使用的屋币数量',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '购买时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `key_userId_indexId` (`user_id`,`book_index_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='用户消费记录表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of user_buy_record
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `user_buy_record` VALUES ('1', '1255060328322027520', '1260400284744613890', '我是一只消消乐2', '1260522024606953472', '第三章', '10', '2020-05-13 21:29:09');
|
||||||
|
INSERT INTO `user_buy_record` VALUES ('2', '1255060328322027520', '1260400284744613890', '我是一只消消乐2', '1260564410687107072', '第四章', '10', '2020-05-13 21:40:38');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for user_feedback
|
-- Table structure for user_feedback
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
@ -1513,3 +1690,149 @@ INSERT INTO `user_read_history` VALUES ('111', '1255060328322027520', '125495762
|
|||||||
INSERT INTO `user_read_history` VALUES ('113', '1255060328322027520', '1254676970567565312', '3264258', '2020-04-30 19:19:11', '2020-04-30 19:19:11');
|
INSERT INTO `user_read_history` VALUES ('113', '1255060328322027520', '1254676970567565312', '3264258', '2020-04-30 19:19:11', '2020-04-30 19:19:11');
|
||||||
INSERT INTO `user_read_history` VALUES ('117', '1255060328322027520', '1254946661743603712', '1254946914001629184', '2020-04-30 19:37:09', '2020-04-30 19:37:09');
|
INSERT INTO `user_read_history` VALUES ('117', '1255060328322027520', '1254946661743603712', '1254946914001629184', '2020-04-30 19:37:09', '2020-04-30 19:37:09');
|
||||||
INSERT INTO `user_read_history` VALUES ('118', '1255060328322027520', '1254957312633352192', '3335449', '2020-04-30 19:37:36', '2020-04-30 19:37:36');
|
INSERT INTO `user_read_history` VALUES ('118', '1255060328322027520', '1254957312633352192', '3335449', '2020-04-30 19:37:36', '2020-04-30 19:37:36');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `book_content0`;
|
||||||
|
CREATE TABLE `book_content0` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
|
||||||
|
`content` mediumtext COMMENT '小说章节内容',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1155 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for book_content1
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `book_content1`;
|
||||||
|
CREATE TABLE `book_content1` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
|
||||||
|
`content` mediumtext COMMENT '小说章节内容',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=406 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for book_content2
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `book_content2`;
|
||||||
|
CREATE TABLE `book_content2` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
|
||||||
|
`content` mediumtext COMMENT '小说章节内容',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1222 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for book_content3
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `book_content3`;
|
||||||
|
CREATE TABLE `book_content3` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
|
||||||
|
`content` mediumtext COMMENT '小说章节内容',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=410 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for book_content4
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `book_content4`;
|
||||||
|
CREATE TABLE `book_content4` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
|
||||||
|
`content` mediumtext COMMENT '小说章节内容',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1188 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for book_content5
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `book_content5`;
|
||||||
|
CREATE TABLE `book_content5` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
|
||||||
|
`content` mediumtext COMMENT '小说章节内容',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=416 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for book_content6
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `book_content6`;
|
||||||
|
CREATE TABLE `book_content6` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
|
||||||
|
`content` mediumtext COMMENT '小说章节内容',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1180 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for book_content7
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `book_content7`;
|
||||||
|
CREATE TABLE `book_content7` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
|
||||||
|
`content` mediumtext COMMENT '小说章节内容',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=404 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for book_content8
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `book_content8`;
|
||||||
|
CREATE TABLE `book_content8` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
|
||||||
|
`content` mediumtext COMMENT '小说章节内容',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1134 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for book_content9
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `book_content9`;
|
||||||
|
CREATE TABLE `book_content9` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
|
||||||
|
`content` mediumtext COMMENT '小说章节内容',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=415 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `crawl_single_task`;
|
||||||
|
CREATE TABLE `crawl_single_task` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`source_id` int(11) DEFAULT NULL COMMENT '爬虫源ID',
|
||||||
|
`source_name` varchar(50) DEFAULT NULL COMMENT '爬虫源名',
|
||||||
|
`source_book_id` varchar(255) DEFAULT NULL COMMENT '源站小说ID',
|
||||||
|
`cat_id` int(11) DEFAULT NULL COMMENT '分类ID',
|
||||||
|
`book_name` varchar(50) DEFAULT NULL COMMENT '爬取的小说名',
|
||||||
|
`author_name` varchar(50) DEFAULT NULL COMMENT '爬取的小说作者名',
|
||||||
|
`task_status` tinyint(1) DEFAULT '2' COMMENT '任务状态,0:失败,1:成功,2;未执行',
|
||||||
|
`exc_count` tinyint(2) DEFAULT '0' COMMENT '已经执行次数,最多执行5次',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COMMENT='抓取单本小说任务表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of crawl_single_task
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `crawl_single_task` VALUES ('6', '2', '百书斋', '1', '1', '1', '1', '0', '5', '2020-06-15 14:36:07');
|
||||||
|
INSERT INTO `crawl_single_task` VALUES ('7', '5', '笔趣阁', '108_108291', '1', '衍天志之不朽仙', '白衣少年丶', '1', '1', '2020-06-15 14:46:08');
|
||||||
|
UPDATE `crawl_source` SET `source_name` = '书趣阁', `crawl_rule` = '{\n \"bookListUrl\": \"http://m.shuquge.com/sort/{catId}/0_{page}.html\",\n \"catIdRule\": {\n \"catId1\": \"1\",\n \"catId2\": \"2\",\n \"catId3\": \"3\",\n \"catId4\": \"4\",\n \"catId5\": \"7\",\n \"catId6\": \"6\",\n \"catId7\": \"8\"\n },\n \"bookIdPatten\": \"href=\\\"/s/(\\\\d+)\\\\.html\\\"\",\n \"pagePatten\": \"第(\\\\d+)/\\\\d+页\",\n \"totalPagePatten\": \"第\\\\d+/(\\\\d+)页\",\n \"bookDetailUrl\": \"http://m.shuquge.com/s/{bookId}.html\",\n \"bookNamePatten\": \"<a\\\\s+href=\\\"/s/\\\\d+\\\\.html\\\"><h2>([^/]+)</h2></a>\",\n \"authorNamePatten\": \"<p>作者:([^/]+)</p>\",\n \"picUrlPatten\": \"src=\\\"(http://www.shuquge.com/files/article/image/\\\\d+/\\\\d+/\\\\d+s\\\\.jpg)\\\"\",\n \"statusPatten\": \"<p>状态:([^/]+)</p>\",\n \"bookStatusRule\": {\n \"连载中\": 0,\n \"完本\": 1\n },\n \"descStart\": \"<div class=\\\"intro_info\\\">\",\n \"descEnd\": \"最新章节推荐地址\",\n \"bookIndexUrl\": \"http://www.shuquge.com/txt/{bookId}/index.html\",\n \"bookIndexStart\": \"<dt>《\",\n \"indexIdPatten\": \"<dd><a\\\\s+href=\\\"(\\\\d+)\\\\.html\\\">[^/]+</a></dd>\",\n \"indexNamePatten\": \"<dd><a\\\\s+href=\\\"\\\\d+\\\\.html\\\">([^/]+)</a></dd>\",\n \"bookContentUrl\": \"http://www.shuquge.com/txt/{bookId}/{indexId}.html\",\n \"contentStart\": \"<div id=\\\"content\\\" class=\\\"showtxt\\\">\",\n \"contentEnd\": \"http://www.shuquge.com\"\n}', `source_status` = 1, `create_time` = '2020-05-18 12:02:34', `update_time` = '2020-05-18 12:02:34' WHERE `id` = 4;
|
||||||
|
|
||||||
|
INSERT INTO `friend_link` ( `link_name`, `link_url`, `sort`, `is_open`, `create_user_id`, `create_time`, `update_user_id`, `update_time`) VALUES
|
||||||
|
('小羊影视', 'http://video.java2nb.com/', 11, 1, NULL, NULL, NULL, NULL),
|
||||||
|
('官方论坛', 'http://bbs.java2nb.com', 21, 1, NULL, NULL, NULL, NULL);
|
3
sql/sql文件说明.txt
Normal file
3
sql/sql文件说明.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
novel_plus.sqlΪȫ<CEAA><C8AB>sql<71>ļ<EFBFBD><C4BC><EFBFBD>yyyyMMdd.sqlΪ<6C><CEAA><EFBFBD><EFBFBD>sql<71>ļ<EFBFBD><C4BC><EFBFBD>
|
||||||
|
<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ֻ<EFBFBD><EFBFBD>Ҫִ<EFBFBD><EFBFBD>novel_plus.sql<71>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ɡ<EFBFBD>
|
||||||
|
<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴδ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬ִ<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>sql<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
Reference in New Issue
Block a user