mirror of
https://github.com/201206030/novel-plus.git
synced 2026-03-07 16:59:36 +08:00
Compare commits
86 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01639cbd3c | ||
|
|
313e73c63b | ||
|
|
3d1b952e1a | ||
|
|
6b72d4856d | ||
|
|
1aa86bdaec | ||
|
|
bd12d2f2a5 | ||
|
|
938ae8571d | ||
|
|
0279a86e56 | ||
|
|
9ba04ccf6d | ||
|
|
43213adba4 | ||
|
|
f49d0dd1c0 | ||
|
|
803607350e | ||
|
|
8448e86ac5 | ||
|
|
1ad240c7f9 | ||
|
|
0564871093 | ||
|
|
d6faab8ca1 | ||
|
|
1ef64edcda | ||
|
|
c24c68ecaf | ||
|
|
7e27456a65 | ||
|
|
d4e8fb1cc7 | ||
|
|
d4e1126873 | ||
|
|
99f1bc7859 | ||
|
|
84a90bbc34 | ||
|
|
b2d8fd8c66 | ||
|
|
11d9d6f6e8 | ||
|
|
8c7b891af2 | ||
|
|
bb1a87e337 | ||
|
|
1cd8a49fd4 | ||
|
|
21816c6b62 | ||
|
|
773ce159f7 | ||
|
|
91e7d2712b | ||
|
|
3db8828384 | ||
|
|
54bd194b98 | ||
|
|
3d41cf3ebb | ||
|
|
d5d174e8cc | ||
|
|
720711414c | ||
|
|
522bb7c739 | ||
|
|
16cec22666 | ||
|
|
64e1686fd1 | ||
|
|
90009a57f4 | ||
|
|
6452c1603f | ||
|
|
d54eda2366 | ||
|
|
972a49f1ba | ||
|
|
675b156094 | ||
|
|
3c409023e5 | ||
|
|
02fb819120 | ||
|
|
8c572edb10 | ||
|
|
8c9013ad05 | ||
|
|
4693c7ffae | ||
|
|
efb136e3be | ||
|
|
7955db0e3c | ||
|
|
60dc28c5ed | ||
|
|
1534220f0c | ||
|
|
0830f6ffeb | ||
|
|
adc83db64e | ||
|
|
9c11f22816 | ||
|
|
24abe7714f | ||
|
|
a9fc80eba1 | ||
|
|
32541a7cb6 | ||
|
|
42bcecc304 | ||
|
|
a07643bde0 | ||
|
|
1f53b56bd6 | ||
|
|
2c86cb9a7d | ||
|
|
a4d6272a4f | ||
|
|
55d5deea74 | ||
|
|
4f474b91a8 | ||
|
|
ca22eed665 | ||
|
|
df1b72fb58 | ||
|
|
415bf8a64c | ||
|
|
3f009dc1f9 | ||
|
|
0e156c04b4 | ||
|
|
d4fa0abc4e | ||
|
|
eff4fc4c7c | ||
|
|
8c1c0f10be | ||
|
|
02ad0f93dc | ||
|
|
a06132a4c2 | ||
|
|
f043ddff42 | ||
|
|
328bd55587 | ||
|
|
04fc8e878a | ||
|
|
970ad407f1 | ||
|
|
f8079f443a | ||
|
|
75a4c3002b | ||
|
|
99f2a15990 | ||
|
|
3a7972a47c | ||
|
|
156f0378b2 | ||
|
|
c66d56615f |
82
README.md
82
README.md
@@ -1,5 +1,4 @@
|
||||
<p align="center">
|
||||
<a href="https://www.swiftproxy.net/?code=T2WV1VT50"><img src="https://xxyopen.com/images/ad1.png" alt="AD" ></a>
|
||||
<a href="https://cloud.tencent.com/act/cps/redirect?redirect=2446&cps_key=736e609d66e0ac4e57813316cec6fd0b&from=console"><img src="https://youdoc.github.io/img/tencent.jpg" alt="AD" ></a>
|
||||
</p>
|
||||
<p align="center">
|
||||
@@ -10,20 +9,20 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
👉 <a href='https://novel.xxyopen.com'>官网</a> | 👉 <a href='https://www.bilibili.com/video/BV1Zo4y187Mi'>项目演示</a> | 👉 <a href='https://docs.xxyopen.com/course/novelplus/1.html'>安装教程</a>
|
||||
👉 <a href='https://novel.xxyopen.com'>官网</a> | 👉 <a href='http://117.72.165.13:8888'>演示站点</a> | 👉 <a href='https://docs.xxyopen.com/course/novelplus/1.html'>安装教程</a>
|
||||
</p>
|
||||
|
||||
## 项目介绍
|
||||
|
||||
novel-plus 是一个多端(PC、WAP)阅读,功能完善的原创文学 CMS
|
||||
系统。由前台门户系统、作家后台管理系统、平台后台管理系统和爬虫管理系统等多个子系统构成,包括小说推荐、作品检索、小说排行、小说阅读、小说评论、会员中心、作家专区等功能,支持自定义多模版、可拓展的多种小说内容存储方式(内置数据库分表存储和
|
||||
TXT 文本存储)、阅读主题切换、多爬虫源自动采集和更新数据、会员充值、订阅模式、新闻发布和实时统计报表。
|
||||
TXT 文本存储)、阅读主题切换、多爬虫源自动采集和更新数据、AI写作、会员充值、订阅模式、新闻发布和实时统计报表。
|
||||
|
||||
## 项目地址
|
||||
|
||||
- 学习版:[GitHub](https://github.com/201206030/novel) | [码云](https://gitee.com/novel_dev_team/novel)
|
||||
| [保姆级教程](https://docs.xxyopen.com)
|
||||
- **应用版**:[GitHub](https://github.com/201206030/novel-plus) | [码云](https://gitee.com/novel_dev_team/novel-plus)
|
||||
| [保姆级教程](https://docs.xxyopen.com)
|
||||
- **应用版**:[GitHub](https://github.com/201206030/novel-plus) | [码云](https://gitee.com/novel_dev_team/novel-plus) | [演示站点](http://117.72.165.13:8888)
|
||||
- 微服务版:[GitHub](https://github.com/201206030/novel-cloud) | [码云](https://gitee.com/novel_dev_team/novel-cloud)
|
||||
|
||||
## 项目结构
|
||||
@@ -39,25 +38,25 @@ novel-plus -- 父工程
|
||||
|
||||
## 技术选型
|
||||
|
||||
| 技术 | 说明
|
||||
|---------------------| ---------------------------
|
||||
| Spring Boot | Spring 应用快速开发脚手架
|
||||
| Spring AI | Spring 官方 AI 框架
|
||||
| MyBatis | 持久层 ORM 框架
|
||||
| MyBatis Dynamic SQL | Mybatis 动态 sql
|
||||
| PageHelper | MyBatis 分页插件
|
||||
| MyBatis Generator | 持久层代码生成插件
|
||||
| Sharding-JDBC | 代码层分库分表中间件
|
||||
| JJWT | JWT 登录支持
|
||||
| Spring Security | 安全框架
|
||||
| Apache Shiro | 安全框架
|
||||
| Redis | 缓存方案
|
||||
| Aliyun OSS | 阿里云对象存储服务(图片存储备选方案)
|
||||
| Lombok | 简化对象封装工具
|
||||
| Docker | 应用容器引擎
|
||||
| MySQL | 数据库服务
|
||||
| Thymeleaf | 模板引擎
|
||||
| Layui | 前端 UI 框架
|
||||
| 技术 | 说明
|
||||
|---------------------|---------------------
|
||||
| Spring Boot | Spring 应用快速开发脚手架
|
||||
| Spring AI | Spring 官方 AI 框架
|
||||
| MyBatis | 持久层 ORM 框架
|
||||
| MyBatis Dynamic SQL | Mybatis 动态 sql
|
||||
| PageHelper | MyBatis 分页插件
|
||||
| MyBatis Generator | 持久层代码生成插件
|
||||
| Sharding-JDBC | 代码层分库分表中间件
|
||||
| JJWT | JWT 登录支持
|
||||
| Spring Security | 安全框架
|
||||
| Apache Shiro | 安全框架
|
||||
| Redis | 缓存方案
|
||||
| Aliyun OSS | 阿里云对象存储服务(图片存储备选方案)
|
||||
| Lombok | 简化对象封装工具
|
||||
| Docker | 应用容器引擎
|
||||
| MySQL | 数据库服务
|
||||
| Thymeleaf | 模板引擎
|
||||
| Layui | 前端 UI 框架
|
||||
|
||||
## 项目截图
|
||||
|
||||
@@ -71,6 +70,39 @@ novel-plus -- 父工程
|
||||
|
||||
https://www.bilibili.com/video/BV18e41197xs
|
||||
|
||||
## AI 功能
|
||||
|
||||
novel-plus 5.x 已集成 Spring 官方最新发布的 Spring AI 框架,并推出多项 AI 功能:
|
||||
|
||||
1. v5.0.0 版本在小说章节发布页面的文本编辑器中集成了多项智能编辑功能,包括 AI 扩写、缩写、续写及文本润色等。这些功能的设计灵感来源于百家号文章编辑器中的 AI 助手。
|
||||
2. v5.1.0 版本在小说发布页面,新增 AI 生成封面图功能。若作家未上传自定义封面图,系统将根据小说信息自动生成封面图。
|
||||
|
||||
目前,AI 功能仍处于实验阶段,仅实现了基础的核心功能。我们非常重视用户的实际使用体验和反馈,未来将根据用户需求和使用情况,持续优化和调整该功能。如果用户反馈积极,我们计划进一步开发更高级的 AI 功能,例如自动生成有声小说、智能情节推荐等,以全面提升 novel-plus 的创作能力和用户体验。
|
||||
|
||||
我们将持续关注 AI 技术的发展,并致力于将其与小说创作场景深度融合,为用户带来更智能、更便捷的创作工具。
|
||||
|
||||
novel-plus 项目默认使用的是第三方大模型服务平台[硅基流动](https://cloud.siliconflow.cn/i/DOgMRH9S)提供的 API(兼容 OpenAI 的相关接口,可直接通过 Spring AI 框架调用),采用的 AI 模型有对话模型`deepseek-ai/DeepSeek-R1-0528-Qwen3-8B`(DeepSeek-R1 的蒸馏版本,免费使用)和生图模型`Kwai-Kolors/Kolors`(快手 Kolors 团队开发的文本到图像生成模型,免费使用)。只需注册一个硅基流动账号,创建一个 API 密钥,并将其添加到 novel-plus 项目 novel-front 模块的 yaml 配置文件中,即可体验 novel-plus 项目的 AI 写作功能。
|
||||
|
||||
```yaml
|
||||
spring:
|
||||
ai:
|
||||
openai:
|
||||
image:
|
||||
enabled: true
|
||||
base-url: https://api.siliconflow.cn
|
||||
api-key: sk-rrrupturhdofbiqzjutduuiceecpvfqlnvmgcyiaipbdikoi
|
||||
options:
|
||||
model: Kwai-Kolors/Kolors
|
||||
response_format: URL
|
||||
api-key: sk-rrrupturhdofbiqzjutduuiceecpvfqlnvmgcyiaipbdikoi
|
||||
base-url: https://api.siliconflow.cn
|
||||
chat:
|
||||
options:
|
||||
model: deepseek-ai/DeepSeek-R1-0528-Qwen3-8B
|
||||
```
|
||||
|
||||
⚠️ novel-plus 项目默认使用的都是免费 AI 模型,生成效果有限。如果对生成内容有更高的要求,建议选用付费的 AI 模型。
|
||||
|
||||
## 增值服务
|
||||
|
||||
👉 [了解详情](https://novel.xxyopen.com/service.htm)
|
||||
@@ -95,3 +127,5 @@ https://www.bilibili.com/video/BV18e41197xs
|
||||
## 免责声明
|
||||
|
||||
本项目提供的爬虫工具仅用于采集项目初期的测试数据,请勿用于商业盈利。 用户使用本系统从事任何违法违规的事情,一切后果由用户自行承担,作者不承担任何责任。
|
||||
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@ dataSources:
|
||||
ds_1:
|
||||
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
jdbcUrl: jdbc:mysql://localhost:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
jdbcUrl: jdbc:mysql://localhost:3306/novel_plus?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: test123456
|
||||
ds_2:
|
||||
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/information_schema?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://localhost:3306/information_schema?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: test123456
|
||||
# 规则配置
|
||||
|
||||
3
doc/sql/20250630.sql
Normal file
3
doc/sql/20250630.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
alter table book_comment add column location varchar(50) DEFAULT NULL COMMENT '地理位置' after comment_content ;
|
||||
|
||||
|
||||
3
doc/sql/20250711.sql
Normal file
3
doc/sql/20250711.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
alter table crawl_single_task add column crawl_chapters int DEFAULT 0 COMMENT '采集章节数量' after exc_count ;
|
||||
|
||||
|
||||
13
doc/sql/20250712.sql
Normal file
13
doc/sql/20250712.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
DROP TABLE IF EXISTS `book_comment_reply`;
|
||||
CREATE TABLE `book_comment_reply`
|
||||
(
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`comment_id` bigint(20) DEFAULT NULL COMMENT '评论ID',
|
||||
`reply_content` varchar(512) DEFAULT NULL COMMENT '回复内容',
|
||||
`location` varchar(50) DEFAULT NULL COMMENT '地理位置',
|
||||
`audit_status` tinyint(1) DEFAULT '0' COMMENT '审核状态,0:待审核,1:审核通过,2:审核不通过',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '回复用户ID',
|
||||
`create_user_id` bigint(20) DEFAULT NULL COMMENT '回复时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4 COMMENT ='小说评论回复表';
|
||||
@@ -3153,4 +3153,64 @@ where menu_id = 104;
|
||||
|
||||
delete
|
||||
from sys_menu
|
||||
where menu_id = 57;
|
||||
where menu_id = 57;
|
||||
|
||||
|
||||
alter table book_comment add column location varchar(50) DEFAULT NULL COMMENT '地理位置' after comment_content ;
|
||||
|
||||
|
||||
alter table crawl_single_task add column crawl_chapters int DEFAULT 0 COMMENT '采集章节数量' after exc_count ;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `book_comment_reply`;
|
||||
CREATE TABLE `book_comment_reply`
|
||||
(
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`comment_id` bigint(20) DEFAULT NULL COMMENT '评论ID',
|
||||
`reply_content` varchar(512) DEFAULT NULL COMMENT '回复内容',
|
||||
`location` varchar(50) DEFAULT NULL COMMENT '地理位置',
|
||||
`audit_status` tinyint(1) DEFAULT '0' COMMENT '审核状态,0:待审核,1:审核通过,2:审核不通过',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '回复用户ID',
|
||||
`create_user_id` bigint(20) DEFAULT NULL COMMENT '回复时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4 COMMENT ='小说评论回复表';
|
||||
|
||||
|
||||
INSERT INTO crawl_source (source_name, crawl_rule, source_status, create_time
|
||||
, update_time)
|
||||
VALUES ('飘天文学网(海外专用)', '{
|
||||
"bookListUrl": "https://www.piaotia.com/booksort{catId}/{page}.html",
|
||||
"catIdRule": {
|
||||
"catId1": "1/0",
|
||||
"catId2": "2/0",
|
||||
"catId3": "3/0",
|
||||
"catId4": "4/0",
|
||||
"catId5": "6/0",
|
||||
"catId6": "5/0"
|
||||
},
|
||||
"bookIdPatten": "href=\\"https://www.piaotia.com/bookinfo/(\\\\d+/\\\\d+).html\\"",
|
||||
"pagePatten": "<em\\\\s+id=\\"pagestats\\">(\\\\d+)/\\\\d+</em>",
|
||||
"totalPagePatten": "<em\\\\s+id=\\"pagestats\\">\\\\d+/(\\\\d+)</em>",
|
||||
"bookDetailUrl": "https://www.piaotia.com/bookinfo/{bookId}.html",
|
||||
"bookNamePatten": "<h1>([^/]+)</h1>",
|
||||
"authorNamePatten": "<td\\\\s+width=\\"\\\\d+%\\">作 者:([^/]+)<",
|
||||
"picUrlPatten": "<img\\\\s+src=\\"(https://www.piaotia.com/files/article/image/[^\\"]+)\\"",
|
||||
"statusPatten": "<td>文章状态:([^/]+)</td>",
|
||||
"bookStatusRule": {
|
||||
"连载中": 0,
|
||||
"已完成": 1
|
||||
},
|
||||
"descStart": " <span class=\\"hottext\\">内容简介:</span><br />",
|
||||
"descEnd": "</td>",
|
||||
"filterDesc": "",
|
||||
"bookIndexUrl": "https://www.piaotia.com/html/{bookId}/index.html",
|
||||
"indexIdPatten": "<li><a href=\\"(\\\\d+).html\\">[^/]+</a></li>",
|
||||
"indexNamePatten": "<li><a href=\\"\\\\d+.html\\">([^/]+)</a></li>",
|
||||
"bookContentUrl": "https://www.piaotia.com/html/{bookId}/{indexId}.html",
|
||||
"contentStart": "<br>",
|
||||
"contentEnd": "</div>",
|
||||
"filterContent": "",
|
||||
"charset": "gbk"
|
||||
}', 0, '2025-07-13 18:57:39'
|
||||
, '2025-07-13 18:57:39');
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.java2nb</groupId>
|
||||
<artifactId>novel-admin</artifactId>
|
||||
<version>5.0.1</version>
|
||||
<version>5.3.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>novel-admin</name>
|
||||
|
||||
4
novel-admin/src/main/build/scripts/novel-admin.bat
Normal file
4
novel-admin/src/main/build/scripts/novel-admin.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
cd /d "%~dp0.."
|
||||
java -jar -Dspring.profiles.active=prod novel-admin.jar
|
||||
pause
|
||||
@@ -5,9 +5,12 @@ JAR_NAME=$APP_NAME\.jar
|
||||
PID=$APP_NAME\.pid
|
||||
|
||||
|
||||
#使用说明,用来提示输入参数
|
||||
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
|
||||
cd "$SCRIPT_DIR"/.. || exit 1
|
||||
|
||||
# 使用说明
|
||||
usage() {
|
||||
echo "Usage: ./novel-admin.sh [start|stop|restart|status]"
|
||||
echo "Usage: $0 [start|stop|restart|status]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.java2nb.common.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 标记某个方法参数需要进行 Map 字段的清理和标准化处理。
|
||||
*
|
||||
* <p>通常用于 DAO 接口中 list 方法的 Map 参数,用于防止非法排序字段或排序顺序。</p>
|
||||
*/
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface SanitizeMap {
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.java2nb.common.aspect;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
import com.java2nb.common.utils.SortWhitelistUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 拦截所有 Mapper 接口的 list* 方法,对带有 @SanitizeMap 注解的 Map 参数进行排序字段和顺序的规范化处理。
|
||||
*
|
||||
* <p>主要防止 SQL 注入或非法排序字段、非法排序顺序的问题。
|
||||
* 例如对 sort 和 order 字段进行白名单过滤和标准化处理。</p>
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class MapSortValidationAspect {
|
||||
|
||||
/**
|
||||
* 拦截所有 Mapper 接口的 list* 方法(如 list(), listByPage 等)。
|
||||
* 对带有 @SanitizeMap 注解的 Map 参数进行处理。
|
||||
*
|
||||
* <p>执行逻辑:</p>
|
||||
* <ol>
|
||||
* <li>获取方法参数及注解信息</li>
|
||||
* <li>遍历所有参数,检查是否带有 @SanitizeMap 注解</li>
|
||||
* <li>如果参数是 Map 类型且有注解,则进行字段清理</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param joinPoint 切点信息
|
||||
* @return 方法执行结果
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Around("execution(* com.java2nb.*.dao.*Dao.list*(..))")
|
||||
public Object sanitizeMapParameters(ProceedingJoinPoint joinPoint) {
|
||||
Object[] args = joinPoint.getArgs();
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
|
||||
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
|
||||
|
||||
for (int i = 0; i < parameterAnnotations.length; i++) {
|
||||
boolean hasAnnotation = Arrays.stream(parameterAnnotations[i])
|
||||
.anyMatch(a -> a.annotationType().equals(SanitizeMap.class));
|
||||
|
||||
if (hasAnnotation && args[i] instanceof Map map) {
|
||||
if (map.get("sort") instanceof String sortStr) {
|
||||
map.put("sort", SortWhitelistUtil.sanitizeColumn(sortStr));
|
||||
}
|
||||
if (map.get("order") instanceof String orderStr) {
|
||||
map.put("order", SortWhitelistUtil.sanitizeOrder(orderStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return joinPoint.proceed(args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ public interface CacheKey {
|
||||
/**
|
||||
* 首页小说设置
|
||||
*/
|
||||
String INDEX_BOOK_SETTINGS_KEY = "indexBookSettingsKey";
|
||||
String INDEX_BOOK_SETTINGS_KEY = "indexBookSettingsKey:v2";
|
||||
|
||||
/**
|
||||
* 首页新闻
|
||||
|
||||
@@ -15,7 +15,7 @@ public class Constant {
|
||||
//通知公告阅读状态-已读
|
||||
public static int OA_NOTIFY_READ_YES = 1;
|
||||
//部门根节点id
|
||||
public static Long DEPT_ROOT_ID = 0l;
|
||||
public static Long DEPT_ROOT_ID = 0L;
|
||||
//缓存方式
|
||||
public static String CACHE_TYPE_REDIS = "redis";
|
||||
|
||||
@@ -23,5 +23,6 @@ public class Constant {
|
||||
|
||||
public static final String UPLOAD_FILES_PREFIX = "/files/";
|
||||
|
||||
public static final String BOOK_IS_DOWNLOADING_KEY = "bookIsDownloading:";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.java2nb.common.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
import com.java2nb.common.domain.DictDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -19,7 +20,7 @@ public interface DictDao {
|
||||
|
||||
DictDO get(Long id);
|
||||
|
||||
List<DictDO> list(Map<String, Object> map);
|
||||
List<DictDO> list(@SanitizeMap Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.java2nb.common.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
import com.java2nb.common.domain.FileDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +19,7 @@ public interface FileDao {
|
||||
|
||||
FileDO get(Long id);
|
||||
|
||||
List<FileDO> list(Map<String,Object> map);
|
||||
List<FileDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.java2nb.common.dao;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
import com.java2nb.common.domain.GenColumnsDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@@ -19,7 +20,7 @@ public interface GenColumnsDao {
|
||||
|
||||
GenColumnsDO get(Long id);
|
||||
|
||||
List<GenColumnsDO> list(Map<String,Object> map);
|
||||
List<GenColumnsDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.java2nb.common.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
import com.java2nb.common.domain.LogDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +19,7 @@ public interface LogDao {
|
||||
|
||||
LogDO get(Long id);
|
||||
|
||||
List<LogDO> list(Map<String,Object> map);
|
||||
List<LogDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.java2nb.common.utils;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 排序字段和排序顺序的白名单工具类。
|
||||
*/
|
||||
@UtilityClass
|
||||
public class SortWhitelistUtil {
|
||||
|
||||
// 白名单字段
|
||||
private static final Set<String> ALLOWED_COLUMNS = Set.of("id", "name", "order_num","index_num");
|
||||
|
||||
// 白名单排序方式
|
||||
private static final Set<String> ALLOWED_ORDERS = Set.of("asc", "desc");
|
||||
|
||||
/**
|
||||
* 对排序字段进行白名单过滤和标准化。
|
||||
*
|
||||
* @param column 原始字段名
|
||||
* @return 安全的字段名,若非法则返回 null
|
||||
*/
|
||||
public static String sanitizeColumn(String column) {
|
||||
if (column == null) return null;
|
||||
String lower = column.trim().toLowerCase();
|
||||
return ALLOWED_COLUMNS.contains(lower) ? lower : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对排序方式进行白名单过滤和标准化。
|
||||
*
|
||||
* @param order 原始排序方式
|
||||
* @return 安全的排序方式("asc" 或 "desc"),若非法则返回 null
|
||||
*/
|
||||
public static String sanitizeOrder(String order) {
|
||||
if (order == null) return null;
|
||||
String lower = order.trim().toLowerCase();
|
||||
return ALLOWED_ORDERS.contains(lower) ? lower : null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,24 @@
|
||||
package com.java2nb.novel.controller;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.java2nb.common.config.Constant;
|
||||
import com.java2nb.novel.domain.BookContentDO;
|
||||
import com.java2nb.novel.domain.BookIndexDO;
|
||||
import com.java2nb.novel.service.BookContentService;
|
||||
import com.java2nb.novel.service.BookIndexService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -22,6 +36,9 @@ import com.java2nb.common.utils.PageBean;
|
||||
import com.java2nb.common.utils.Query;
|
||||
import com.java2nb.common.utils.R;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* 小说表
|
||||
*
|
||||
@@ -30,12 +47,34 @@ import com.java2nb.common.utils.R;
|
||||
* @date 2020-12-01 03:49:46
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequestMapping("/novel/book")
|
||||
public class BookController {
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private BookIndexService bookIndexService;
|
||||
|
||||
@Autowired
|
||||
private BookContentService bookContentService;
|
||||
|
||||
|
||||
private final Pattern PATTERN_BR = Pattern.compile("<br\\s*/?>", Pattern.CASE_INSENSITIVE);
|
||||
private final Pattern PATTERN_NBSP = Pattern.compile(" ", Pattern.CASE_INSENSITIVE);
|
||||
private final Pattern PATTERN_ANCHOR_OPEN = Pattern.compile("<a[^>]*>", Pattern.CASE_INSENSITIVE);
|
||||
private final Pattern PATTERN_ANCHOR_CLOSE = Pattern.compile("</a>", Pattern.CASE_INSENSITIVE);
|
||||
private final Pattern PATTERN_DIV_OPEN = Pattern.compile("<div[^>]*>", Pattern.CASE_INSENSITIVE);
|
||||
private final Pattern PATTERN_DIV_CLOSE = Pattern.compile("</div>", Pattern.CASE_INSENSITIVE);
|
||||
private final Pattern PATTERN_EMPTY_PARAGRAPH_WITH_LINK = Pattern.compile("<p[^>]*>[^<]*<a[^>]*>[^<]*</a>\\s*</p>", Pattern.CASE_INSENSITIVE);
|
||||
private final Pattern PATTERN_P_OPEN = Pattern.compile("<p[^>]*>", Pattern.CASE_INSENSITIVE);
|
||||
private final Pattern PATTERN_P_CLOSE = Pattern.compile("</p>", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
@GetMapping()
|
||||
@RequiresPermissions("novel:book:book")
|
||||
String Book() {
|
||||
@@ -66,7 +105,7 @@ public class BookController {
|
||||
@GetMapping("/edit/{id}")
|
||||
@RequiresPermissions("novel:book:edit")
|
||||
String edit(@PathVariable("id") Long id, Model model) {
|
||||
BookDO book = bookService.get(id);
|
||||
BookDO book = bookService.get(id);
|
||||
model.addAttribute("book", book);
|
||||
return "novel/book/edit";
|
||||
}
|
||||
@@ -75,7 +114,7 @@ public class BookController {
|
||||
@GetMapping("/detail/{id}")
|
||||
@RequiresPermissions("novel:book:detail")
|
||||
String detail(@PathVariable("id") Long id, Model model) {
|
||||
BookDO book = bookService.get(id);
|
||||
BookDO book = bookService.get(id);
|
||||
model.addAttribute("book", book);
|
||||
return "novel/book/detail";
|
||||
}
|
||||
@@ -87,7 +126,7 @@ public class BookController {
|
||||
@ResponseBody
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("novel:book:add")
|
||||
public R save( BookDO book) {
|
||||
public R save(BookDO book) {
|
||||
if (bookService.save(book) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
@@ -101,8 +140,8 @@ public class BookController {
|
||||
@ResponseBody
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("novel:book:edit")
|
||||
public R update( BookDO book) {
|
||||
bookService.update(book);
|
||||
public R update(BookDO book) {
|
||||
bookService.update(book);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -113,7 +152,7 @@ public class BookController {
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
@RequiresPermissions("novel:book:remove")
|
||||
public R remove( Long id) {
|
||||
public R remove(Long id) {
|
||||
if (bookService.remove(id) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
@@ -128,8 +167,83 @@ public class BookController {
|
||||
@ResponseBody
|
||||
@RequiresPermissions("novel:book:batchRemove")
|
||||
public R remove(@RequestParam("ids[]") Long[] ids) {
|
||||
bookService.batchRemove(ids);
|
||||
bookService.batchRemove(ids);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 小说下载
|
||||
*/
|
||||
@RequestMapping(value = "/download")
|
||||
public void download(@RequestParam("bookId") Long bookId, @RequestParam("bookName") String bookName,
|
||||
HttpServletResponse resp) {
|
||||
try {
|
||||
OutputStream out = resp.getOutputStream();
|
||||
Boolean success = redisTemplate
|
||||
.opsForValue()
|
||||
.setIfAbsent(Constant.BOOK_IS_DOWNLOADING_KEY + bookId, "1", 10, TimeUnit.MINUTES);
|
||||
if (Boolean.FALSE.equals(success)) {
|
||||
resp.setContentType("text/html;charset=UTF-8");
|
||||
out.write("该小说正在下载中,请稍后重试!".getBytes(StandardCharsets.UTF_8));
|
||||
out.close();
|
||||
return;
|
||||
}
|
||||
//设置响应头,对文件进行url编码
|
||||
bookName = URLEncoder.encode(bookName, StandardCharsets.UTF_8);
|
||||
//解决手机端不能下载附件的问题
|
||||
resp.setContentType("application/octet-stream");
|
||||
resp.setHeader("Content-Disposition", "attachment;filename=" + bookName + ".txt");
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("bookId", bookId);
|
||||
params.put("sort", "index_num");
|
||||
params.put("order", "asc");
|
||||
params.put("limit", 9999);
|
||||
params.put("offset", 0);
|
||||
List<BookIndexDO> bookIndexBigList = bookIndexService.list(params);
|
||||
if (!bookIndexBigList.isEmpty()) {
|
||||
List<List<BookIndexDO>> bookIndexSmallList = bookIndexBigList.stream().collect(
|
||||
Collectors.groupingBy(item -> bookIndexBigList.indexOf(item) / 100)).values().stream().toList();
|
||||
for (List<BookIndexDO> bookIndexList : bookIndexSmallList) {
|
||||
// 获取集合中所有的ID
|
||||
List<Long> bookIndexIds = bookIndexList.stream().map(BookIndexDO::getId).toList();
|
||||
List<BookContentDO> bookContentList = bookContentService.listByIndexIds(bookIndexIds);
|
||||
Map<Long, String> bookContentMap = bookContentList.stream()
|
||||
.collect(Collectors.toMap(BookContentDO::getIndexId, BookContentDO::getContent));
|
||||
for (BookIndexDO bookIndex : bookIndexList) {
|
||||
String indexName = bookIndex.getIndexName();
|
||||
if (indexName != null) {
|
||||
String content = bookContentMap.get(bookIndex.getId());
|
||||
out.write(indexName.getBytes(StandardCharsets.UTF_8));
|
||||
out.write("\r\n".getBytes(StandardCharsets.UTF_8));
|
||||
content = PATTERN_BR.matcher(content).replaceAll("\r\n");
|
||||
content = PATTERN_NBSP.matcher(content).replaceAll(" ");
|
||||
content = PATTERN_ANCHOR_OPEN.matcher(content).replaceAll("");
|
||||
content = PATTERN_ANCHOR_CLOSE.matcher(content).replaceAll("");
|
||||
content = PATTERN_DIV_OPEN.matcher(content).replaceAll("");
|
||||
content = PATTERN_DIV_CLOSE.matcher(content).replaceAll("");
|
||||
content = PATTERN_EMPTY_PARAGRAPH_WITH_LINK.matcher(content).replaceAll("");
|
||||
content = PATTERN_P_OPEN.matcher(content).replaceAll("");
|
||||
content = PATTERN_P_CLOSE.matcher(content).replaceAll("\r\n");
|
||||
out.write(content.getBytes(StandardCharsets.UTF_8));
|
||||
out.write("\r\n".getBytes(StandardCharsets.UTF_8));
|
||||
out.write("\r\n".getBytes(StandardCharsets.UTF_8));
|
||||
out.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
out.close();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} finally {
|
||||
redisTemplate.delete(Constant.BOOK_IS_DOWNLOADING_KEY + bookId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.java2nb.novel.service.FriendLinkService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -31,7 +31,7 @@ public class FriendLinkController {
|
||||
@Autowired
|
||||
private FriendLinkService friendLinkService;
|
||||
@Autowired
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@GetMapping()
|
||||
@RequiresPermissions("novel:friendLink:friendLink")
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.java2nb.novel.service.NewsService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -32,7 +32,7 @@ public class NewsController {
|
||||
@Autowired
|
||||
private NewsService newsService;
|
||||
@Autowired
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@GetMapping()
|
||||
@RequiresPermissions("novel:news:news")
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.novel.domain.AuthorCodeDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +20,7 @@ public interface AuthorCodeDao {
|
||||
|
||||
AuthorCodeDO get(Long id);
|
||||
|
||||
List<AuthorCodeDO> list(Map<String,Object> map);
|
||||
List<AuthorCodeDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
import com.java2nb.novel.domain.AuthorDO;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -19,7 +20,7 @@ public interface AuthorDao {
|
||||
|
||||
AuthorDO get(Long id);
|
||||
|
||||
List<AuthorDO> list(Map<String,Object> map);
|
||||
List<AuthorDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.novel.domain.BookCommentDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +20,7 @@ public interface BookCommentDao {
|
||||
|
||||
BookCommentDO get(Long id);
|
||||
|
||||
List<BookCommentDO> list(Map<String,Object> map);
|
||||
List<BookCommentDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.novel.domain.BookContentDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -18,7 +21,7 @@ public interface BookContentDao {
|
||||
|
||||
BookContentDO get(Long id);
|
||||
|
||||
List<BookContentDO> list(Map<String, Object> map);
|
||||
List<BookContentDO> list(@SanitizeMap Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
@@ -31,4 +34,6 @@ public interface BookContentDao {
|
||||
int batchRemove(Long[] ids);
|
||||
|
||||
int removeByIndexIds(Long[] indexIds);
|
||||
|
||||
List<BookContentDO> listByIndexIds(@Param("indexIds") List<Long> indexIds);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.novel.domain.BookDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@@ -19,7 +21,7 @@ public interface BookDao {
|
||||
|
||||
BookDO get(Long id);
|
||||
|
||||
List<BookDO> list(Map<String, Object> map);
|
||||
List<BookDO> list(@SanitizeMap Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.novel.domain.BookIndexDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@@ -18,7 +20,7 @@ public interface BookIndexDao {
|
||||
|
||||
BookIndexDO get(Long id);
|
||||
|
||||
List<BookIndexDO> list(Map<String, Object> map);
|
||||
List<BookIndexDO> list(@SanitizeMap Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.novel.domain.BookSettingDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +20,7 @@ public interface BookSettingDao {
|
||||
|
||||
BookSettingDO get(Long id);
|
||||
|
||||
List<BookSettingDO> list(Map<String,Object> map);
|
||||
List<BookSettingDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.novel.domain.CategoryDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +20,7 @@ public interface CategoryDao {
|
||||
|
||||
CategoryDO get(Integer id);
|
||||
|
||||
List<CategoryDO> list(Map<String,Object> map);
|
||||
List<CategoryDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.novel.domain.FriendLinkDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +20,7 @@ public interface FriendLinkDao {
|
||||
|
||||
FriendLinkDO get(Integer id);
|
||||
|
||||
List<FriendLinkDO> list(Map<String,Object> map);
|
||||
List<FriendLinkDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.novel.domain.NewsDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +20,7 @@ public interface NewsDao {
|
||||
|
||||
NewsDO get(Long id);
|
||||
|
||||
List<NewsDO> list(Map<String,Object> map);
|
||||
List<NewsDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.novel.domain.PayDO;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -19,7 +21,7 @@ public interface PayDao {
|
||||
|
||||
PayDO get(Long id);
|
||||
|
||||
List<PayDO> list(Map<String,Object> map);
|
||||
List<PayDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.novel.domain.UserDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@@ -17,7 +19,7 @@ public interface UserDao {
|
||||
|
||||
UserDO get(Long id);
|
||||
|
||||
List<UserDO> list(Map<String, Object> map);
|
||||
List<UserDO> list(@SanitizeMap Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.novel.domain.UserFeedbackDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +20,7 @@ public interface UserFeedbackDao {
|
||||
|
||||
UserFeedbackDO get(Long id);
|
||||
|
||||
List<UserFeedbackDO> list(Map<String,Object> map);
|
||||
List<UserFeedbackDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.novel.domain.WebsiteInfoDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +20,7 @@ public interface WebsiteInfoDao {
|
||||
|
||||
WebsiteInfoDO get(Long id);
|
||||
|
||||
List<WebsiteInfoDO> list(Map<String,Object> map);
|
||||
List<WebsiteInfoDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -27,4 +27,6 @@ public interface BookContentService {
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
|
||||
List<BookContentDO> listByIndexIds(List<Long> indexIds);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.java2nb.novel.service.impl;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -51,5 +52,10 @@ public class BookContentServiceImpl implements BookContentService {
|
||||
public int batchRemove(Long[] ids){
|
||||
return bookContentDao.batchRemove(ids);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<BookContentDO> listByIndexIds(List<Long> indexIds) {
|
||||
return bookContentDao.listByIndexIds(indexIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.system.domain.DataPermDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -19,7 +21,7 @@ public interface DataPermDao {
|
||||
|
||||
DataPermDO get(Long id);
|
||||
|
||||
List<DataPermDO> list(Map<String,Object> map);
|
||||
List<DataPermDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.system.domain.DeptDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -19,7 +21,7 @@ public interface DeptDao {
|
||||
|
||||
DeptDO get(Long deptId);
|
||||
|
||||
List<DeptDO> list(Map<String,Object> map);
|
||||
List<DeptDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.system.domain.MenuDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +20,7 @@ public interface MenuDao {
|
||||
|
||||
MenuDO get(Long menuId);
|
||||
|
||||
List<MenuDO> list(Map<String,Object> map);
|
||||
List<MenuDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.system.domain.RoleDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +20,7 @@ public interface RoleDao {
|
||||
|
||||
RoleDO get(Long roleId);
|
||||
|
||||
List<RoleDO> list(Map<String,Object> map);
|
||||
List<RoleDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.system.domain.RoleDataPermDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +20,7 @@ public interface RoleDataPermDao {
|
||||
|
||||
RoleDataPermDO get(Long id);
|
||||
|
||||
List<RoleDataPermDO> list(Map<String,Object> map);
|
||||
List<RoleDataPermDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.system.domain.RoleMenuDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +20,7 @@ public interface RoleMenuDao {
|
||||
|
||||
RoleMenuDO get(Long id);
|
||||
|
||||
List<RoleMenuDO> list(Map<String,Object> map);
|
||||
List<RoleMenuDO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.system.domain.UserDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-10-03 09:45:11
|
||||
@@ -17,23 +17,23 @@ import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface SysUserDao {
|
||||
|
||||
UserDO get(Long userId);
|
||||
|
||||
List<UserDO> list(Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
int save(UserDO user);
|
||||
|
||||
int update(UserDO user);
|
||||
|
||||
int remove(Long userId);
|
||||
|
||||
int batchRemove(Long[] userIds);
|
||||
|
||||
Long[] listAllDept();
|
||||
UserDO get(Long userId);
|
||||
|
||||
List<UserDO> listByPerm(Map<String, Object> map);
|
||||
List<UserDO> list(@SanitizeMap Map<String, Object> map);
|
||||
|
||||
int countByPerm(Map<String,Object> map);
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
int save(UserDO user);
|
||||
|
||||
int update(UserDO user);
|
||||
|
||||
int remove(Long userId);
|
||||
|
||||
int batchRemove(Long[] userIds);
|
||||
|
||||
Long[] listAllDept();
|
||||
|
||||
List<UserDO> listByPerm(@SanitizeMap Map<String, Object> map);
|
||||
|
||||
int countByPerm(Map<String, Object> map);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.common.annotation.SanitizeMap;
|
||||
|
||||
import com.java2nb.system.domain.UserRoleDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -19,7 +21,7 @@ public interface UserRoleDao {
|
||||
|
||||
UserRoleDO get(Long id);
|
||||
|
||||
List<UserRoleDO> list(Map<String, Object> map);
|
||||
List<UserRoleDO> list(@SanitizeMap Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
|
||||
@@ -38,6 +38,17 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="listByIndexIds" resultType="com.java2nb.novel.domain.BookContentDO">
|
||||
select `id`,`index_id`,`content` from book_content
|
||||
where index_id in (
|
||||
<foreach item="item" index="index" collection="indexIds" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
<insert id="save" parameterType="com.java2nb.novel.domain.BookContentDO">
|
||||
insert into book_content
|
||||
(`id`,
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(*) from book_setting t1 inner join book t2 on t1.book_id = t2.id
|
||||
select count(*) from book_setting t1
|
||||
<where>
|
||||
<if test="id != null and id != ''">and t1.id = #{id}</if>
|
||||
<if test="bookId != null and bookId != ''">and t1.book_id = #{bookId}</if>
|
||||
|
||||
@@ -143,10 +143,14 @@ function load() {
|
||||
field: 'id',
|
||||
align: 'center',
|
||||
formatter: function (value, row, index) {
|
||||
// 增加下载按钮
|
||||
var d = '<a class="btn btn-primary btn-sm" href="#" mce_href="#" title="下载TXT" onclick="downloadBook(\''
|
||||
+ row.id
|
||||
+ '\',\'' + row.bookName + '\')"><i class="fa fa-cloud-download"></i></a><br><br> ';
|
||||
var r = '<a class="btn btn-warning btn-sm ' + s_remove_h + '" href="#" title="删除" mce_href="#" onclick="remove(\''
|
||||
+ row.id
|
||||
+ '\')"><i class="fa fa-remove"></i></a> ';
|
||||
return r;
|
||||
return d + r;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,4 +253,9 @@ function batchRemove() {
|
||||
}, function () {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function downloadBook(bookId, bookName) {
|
||||
window.open(prefix + '/download?bookId='+bookId+'&bookName='+bookName);
|
||||
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public interface ${className}Dao {
|
||||
|
||||
${className}DO get(${pk.javaType} ${pk.attrname});
|
||||
|
||||
List<${className}DO> list(Map<String,Object> map);
|
||||
List<${className}DO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface ${className}Mapper {
|
||||
"limit #{offset}, #{limit}" +
|
||||
"</if>"+
|
||||
"</script>")
|
||||
List<${className}DO> list(Map<String,Object> map);
|
||||
List<${className}DO> list(@SanitizeMap Map<String,Object> map);
|
||||
|
||||
@Select("<script>" +
|
||||
"select count(*) from ${tableName} " +
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>后台管理-登陆</title>
|
||||
<title>后台管理-登录</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta http-equiv="Access-Control-Allow-Origin" content="*">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>novel</artifactId>
|
||||
<groupId>com.java2nb</groupId>
|
||||
<version>5.0.1</version>
|
||||
<version>5.3.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Aop 相关 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.java2nb.novel.core.advice;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 在对 RestController 返回对象 json 序列化时,将所有 Long 类型转为 String 类型返回,避免前端数据精度丢失的问题
|
||||
* 取代 spring.jackson.generator.write-numbers-as-strings=true 配置,避免影响全局的 ObjectMapper
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* */
|
||||
@RestControllerAdvice
|
||||
public class CustomResponseBodyAdvice implements ResponseBodyAdvice<Object> {
|
||||
|
||||
private final ObjectMapper customObjectMapper;
|
||||
|
||||
public CustomResponseBodyAdvice(Jackson2ObjectMapperBuilder builder) {
|
||||
customObjectMapper = builder.createXmlMapper(false).build();
|
||||
SimpleModule simpleModule = new SimpleModule();
|
||||
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
||||
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
|
||||
customObjectMapper.registerModule(simpleModule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
// 返回 true 表示对所有 Controller 的响应都生效
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
||||
// 使用自定义的 ObjectMapper 序列化响应体
|
||||
if(Objects.nonNull(body)) {
|
||||
return customObjectMapper.valueToTree(body);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public interface CacheKey {
|
||||
/**
|
||||
* 首页小说设置
|
||||
* */
|
||||
String INDEX_BOOK_SETTINGS_KEY = "indexBookSettingsKey";
|
||||
String INDEX_BOOK_SETTINGS_KEY = "indexBookSettingsKey:v2";
|
||||
|
||||
/**
|
||||
* 首页新闻
|
||||
@@ -41,11 +41,6 @@ public interface CacheKey {
|
||||
* */
|
||||
String TEMPLATE_DIR_KEY = "templateDirKey";;
|
||||
|
||||
/**
|
||||
* 正在运行的爬虫线程存储KEY前缀
|
||||
* */
|
||||
String RUNNING_CRAWL_THREAD_KEY_PREFIX = "runningCrawlTreadDataKeyPrefix";
|
||||
|
||||
/**
|
||||
* 上一次搜索引擎更新的时间
|
||||
* */
|
||||
@@ -69,4 +64,8 @@ public interface CacheKey {
|
||||
* 测试爬虫规则缓存
|
||||
*/
|
||||
String BOOK_TEST_PARSE = "testParse";
|
||||
/**
|
||||
* AI生成图片
|
||||
* */
|
||||
String AI_GEN_PIC = "aiGenPic";
|
||||
}
|
||||
|
||||
@@ -1,55 +1,61 @@
|
||||
package com.java2nb.novel.core.cache;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 11797
|
||||
*/
|
||||
public interface CacheService {
|
||||
|
||||
/**
|
||||
* 根据key获取缓存的String类型数据
|
||||
*/
|
||||
String get(String key);
|
||||
/**
|
||||
* 根据key获取缓存的String类型数据
|
||||
*/
|
||||
String get(String key);
|
||||
|
||||
/**
|
||||
* 设置String类型的缓存
|
||||
*/
|
||||
void set(String key, String value);
|
||||
/**
|
||||
* 设置String类型的缓存
|
||||
*/
|
||||
void set(String key, String value);
|
||||
|
||||
/**
|
||||
* 设置一个有过期时间的String类型的缓存,单位秒
|
||||
*/
|
||||
void set(String key, String value, long timeout);
|
||||
|
||||
/**
|
||||
* 根据key获取缓存的Object类型数据
|
||||
*/
|
||||
Object getObject(String key);
|
||||
|
||||
/**
|
||||
* 设置Object类型的缓存
|
||||
*/
|
||||
void setObject(String key, Object value);
|
||||
|
||||
/**
|
||||
* 设置一个有过期时间的Object类型的缓存,单位秒
|
||||
*/
|
||||
/**
|
||||
* 设置一个有过期时间的String类型的缓存,单位秒
|
||||
*/
|
||||
void set(String key, String value, long timeout);
|
||||
|
||||
/**
|
||||
* 根据key获取缓存的Object类型数据
|
||||
*/
|
||||
<T> T getObject(String key, Class<T> clazz);
|
||||
|
||||
<T> List<T> getList(String key, Class<T> clazz);
|
||||
|
||||
/**
|
||||
* 设置Object类型的缓存
|
||||
*/
|
||||
void setObject(String key, Object value);
|
||||
|
||||
/**
|
||||
* 设置一个有过期时间的Object类型的缓存,单位秒
|
||||
*/
|
||||
void setObject(String key, Object value, long timeout);
|
||||
|
||||
/**
|
||||
* 根据key删除缓存的数据
|
||||
*/
|
||||
void del(String key);
|
||||
/**
|
||||
* 根据key删除缓存的数据
|
||||
*/
|
||||
void del(String key);
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否存在一个key
|
||||
* */
|
||||
boolean contains(String key);
|
||||
|
||||
/**
|
||||
* 设置key过期时间
|
||||
* */
|
||||
void expire(String key, long timeout);
|
||||
|
||||
/**
|
||||
* 判断是否存在一个key
|
||||
*/
|
||||
boolean contains(String key);
|
||||
|
||||
/**
|
||||
* 设置key过期时间
|
||||
*/
|
||||
void expire(String key, long timeout);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,23 +1,35 @@
|
||||
package com.java2nb.novel.core.cache.impl;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author xxy
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class RedisServiceImpl implements CacheService {
|
||||
|
||||
private final StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
private final RedisTemplate<Object, Object> redisTemplate;
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -37,34 +49,66 @@ public class RedisServiceImpl implements CacheService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject(String key) {
|
||||
return redisTemplate.opsForValue().get(key);
|
||||
public <T> T getObject(String key, Class<T> clazz) {
|
||||
String result = get(key);
|
||||
if (result != null) {
|
||||
try {
|
||||
return objectMapper.readValue(result, clazz);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> getList(String key, Class<T> clazz) {
|
||||
String result = get(key);
|
||||
if (result != null) {
|
||||
try {
|
||||
return objectMapper.readValue(result,
|
||||
objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject(String key, Object value) {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
if (value != null) {
|
||||
try {
|
||||
set(key, objectMapper.writeValueAsString(value));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject(String key, Object value, long timeout) {
|
||||
redisTemplate.opsForValue().set(key, value, timeout, TimeUnit.SECONDS);
|
||||
if (value != null) {
|
||||
try {
|
||||
set(key, objectMapper.writeValueAsString(value), timeout);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
return stringRedisTemplate.hasKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expire(String key, long timeout) {
|
||||
redisTemplate.expire(key, timeout, TimeUnit.SECONDS);
|
||||
stringRedisTemplate.expire(key, timeout, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public enum ResponseStatus implements IResultCode {
|
||||
/**
|
||||
* 用户相关错误
|
||||
* */
|
||||
NO_LOGIN(1001, "未登录或登陆失效!"),
|
||||
NO_LOGIN(1001, "未登录或登录失效!"),
|
||||
VEL_CODE_ERROR(1002, "验证码错误!"),
|
||||
USERNAME_EXIST(1003,"该手机号已注册!"),
|
||||
USERNAME_PASS_ERROR(1004,"手机号或密码错误!"),
|
||||
|
||||
@@ -106,6 +106,47 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将日期格式化成"多久之前"的格式
|
||||
* */
|
||||
public static String formatTimeAgo(Date date){
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
long now = new Date().getTime();
|
||||
long then = date.getTime();
|
||||
|
||||
long diff = now - then;
|
||||
|
||||
if (diff < 0) {
|
||||
// 未来时间
|
||||
DateUtil.formatDate(date, DateUtil.DATE_TIME_PATTERN);
|
||||
}
|
||||
|
||||
long seconds = diff / 1000;
|
||||
long minutes = seconds / 60;
|
||||
long hours = minutes / 60;
|
||||
long days = hours / 24;
|
||||
long months = days / 30;
|
||||
long years = months / 12;
|
||||
|
||||
if (seconds < 60) {
|
||||
return "刚刚";
|
||||
} else if (minutes < 60) {
|
||||
return minutes + "分钟前";
|
||||
} else if (hours < 24) {
|
||||
return hours + "小时前";
|
||||
} else if (days < 30) {
|
||||
return days + "天前";
|
||||
} else if (months < 12) {
|
||||
return months + "个月前";
|
||||
} else {
|
||||
return years + "年前";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(formatDate(getYesterday(),DATE_TIME_PATTERN));
|
||||
System.out.println(formatDate(getDateStartTime(getYesterday()),DATE_TIME_PATTERN));
|
||||
|
||||
@@ -18,6 +18,11 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -125,5 +130,23 @@ public class FileUtil {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*
|
||||
* @param downloadUrl 下载的URL
|
||||
* @param savePath 保存的路径
|
||||
*/
|
||||
@SneakyThrows
|
||||
public void downloadFile(String downloadUrl, String savePath) {
|
||||
Path path = Paths.get(savePath);
|
||||
Path parentPath = path.getParent();
|
||||
if (Files.notExists(parentPath)) {
|
||||
Files.createDirectories(parentPath);
|
||||
}
|
||||
URL url = new URL(downloadUrl);
|
||||
try (InputStream in = url.openStream()) {
|
||||
Files.copy(in, path, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import org.springframework.http.*;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
@@ -16,7 +16,7 @@ public class HttpUtil {
|
||||
|
||||
private static final String DEFAULT_CHARSET = "utf-8";
|
||||
|
||||
private static final Map<String, RestTemplate> REST_TEMPLATE_MAP = new HashMap<>();
|
||||
private static final Map<String, RestTemplate> REST_TEMPLATE_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
public static String getByHttpClientWithChrome(String url, String charset) {
|
||||
log.debug("Get url:{}", url);
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
package com.java2nb.novel.core.utils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.time.Duration;
|
||||
|
||||
@Slf4j
|
||||
public class IpUtil {
|
||||
|
||||
/**
|
||||
* 获取真实IP
|
||||
*
|
||||
* @param request 请求体
|
||||
* @return 真实IP
|
||||
*/
|
||||
@@ -31,4 +41,27 @@ public class IpUtil {
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本机公网IP
|
||||
*/
|
||||
public static String getPublicIP() {
|
||||
try {
|
||||
HttpClient client = HttpClient.newHttpClient();
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://httpbin.org/ip"))
|
||||
.GET()
|
||||
.timeout(Duration.ofSeconds(5))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
if (response.statusCode() == 200) {
|
||||
return new ObjectMapper().readTree(response.body()).get("origin").asText();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取本机公网IP异常", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ public class RestTemplates {
|
||||
connectionManager.setDefaultMaxPerRoute(300);
|
||||
|
||||
HttpClientBuilder clientBuilder = HttpClients.custom();
|
||||
// 禁用 Cookie 管理
|
||||
clientBuilder.disableCookieManagement();
|
||||
if (Objects.nonNull(httpProxyProperties) && Boolean.TRUE.equals(httpProxyProperties.getEnabled())) {
|
||||
HttpHost proxy = new HttpHost(httpProxyProperties.getIp(), httpProxyProperties.getPort());
|
||||
clientBuilder.setProxy(proxy);
|
||||
|
||||
@@ -14,6 +14,9 @@ public class BookComment {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private String commentContent;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private String location;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Integer replyCount;
|
||||
|
||||
@@ -56,6 +59,16 @@ public class BookComment {
|
||||
this.commentContent = commentContent == null ? null : commentContent.trim();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setLocation(String location) {
|
||||
this.location = location == null ? null : location.trim();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Integer getReplyCount() {
|
||||
return replyCount;
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.java2nb.novel.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
public class BookCommentReply {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Long id;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Long commentId;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private String replyContent;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private String location;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Byte auditStatus;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Date createTime;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Long createUserId;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Long getCommentId() {
|
||||
return commentId;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setCommentId(Long commentId) {
|
||||
this.commentId = commentId;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public String getReplyContent() {
|
||||
return replyContent;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setReplyContent(String replyContent) {
|
||||
this.replyContent = replyContent == null ? null : replyContent.trim();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setLocation(String location) {
|
||||
this.location = location == null ? null : location.trim();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Byte getAuditStatus() {
|
||||
return auditStatus;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setAuditStatus(Byte auditStatus) {
|
||||
this.auditStatus = auditStatus;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,9 @@ public class CrawlSingleTask {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Byte excCount;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Integer crawlChapters;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Date createTime;
|
||||
|
||||
@@ -124,6 +127,16 @@ public class CrawlSingleTask {
|
||||
this.excCount = excCount;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Integer getCrawlChapters() {
|
||||
return crawlChapters;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setCrawlChapters(Integer crawlChapters) {
|
||||
this.crawlChapters = crawlChapters;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
|
||||
@@ -19,6 +19,9 @@ public final class BookCommentDynamicSqlSupport {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<String> commentContent = bookComment.commentContent;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<String> location = bookComment.location;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Integer> replyCount = bookComment.replyCount;
|
||||
|
||||
@@ -39,6 +42,8 @@ public final class BookCommentDynamicSqlSupport {
|
||||
|
||||
public final SqlColumn<String> commentContent = column("comment_content", JDBCType.VARCHAR);
|
||||
|
||||
public final SqlColumn<String> location = column("location", JDBCType.VARCHAR);
|
||||
|
||||
public final SqlColumn<Integer> replyCount = column("reply_count", JDBCType.INTEGER);
|
||||
|
||||
public final SqlColumn<Byte> auditStatus = column("audit_status", JDBCType.TINYINT);
|
||||
|
||||
@@ -29,7 +29,7 @@ import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;
|
||||
@Mapper
|
||||
public interface BookCommentMapper {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
BasicColumn[] selectList = BasicColumn.columnList(id, bookId, commentContent, replyCount, auditStatus, createTime, createUserId);
|
||||
BasicColumn[] selectList = BasicColumn.columnList(id, bookId, commentContent, location, replyCount, auditStatus, createTime, createUserId);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
@@ -58,6 +58,7 @@ public interface BookCommentMapper {
|
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
||||
@Result(column="book_id", property="bookId", jdbcType=JdbcType.BIGINT),
|
||||
@Result(column="comment_content", property="commentContent", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="location", property="location", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="reply_count", property="replyCount", jdbcType=JdbcType.INTEGER),
|
||||
@Result(column="audit_status", property="auditStatus", jdbcType=JdbcType.TINYINT),
|
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
|
||||
@@ -92,6 +93,7 @@ public interface BookCommentMapper {
|
||||
c.map(id).toProperty("id")
|
||||
.map(bookId).toProperty("bookId")
|
||||
.map(commentContent).toProperty("commentContent")
|
||||
.map(location).toProperty("location")
|
||||
.map(replyCount).toProperty("replyCount")
|
||||
.map(auditStatus).toProperty("auditStatus")
|
||||
.map(createTime).toProperty("createTime")
|
||||
@@ -105,6 +107,7 @@ public interface BookCommentMapper {
|
||||
c.map(id).toProperty("id")
|
||||
.map(bookId).toProperty("bookId")
|
||||
.map(commentContent).toProperty("commentContent")
|
||||
.map(location).toProperty("location")
|
||||
.map(replyCount).toProperty("replyCount")
|
||||
.map(auditStatus).toProperty("auditStatus")
|
||||
.map(createTime).toProperty("createTime")
|
||||
@@ -118,6 +121,7 @@ public interface BookCommentMapper {
|
||||
c.map(id).toPropertyWhenPresent("id", record::getId)
|
||||
.map(bookId).toPropertyWhenPresent("bookId", record::getBookId)
|
||||
.map(commentContent).toPropertyWhenPresent("commentContent", record::getCommentContent)
|
||||
.map(location).toPropertyWhenPresent("location", record::getLocation)
|
||||
.map(replyCount).toPropertyWhenPresent("replyCount", record::getReplyCount)
|
||||
.map(auditStatus).toPropertyWhenPresent("auditStatus", record::getAuditStatus)
|
||||
.map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
|
||||
@@ -157,6 +161,7 @@ public interface BookCommentMapper {
|
||||
return dsl.set(id).equalTo(record::getId)
|
||||
.set(bookId).equalTo(record::getBookId)
|
||||
.set(commentContent).equalTo(record::getCommentContent)
|
||||
.set(location).equalTo(record::getLocation)
|
||||
.set(replyCount).equalTo(record::getReplyCount)
|
||||
.set(auditStatus).equalTo(record::getAuditStatus)
|
||||
.set(createTime).equalTo(record::getCreateTime)
|
||||
@@ -168,6 +173,7 @@ public interface BookCommentMapper {
|
||||
return dsl.set(id).equalToWhenPresent(record::getId)
|
||||
.set(bookId).equalToWhenPresent(record::getBookId)
|
||||
.set(commentContent).equalToWhenPresent(record::getCommentContent)
|
||||
.set(location).equalToWhenPresent(record::getLocation)
|
||||
.set(replyCount).equalToWhenPresent(record::getReplyCount)
|
||||
.set(auditStatus).equalToWhenPresent(record::getAuditStatus)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||
@@ -179,6 +185,7 @@ public interface BookCommentMapper {
|
||||
return update(c ->
|
||||
c.set(bookId).equalTo(record::getBookId)
|
||||
.set(commentContent).equalTo(record::getCommentContent)
|
||||
.set(location).equalTo(record::getLocation)
|
||||
.set(replyCount).equalTo(record::getReplyCount)
|
||||
.set(auditStatus).equalTo(record::getAuditStatus)
|
||||
.set(createTime).equalTo(record::getCreateTime)
|
||||
@@ -192,6 +199,7 @@ public interface BookCommentMapper {
|
||||
return update(c ->
|
||||
c.set(bookId).equalToWhenPresent(record::getBookId)
|
||||
.set(commentContent).equalToWhenPresent(record::getCommentContent)
|
||||
.set(location).equalToWhenPresent(record::getLocation)
|
||||
.set(replyCount).equalToWhenPresent(record::getReplyCount)
|
||||
.set(auditStatus).equalToWhenPresent(record::getAuditStatus)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.java2nb.novel.mapper;
|
||||
|
||||
import java.sql.JDBCType;
|
||||
import java.util.Date;
|
||||
import javax.annotation.Generated;
|
||||
import org.mybatis.dynamic.sql.SqlColumn;
|
||||
import org.mybatis.dynamic.sql.SqlTable;
|
||||
|
||||
public final class BookCommentReplyDynamicSqlSupport {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final BookCommentReply bookCommentReply = new BookCommentReply();
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Long> id = bookCommentReply.id;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Long> commentId = bookCommentReply.commentId;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<String> replyContent = bookCommentReply.replyContent;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<String> location = bookCommentReply.location;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Byte> auditStatus = bookCommentReply.auditStatus;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Date> createTime = bookCommentReply.createTime;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Long> createUserId = bookCommentReply.createUserId;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final class BookCommentReply extends SqlTable {
|
||||
public final SqlColumn<Long> id = column("id", JDBCType.BIGINT);
|
||||
|
||||
public final SqlColumn<Long> commentId = column("comment_id", JDBCType.BIGINT);
|
||||
|
||||
public final SqlColumn<String> replyContent = column("reply_content", JDBCType.VARCHAR);
|
||||
|
||||
public final SqlColumn<String> location = column("location", JDBCType.VARCHAR);
|
||||
|
||||
public final SqlColumn<Byte> auditStatus = column("audit_status", JDBCType.TINYINT);
|
||||
|
||||
public final SqlColumn<Date> createTime = column("create_time", JDBCType.TIMESTAMP);
|
||||
|
||||
public final SqlColumn<Long> createUserId = column("create_user_id", JDBCType.BIGINT);
|
||||
|
||||
public BookCommentReply() {
|
||||
super("book_comment_reply");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
package com.java2nb.novel.mapper;
|
||||
|
||||
import static com.java2nb.novel.mapper.BookCommentReplyDynamicSqlSupport.*;
|
||||
import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
||||
|
||||
import com.java2nb.novel.entity.BookCommentReply;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Generated;
|
||||
import org.apache.ibatis.annotations.DeleteProvider;
|
||||
import org.apache.ibatis.annotations.InsertProvider;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Result;
|
||||
import org.apache.ibatis.annotations.ResultMap;
|
||||
import org.apache.ibatis.annotations.Results;
|
||||
import org.apache.ibatis.annotations.SelectProvider;
|
||||
import org.apache.ibatis.annotations.UpdateProvider;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.mybatis.dynamic.sql.BasicColumn;
|
||||
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
|
||||
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
|
||||
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
|
||||
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
|
||||
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
|
||||
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
|
||||
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
|
||||
import org.mybatis.dynamic.sql.update.UpdateDSL;
|
||||
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
|
||||
import org.mybatis.dynamic.sql.update.UpdateModel;
|
||||
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
|
||||
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
|
||||
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;
|
||||
|
||||
@Mapper
|
||||
public interface BookCommentReplyMapper {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
BasicColumn[] selectList = BasicColumn.columnList(id, commentId, replyContent, location, auditStatus, createTime, createUserId);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
long count(SelectStatementProvider selectStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@DeleteProvider(type=SqlProviderAdapter.class, method="delete")
|
||||
int delete(DeleteStatementProvider deleteStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@InsertProvider(type=SqlProviderAdapter.class, method="insert")
|
||||
int insert(InsertStatementProvider<BookCommentReply> insertStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
|
||||
int insertMultiple(MultiRowInsertStatementProvider<BookCommentReply> multipleInsertStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
@ResultMap("BookCommentReplyResult")
|
||||
Optional<BookCommentReply> selectOne(SelectStatementProvider selectStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
@Results(id="BookCommentReplyResult", value = {
|
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
||||
@Result(column="comment_id", property="commentId", jdbcType=JdbcType.BIGINT),
|
||||
@Result(column="reply_content", property="replyContent", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="location", property="location", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="audit_status", property="auditStatus", jdbcType=JdbcType.TINYINT),
|
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
|
||||
@Result(column="create_user_id", property="createUserId", jdbcType=JdbcType.BIGINT)
|
||||
})
|
||||
List<BookCommentReply> selectMany(SelectStatementProvider selectStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@UpdateProvider(type=SqlProviderAdapter.class, method="update")
|
||||
int update(UpdateStatementProvider updateStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default long count(CountDSLCompleter completer) {
|
||||
return MyBatis3Utils.countFrom(this::count, bookCommentReply, completer);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int delete(DeleteDSLCompleter completer) {
|
||||
return MyBatis3Utils.deleteFrom(this::delete, bookCommentReply, completer);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int deleteByPrimaryKey(Long id_) {
|
||||
return delete(c ->
|
||||
c.where(id, isEqualTo(id_))
|
||||
);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int insert(BookCommentReply record) {
|
||||
return MyBatis3Utils.insert(this::insert, record, bookCommentReply, c ->
|
||||
c.map(id).toProperty("id")
|
||||
.map(commentId).toProperty("commentId")
|
||||
.map(replyContent).toProperty("replyContent")
|
||||
.map(location).toProperty("location")
|
||||
.map(auditStatus).toProperty("auditStatus")
|
||||
.map(createTime).toProperty("createTime")
|
||||
.map(createUserId).toProperty("createUserId")
|
||||
);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int insertMultiple(Collection<BookCommentReply> records) {
|
||||
return MyBatis3Utils.insertMultiple(this::insertMultiple, records, bookCommentReply, c ->
|
||||
c.map(id).toProperty("id")
|
||||
.map(commentId).toProperty("commentId")
|
||||
.map(replyContent).toProperty("replyContent")
|
||||
.map(location).toProperty("location")
|
||||
.map(auditStatus).toProperty("auditStatus")
|
||||
.map(createTime).toProperty("createTime")
|
||||
.map(createUserId).toProperty("createUserId")
|
||||
);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int insertSelective(BookCommentReply record) {
|
||||
return MyBatis3Utils.insert(this::insert, record, bookCommentReply, c ->
|
||||
c.map(id).toPropertyWhenPresent("id", record::getId)
|
||||
.map(commentId).toPropertyWhenPresent("commentId", record::getCommentId)
|
||||
.map(replyContent).toPropertyWhenPresent("replyContent", record::getReplyContent)
|
||||
.map(location).toPropertyWhenPresent("location", record::getLocation)
|
||||
.map(auditStatus).toPropertyWhenPresent("auditStatus", record::getAuditStatus)
|
||||
.map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
|
||||
.map(createUserId).toPropertyWhenPresent("createUserId", record::getCreateUserId)
|
||||
);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default Optional<BookCommentReply> selectOne(SelectDSLCompleter completer) {
|
||||
return MyBatis3Utils.selectOne(this::selectOne, selectList, bookCommentReply, completer);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default List<BookCommentReply> select(SelectDSLCompleter completer) {
|
||||
return MyBatis3Utils.selectList(this::selectMany, selectList, bookCommentReply, completer);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default List<BookCommentReply> selectDistinct(SelectDSLCompleter completer) {
|
||||
return MyBatis3Utils.selectDistinct(this::selectMany, selectList, bookCommentReply, completer);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default Optional<BookCommentReply> selectByPrimaryKey(Long id_) {
|
||||
return selectOne(c ->
|
||||
c.where(id, isEqualTo(id_))
|
||||
);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int update(UpdateDSLCompleter completer) {
|
||||
return MyBatis3Utils.update(this::update, bookCommentReply, completer);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
static UpdateDSL<UpdateModel> updateAllColumns(BookCommentReply record, UpdateDSL<UpdateModel> dsl) {
|
||||
return dsl.set(id).equalTo(record::getId)
|
||||
.set(commentId).equalTo(record::getCommentId)
|
||||
.set(replyContent).equalTo(record::getReplyContent)
|
||||
.set(location).equalTo(record::getLocation)
|
||||
.set(auditStatus).equalTo(record::getAuditStatus)
|
||||
.set(createTime).equalTo(record::getCreateTime)
|
||||
.set(createUserId).equalTo(record::getCreateUserId);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
static UpdateDSL<UpdateModel> updateSelectiveColumns(BookCommentReply record, UpdateDSL<UpdateModel> dsl) {
|
||||
return dsl.set(id).equalToWhenPresent(record::getId)
|
||||
.set(commentId).equalToWhenPresent(record::getCommentId)
|
||||
.set(replyContent).equalToWhenPresent(record::getReplyContent)
|
||||
.set(location).equalToWhenPresent(record::getLocation)
|
||||
.set(auditStatus).equalToWhenPresent(record::getAuditStatus)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||
.set(createUserId).equalToWhenPresent(record::getCreateUserId);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int updateByPrimaryKey(BookCommentReply record) {
|
||||
return update(c ->
|
||||
c.set(commentId).equalTo(record::getCommentId)
|
||||
.set(replyContent).equalTo(record::getReplyContent)
|
||||
.set(location).equalTo(record::getLocation)
|
||||
.set(auditStatus).equalTo(record::getAuditStatus)
|
||||
.set(createTime).equalTo(record::getCreateTime)
|
||||
.set(createUserId).equalTo(record::getCreateUserId)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int updateByPrimaryKeySelective(BookCommentReply record) {
|
||||
return update(c ->
|
||||
c.set(commentId).equalToWhenPresent(record::getCommentId)
|
||||
.set(replyContent).equalToWhenPresent(record::getReplyContent)
|
||||
.set(location).equalToWhenPresent(record::getLocation)
|
||||
.set(auditStatus).equalToWhenPresent(record::getAuditStatus)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||
.set(createUserId).equalToWhenPresent(record::getCreateUserId)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,9 @@ public final class CrawlSingleTaskDynamicSqlSupport {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Byte> excCount = crawlSingleTask.excCount;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Integer> crawlChapters = crawlSingleTask.crawlChapters;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Date> createTime = crawlSingleTask.createTime;
|
||||
|
||||
@@ -60,6 +63,8 @@ public final class CrawlSingleTaskDynamicSqlSupport {
|
||||
|
||||
public final SqlColumn<Byte> excCount = column("exc_count", JDBCType.TINYINT);
|
||||
|
||||
public final SqlColumn<Integer> crawlChapters = column("crawl_chapters", JDBCType.INTEGER);
|
||||
|
||||
public final SqlColumn<Date> createTime = column("create_time", JDBCType.TIMESTAMP);
|
||||
|
||||
public CrawlSingleTask() {
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;
|
||||
@Mapper
|
||||
public interface CrawlSingleTaskMapper {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
BasicColumn[] selectList = BasicColumn.columnList(id, sourceId, sourceName, sourceBookId, catId, bookName, authorName, taskStatus, excCount, createTime);
|
||||
BasicColumn[] selectList = BasicColumn.columnList(id, sourceId, sourceName, sourceBookId, catId, bookName, authorName, taskStatus, excCount, crawlChapters, createTime);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
@@ -70,6 +70,7 @@ public interface CrawlSingleTaskMapper {
|
||||
@Result(column="author_name", property="authorName", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="task_status", property="taskStatus", jdbcType=JdbcType.TINYINT),
|
||||
@Result(column="exc_count", property="excCount", jdbcType=JdbcType.TINYINT),
|
||||
@Result(column="crawl_chapters", property="crawlChapters", jdbcType=JdbcType.INTEGER),
|
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
|
||||
})
|
||||
List<CrawlSingleTask> selectMany(SelectStatementProvider selectStatement);
|
||||
@@ -90,7 +91,7 @@ public interface CrawlSingleTaskMapper {
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int deleteByPrimaryKey(Long id_) {
|
||||
return delete(c ->
|
||||
return delete(c ->
|
||||
c.where(id, isEqualTo(id_))
|
||||
);
|
||||
}
|
||||
@@ -99,15 +100,16 @@ public interface CrawlSingleTaskMapper {
|
||||
default int insert(CrawlSingleTask record) {
|
||||
return MyBatis3Utils.insert(this::insert, record, crawlSingleTask, c ->
|
||||
c.map(id).toProperty("id")
|
||||
.map(sourceId).toProperty("sourceId")
|
||||
.map(sourceName).toProperty("sourceName")
|
||||
.map(sourceBookId).toProperty("sourceBookId")
|
||||
.map(catId).toProperty("catId")
|
||||
.map(bookName).toProperty("bookName")
|
||||
.map(authorName).toProperty("authorName")
|
||||
.map(taskStatus).toProperty("taskStatus")
|
||||
.map(excCount).toProperty("excCount")
|
||||
.map(createTime).toProperty("createTime")
|
||||
.map(sourceId).toProperty("sourceId")
|
||||
.map(sourceName).toProperty("sourceName")
|
||||
.map(sourceBookId).toProperty("sourceBookId")
|
||||
.map(catId).toProperty("catId")
|
||||
.map(bookName).toProperty("bookName")
|
||||
.map(authorName).toProperty("authorName")
|
||||
.map(taskStatus).toProperty("taskStatus")
|
||||
.map(excCount).toProperty("excCount")
|
||||
.map(crawlChapters).toProperty("crawlChapters")
|
||||
.map(createTime).toProperty("createTime")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -115,15 +117,16 @@ public interface CrawlSingleTaskMapper {
|
||||
default int insertMultiple(Collection<CrawlSingleTask> records) {
|
||||
return MyBatis3Utils.insertMultiple(this::insertMultiple, records, crawlSingleTask, c ->
|
||||
c.map(id).toProperty("id")
|
||||
.map(sourceId).toProperty("sourceId")
|
||||
.map(sourceName).toProperty("sourceName")
|
||||
.map(sourceBookId).toProperty("sourceBookId")
|
||||
.map(catId).toProperty("catId")
|
||||
.map(bookName).toProperty("bookName")
|
||||
.map(authorName).toProperty("authorName")
|
||||
.map(taskStatus).toProperty("taskStatus")
|
||||
.map(excCount).toProperty("excCount")
|
||||
.map(createTime).toProperty("createTime")
|
||||
.map(sourceId).toProperty("sourceId")
|
||||
.map(sourceName).toProperty("sourceName")
|
||||
.map(sourceBookId).toProperty("sourceBookId")
|
||||
.map(catId).toProperty("catId")
|
||||
.map(bookName).toProperty("bookName")
|
||||
.map(authorName).toProperty("authorName")
|
||||
.map(taskStatus).toProperty("taskStatus")
|
||||
.map(excCount).toProperty("excCount")
|
||||
.map(crawlChapters).toProperty("crawlChapters")
|
||||
.map(createTime).toProperty("createTime")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -131,15 +134,16 @@ public interface CrawlSingleTaskMapper {
|
||||
default int insertSelective(CrawlSingleTask record) {
|
||||
return MyBatis3Utils.insert(this::insert, record, crawlSingleTask, c ->
|
||||
c.map(id).toPropertyWhenPresent("id", record::getId)
|
||||
.map(sourceId).toPropertyWhenPresent("sourceId", record::getSourceId)
|
||||
.map(sourceName).toPropertyWhenPresent("sourceName", record::getSourceName)
|
||||
.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(excCount).toPropertyWhenPresent("excCount", record::getExcCount)
|
||||
.map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
|
||||
.map(sourceId).toPropertyWhenPresent("sourceId", record::getSourceId)
|
||||
.map(sourceName).toPropertyWhenPresent("sourceName", record::getSourceName)
|
||||
.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(excCount).toPropertyWhenPresent("excCount", record::getExcCount)
|
||||
.map(crawlChapters).toPropertyWhenPresent("crawlChapters", record::getCrawlChapters)
|
||||
.map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -173,35 +177,7 @@ public interface CrawlSingleTaskMapper {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
static UpdateDSL<UpdateModel> updateAllColumns(CrawlSingleTask record, UpdateDSL<UpdateModel> dsl) {
|
||||
return dsl.set(id).equalTo(record::getId)
|
||||
.set(sourceId).equalTo(record::getSourceId)
|
||||
.set(sourceName).equalTo(record::getSourceName)
|
||||
.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(excCount).equalTo(record::getExcCount)
|
||||
.set(createTime).equalTo(record::getCreateTime);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
static UpdateDSL<UpdateModel> updateSelectiveColumns(CrawlSingleTask record, UpdateDSL<UpdateModel> dsl) {
|
||||
return dsl.set(id).equalToWhenPresent(record::getId)
|
||||
.set(sourceId).equalToWhenPresent(record::getSourceId)
|
||||
.set(sourceName).equalToWhenPresent(record::getSourceName)
|
||||
.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(excCount).equalToWhenPresent(record::getExcCount)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int updateByPrimaryKey(CrawlSingleTask record) {
|
||||
return update(c ->
|
||||
c.set(sourceId).equalTo(record::getSourceId)
|
||||
.set(sourceId).equalTo(record::getSourceId)
|
||||
.set(sourceName).equalTo(record::getSourceName)
|
||||
.set(sourceBookId).equalTo(record::getSourceBookId)
|
||||
.set(catId).equalTo(record::getCatId)
|
||||
@@ -209,15 +185,14 @@ public interface CrawlSingleTaskMapper {
|
||||
.set(authorName).equalTo(record::getAuthorName)
|
||||
.set(taskStatus).equalTo(record::getTaskStatus)
|
||||
.set(excCount).equalTo(record::getExcCount)
|
||||
.set(createTime).equalTo(record::getCreateTime)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
);
|
||||
.set(crawlChapters).equalTo(record::getCrawlChapters)
|
||||
.set(createTime).equalTo(record::getCreateTime);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int updateByPrimaryKeySelective(CrawlSingleTask record) {
|
||||
return update(c ->
|
||||
c.set(sourceId).equalToWhenPresent(record::getSourceId)
|
||||
static UpdateDSL<UpdateModel> updateSelectiveColumns(CrawlSingleTask record, UpdateDSL<UpdateModel> dsl) {
|
||||
return dsl.set(id).equalToWhenPresent(record::getId)
|
||||
.set(sourceId).equalToWhenPresent(record::getSourceId)
|
||||
.set(sourceName).equalToWhenPresent(record::getSourceName)
|
||||
.set(sourceBookId).equalToWhenPresent(record::getSourceBookId)
|
||||
.set(catId).equalToWhenPresent(record::getCatId)
|
||||
@@ -225,8 +200,41 @@ public interface CrawlSingleTaskMapper {
|
||||
.set(authorName).equalToWhenPresent(record::getAuthorName)
|
||||
.set(taskStatus).equalToWhenPresent(record::getTaskStatus)
|
||||
.set(excCount).equalToWhenPresent(record::getExcCount)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
.set(crawlChapters).equalToWhenPresent(record::getCrawlChapters)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int updateByPrimaryKey(CrawlSingleTask record) {
|
||||
return update(c ->
|
||||
c.set(sourceId).equalTo(record::getSourceId)
|
||||
.set(sourceName).equalTo(record::getSourceName)
|
||||
.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(excCount).equalTo(record::getExcCount)
|
||||
.set(crawlChapters).equalTo(record::getCrawlChapters)
|
||||
.set(createTime).equalTo(record::getCreateTime)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int updateByPrimaryKeySelective(CrawlSingleTask record) {
|
||||
return update(c ->
|
||||
c.set(sourceId).equalToWhenPresent(record::getSourceId)
|
||||
.set(sourceName).equalToWhenPresent(record::getSourceName)
|
||||
.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(excCount).equalToWhenPresent(record::getExcCount)
|
||||
.set(crawlChapters).equalToWhenPresent(record::getCrawlChapters)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,10 @@ http:
|
||||
# 是否开启 HTTP 代理,true-开启,false-不开启
|
||||
enabled: false
|
||||
# 代理 IP
|
||||
ip: us.swiftproxy.net
|
||||
ip: proxy.bestproxy.com
|
||||
# 代理端口号
|
||||
port: 7878
|
||||
port: 2312
|
||||
# 代理用户名
|
||||
username: swiftproxy_u
|
||||
username: bestproxy_u
|
||||
# 代理密码
|
||||
password: swiftproxy_p
|
||||
password: bestproxy_p
|
||||
@@ -6,11 +6,6 @@ spring:
|
||||
mode: LEGACYHTML5 #去除thymeleaf的html严格校验thymeleaf.mode=LEGACYHTML5
|
||||
cache: false # 是否开启模板缓存,默认true,建议在开发时关闭缓存,不然没法看到实时
|
||||
|
||||
# 将所有数字转为 String 类型返回,避免前端数据精度丢失的问题
|
||||
jackson:
|
||||
generator:
|
||||
write-numbers-as-strings: true
|
||||
|
||||
#上传文件的最大值(100M)
|
||||
servlet:
|
||||
multipart:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>novel</artifactId>
|
||||
<groupId>com.java2nb</groupId>
|
||||
<version>5.0.1</version>
|
||||
<version>5.3.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -37,6 +37,10 @@
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -38,10 +38,38 @@ http:
|
||||
# 是否开启 HTTP 代理,true-开启,false-不开启
|
||||
enabled: false
|
||||
# 代理 IP
|
||||
ip: us.swiftproxy.net
|
||||
ip: proxy.bestproxy.com
|
||||
# 代理端口号
|
||||
port: 7878
|
||||
port: 2312
|
||||
# 代理用户名
|
||||
username: swiftproxy_u
|
||||
username: bestproxy_u
|
||||
# 代理密码
|
||||
password: swiftproxy_p
|
||||
password: bestproxy_p
|
||||
|
||||
---
|
||||
|
||||
#邮箱服务器
|
||||
spring:
|
||||
mail:
|
||||
host: smtp.163.com
|
||||
#发件人昵称
|
||||
nickname: novel-plus
|
||||
#邮箱账户
|
||||
username: xxyopen@163.com
|
||||
#邮箱第三方授权码
|
||||
password: novel123456
|
||||
|
||||
|
||||
# 磁盘监控配置
|
||||
disk-monitor:
|
||||
# 是否开启磁盘监控,true-开启,false-不启用
|
||||
enabled: false
|
||||
# 磁盘监控间隔时间(分钟)
|
||||
interval-minutes: 5
|
||||
# 磁盘使用率阈值
|
||||
warning-threshold: 85.0
|
||||
severe-threshold: 90.0
|
||||
critical-threshold: 95.0
|
||||
# 告警邮件接收人列表(支持多个邮箱)
|
||||
recipients: xxyopen@foxmail.com,12345678@qq.com
|
||||
|
||||
|
||||
4
novel-crawl/src/main/build/scripts/novel-crawl.bat
Normal file
4
novel-crawl/src/main/build/scripts/novel-crawl.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
cd /d "%~dp0.."
|
||||
java -jar -Dspring.profiles.active=prod novel-crawl.jar
|
||||
pause
|
||||
@@ -5,9 +5,12 @@ JAR_NAME=$APP_NAME\.jar
|
||||
PID=$APP_NAME\.pid
|
||||
|
||||
|
||||
#使用说明,用来提示输入参数
|
||||
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
|
||||
cd "$SCRIPT_DIR"/.. || exit 1
|
||||
|
||||
# 使用说明
|
||||
usage() {
|
||||
echo "Usage: ./novel-crawl.sh [start|stop|restart|status]"
|
||||
echo "Usage: $0 [start|stop|restart|status]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
@@ -72,17 +72,15 @@ public class CrawlController {
|
||||
if(url.startsWith("https://")||url.startsWith("http://")){
|
||||
String refreshCache="1";
|
||||
if(!refreshCache.equals(isRefresh)) {
|
||||
Object cache = cacheService.getObject(CacheKey.BOOK_TEST_PARSE + url);
|
||||
if (cache == null) {
|
||||
html = cacheService.get(CacheKey.BOOK_TEST_PARSE + url);
|
||||
if (html == null) {
|
||||
isRefresh="1";
|
||||
}else {
|
||||
html = (String) cache;
|
||||
}
|
||||
}
|
||||
if(refreshCache.equals(isRefresh)){
|
||||
html = HttpUtil.getByHttpClientWithChrome(url);
|
||||
if (html != null) {
|
||||
cacheService.setObject(CacheKey.BOOK_TEST_PARSE + url, html, 60 * 10);
|
||||
cacheService.set(CacheKey.BOOK_TEST_PARSE + url, html, 60 * 10);
|
||||
}else{
|
||||
resultMap.put("msg","html is null");
|
||||
return RestResult.ok(resultMap);
|
||||
@@ -153,6 +151,14 @@ public class CrawlController {
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 采集任务进度查询
|
||||
* */
|
||||
@GetMapping("getTaskProgress/{id}")
|
||||
public RestResult<Integer> getTaskProgress(@PathVariable("id") Long id){
|
||||
return RestResult.ok(crawlService.getTaskProgress(id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.java2nb.novel.core.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author xiongxiaoyang
|
||||
* @date 2025/10/24
|
||||
*/
|
||||
@Data
|
||||
public class DiskInfo {
|
||||
|
||||
private String path;
|
||||
private double totalGB;
|
||||
private double freeGB;
|
||||
private double usage;
|
||||
|
||||
public DiskInfo(String path, long totalBytes, long freeBytes, double usage) {
|
||||
this.path = path;
|
||||
this.totalGB = bytesToGB(totalBytes);
|
||||
this.freeGB = bytesToGB(freeBytes);
|
||||
this.usage = usage;
|
||||
}
|
||||
|
||||
private double bytesToGB(long bytes) {
|
||||
return bytes / (1024.0 * 1024.0 * 1024.0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.java2nb.novel.core.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xiongxiaoyang
|
||||
* @date 2025/10/24
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "disk-monitor")
|
||||
@Data
|
||||
public class DiskMonitorProperties {
|
||||
|
||||
private boolean enabled;
|
||||
private int intervalMinutes;
|
||||
private double warningThreshold;
|
||||
private double severeThreshold;
|
||||
private double criticalThreshold;
|
||||
private List<String> recipients;
|
||||
|
||||
}
|
||||
@@ -7,6 +7,6 @@ import com.java2nb.novel.entity.Book;
|
||||
* */
|
||||
public interface CrawlBookHandler {
|
||||
|
||||
void handle(Book book);
|
||||
void handle(Book book) throws InterruptedException;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,19 +5,19 @@ import com.java2nb.novel.core.utils.StringUtil;
|
||||
import com.java2nb.novel.entity.Book;
|
||||
import com.java2nb.novel.entity.BookContent;
|
||||
import com.java2nb.novel.entity.BookIndex;
|
||||
import com.java2nb.novel.entity.CrawlSingleTask;
|
||||
import com.java2nb.novel.utils.Constants;
|
||||
import com.java2nb.novel.utils.CrawlHttpClient;
|
||||
import io.github.xxyopen.util.IdWorker;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CrawlParser {
|
||||
@@ -34,8 +35,48 @@ public class CrawlParser {
|
||||
|
||||
private final CrawlHttpClient crawlHttpClient;
|
||||
|
||||
@SneakyThrows
|
||||
public void parseBook(RuleBean ruleBean, String bookId, CrawlBookHandler handler) {
|
||||
private final StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
/**
|
||||
* 爬虫源采集章节数量缓存key
|
||||
*/
|
||||
private static final String CRAWL_SOURCE_CHAPTER_COUNT_CACHE_KEY = "crawlSource:chapterCount:";
|
||||
|
||||
/**
|
||||
* 爬虫任务进度
|
||||
*/
|
||||
private final Map<Long, Integer> crawlTaskProgress = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 获取爬虫任务进度
|
||||
*/
|
||||
public Integer getCrawlTaskProgress(Long taskId) {
|
||||
return crawlTaskProgress.get(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除爬虫任务进度
|
||||
*/
|
||||
public void removeCrawlTaskProgress(Long taskId) {
|
||||
crawlTaskProgress.remove(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取爬虫源采集的章节数量
|
||||
*/
|
||||
public Long getCrawlSourceChapterCount(Integer sourceId) {
|
||||
return Optional.ofNullable(
|
||||
stringRedisTemplate.opsForValue().get(CRAWL_SOURCE_CHAPTER_COUNT_CACHE_KEY + sourceId)).map(v -> {
|
||||
try {
|
||||
return Long.parseLong(v);
|
||||
} catch (NumberFormatException e) {
|
||||
return 0L;
|
||||
}
|
||||
}).orElse(0L);
|
||||
}
|
||||
|
||||
public void parseBook(RuleBean ruleBean, String bookId, CrawlBookHandler handler)
|
||||
throws InterruptedException {
|
||||
Book book = new Book();
|
||||
String bookDetailUrl = ruleBean.getBookDetailUrl().replace("{bookId}", bookId);
|
||||
String bookDetailHtml = crawlHttpClient.get(bookDetailUrl, ruleBean.getCharset());
|
||||
@@ -97,6 +138,22 @@ public class CrawlParser {
|
||||
.replaceAll("<p>\\s*</p>", "")
|
||||
.replaceAll("<p>", "")
|
||||
.replaceAll("</p>", "<br/>");
|
||||
// 小说简介过滤
|
||||
String filterDesc = ruleBean.getFilterDesc();
|
||||
if (StringUtils.isNotBlank(filterDesc)) {
|
||||
String[] filterRules = filterDesc.replace("\r\n", "\n").split("\n");
|
||||
for (String filterRule : filterRules) {
|
||||
if (StringUtils.isNotBlank(filterRule)) {
|
||||
desc = desc.replaceAll(filterRule, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 去除小说简介前后空格
|
||||
desc = desc.trim();
|
||||
// 去除小说简介末尾冗余的小说名
|
||||
if (desc.endsWith(bookName)) {
|
||||
desc = desc.substring(0, desc.length() - bookName.length());
|
||||
}
|
||||
//设置书籍简介
|
||||
book.setBookDesc(desc);
|
||||
if (StringUtils.isNotBlank(ruleBean.getStatusPatten())) {
|
||||
@@ -120,8 +177,12 @@ public class CrawlParser {
|
||||
if (isFindUpdateTime) {
|
||||
String updateTime = updateTimeMatch.group(1);
|
||||
//设置更新时间
|
||||
book.setLastIndexUpdateTime(
|
||||
new SimpleDateFormat(ruleBean.getUpadateTimeFormatPatten()).parse(updateTime));
|
||||
try {
|
||||
book.setLastIndexUpdateTime(
|
||||
new SimpleDateFormat(ruleBean.getUpadateTimeFormatPatten()).parse(updateTime));
|
||||
} catch (ParseException e) {
|
||||
log.error("解析最新章节更新时间出错", e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -133,7 +194,7 @@ public class CrawlParser {
|
||||
} else if (book.getVisitCount() != null && book.getScore() == null) {
|
||||
//随机根据访问次数生成评分
|
||||
book.setScore(RandomBookInfoUtil.getScoreByVisitCount(book.getVisitCount()));
|
||||
} else if (book.getVisitCount() == null && book.getScore() == null) {
|
||||
} else if (book.getVisitCount() == null) {
|
||||
//都没有,设置成固定值
|
||||
book.setVisitCount(Constants.VISIT_COUNT_DEFAULT);
|
||||
book.setScore(6.5f);
|
||||
@@ -143,8 +204,14 @@ public class CrawlParser {
|
||||
handler.handle(book);
|
||||
}
|
||||
|
||||
public boolean parseBookIndexAndContent(String sourceBookId, Book book, RuleBean ruleBean,
|
||||
Map<Integer, BookIndex> existBookIndexMap, CrawlBookChapterHandler handler) {
|
||||
public boolean parseBookIndexAndContent(String sourceBookId, Book book, RuleBean ruleBean, Integer sourceId,
|
||||
Map<Integer, BookIndex> existBookIndexMap, CrawlBookChapterHandler handler, CrawlSingleTask task)
|
||||
throws InterruptedException {
|
||||
|
||||
if (task != null) {
|
||||
// 开始采集
|
||||
crawlTaskProgress.put(task.getId(), 0);
|
||||
}
|
||||
|
||||
Date currentDate = new Date();
|
||||
|
||||
@@ -202,7 +269,7 @@ public class CrawlParser {
|
||||
calResult = sourceIndexId.substring(0, sourceBookId.length() - y);
|
||||
}
|
||||
|
||||
if (calResult.length() == 0) {
|
||||
if (calResult.isEmpty()) {
|
||||
calResult = "0";
|
||||
|
||||
}
|
||||
@@ -231,6 +298,8 @@ public class CrawlParser {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 去除小说内容末尾的所有换行
|
||||
content = removeTrailingBrTags(content);
|
||||
//插入章节目录和章节内容
|
||||
BookIndex bookIndex = new BookIndex();
|
||||
bookIndex.setIndexName(indexName);
|
||||
@@ -266,6 +335,13 @@ public class CrawlParser {
|
||||
}
|
||||
bookIndex.setUpdateTime(currentDate);
|
||||
|
||||
if (task != null) {
|
||||
// 更新单本任务采集进度
|
||||
crawlTaskProgress.put(task.getId(), indexList.size());
|
||||
}
|
||||
|
||||
// 更新爬虫源采集章节数量
|
||||
stringRedisTemplate.opsForValue().increment(CRAWL_SOURCE_CHAPTER_COUNT_CACHE_KEY + sourceId);
|
||||
|
||||
}
|
||||
|
||||
@@ -275,10 +351,10 @@ public class CrawlParser {
|
||||
isFindIndex = indexIdMatch.find() & indexNameMatch.find();
|
||||
}
|
||||
|
||||
if (indexList.size() > 0) {
|
||||
if (!indexList.isEmpty()) {
|
||||
//如果有爬到最新章节,则设置小说主表的最新章节信息
|
||||
//获取爬取到的最新章节
|
||||
BookIndex lastIndex = indexList.get(indexList.size() - 1);
|
||||
BookIndex lastIndex = indexList.getLast();
|
||||
book.setLastIndexId(lastIndex.getId());
|
||||
book.setLastIndexName(lastIndex.getIndexName());
|
||||
book.setLastIndexUpdateTime(currentDate);
|
||||
@@ -287,7 +363,7 @@ public class CrawlParser {
|
||||
book.setWordCount(totalWordCount);
|
||||
book.setUpdateTime(currentDate);
|
||||
|
||||
if (indexList.size() == contentList.size() && indexList.size() > 0) {
|
||||
if (indexList.size() == contentList.size() && !indexList.isEmpty()) {
|
||||
|
||||
handler.handle(new ChapterBean() {{
|
||||
setBookIndexList(indexList);
|
||||
@@ -307,4 +383,12 @@ public class CrawlParser {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字符串末尾的所有 <br> 类似标签(允许各种空格)
|
||||
*/
|
||||
public static String removeTrailingBrTags(String str) {
|
||||
return str.replaceAll("(?i)(?:\\s*<\\s*br\\s*/?\\s*>)++(?:\\s|\\u3000)*$", "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public class RuleBean {
|
||||
private String visitCountPatten;
|
||||
private String descStart;
|
||||
private String descEnd;
|
||||
private String filterDesc;
|
||||
private String upadateTimePatten;
|
||||
private String upadateTimeFormatPatten;
|
||||
private String bookIndexUrl;
|
||||
|
||||
@@ -74,10 +74,10 @@ public class StarterListener implements ServletContextInitializer {
|
||||
needUpdateBook.getId());
|
||||
//解析章节目录
|
||||
crawlParser.parseBookIndexAndContent(needUpdateBook.getCrawlBookId(), book,
|
||||
ruleBean, existBookIndexMap, chapter -> {
|
||||
bookService.updateBookAndIndexAndContent(book, chapter.getBookIndexList(),
|
||||
chapter.getBookContentList(), existBookIndexMap);
|
||||
});
|
||||
ruleBean, needUpdateBook.getCrawlSourceId(), existBookIndexMap,
|
||||
chapter -> bookService.updateBookAndIndexAndContent(book,
|
||||
chapter.getBookIndexList(),
|
||||
chapter.getBookContentList(), existBookIndexMap), null);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
@@ -109,9 +109,8 @@ public class StarterListener implements ServletContextInitializer {
|
||||
//查询爬虫规则
|
||||
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())) {
|
||||
task.getSourceBookId(), task)) {
|
||||
//采集成功
|
||||
crawlStatus = 1;
|
||||
}
|
||||
@@ -124,6 +123,7 @@ public class StarterListener implements ServletContextInitializer {
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (task != null) {
|
||||
crawlService.updateCrawlSingleTask(task, crawlStatus);
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.java2nb.novel.core.schedule;
|
||||
|
||||
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import com.java2nb.novel.entity.CrawlSource;
|
||||
import com.java2nb.novel.service.CrawlService;
|
||||
import io.github.xxyopen.util.ThreadUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 爬虫线程监控器,监控执行完成的爬虫源,并修改状态
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class CrawlThreadMonitor {
|
||||
|
||||
private final CacheService cacheService;
|
||||
|
||||
private final CrawlService crawlService;
|
||||
|
||||
@Scheduled(fixedRate = 1000 * 60 * 5)
|
||||
public void monitor() {
|
||||
|
||||
//查询需要监控的正在运行的爬虫源
|
||||
List<CrawlSource> sources = crawlService.queryCrawlSourceByStatus((byte) 1);
|
||||
|
||||
for (CrawlSource source : sources) {
|
||||
Set<Long> runningCrawlThreadIds = (Set<Long>) cacheService.getObject(CacheKey.RUNNING_CRAWL_THREAD_KEY_PREFIX + source.getId());
|
||||
boolean sourceStop = true;
|
||||
if (runningCrawlThreadIds != null) {
|
||||
for (Long threadId : runningCrawlThreadIds) {
|
||||
Thread thread = ThreadUtil.findThread(threadId);
|
||||
|
||||
if (thread != null && thread.isAlive()) {
|
||||
//有活跃线程,说明该爬虫源正在运行,数据库中状态正确,不需要修改
|
||||
sourceStop = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceStop) {
|
||||
crawlService.updateCrawlSourceStatus(source.getId(), (byte) 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.java2nb.novel.core.schedule;
|
||||
|
||||
import com.java2nb.novel.core.bean.DiskInfo;
|
||||
import com.java2nb.novel.core.config.DiskMonitorProperties;
|
||||
import com.java2nb.novel.service.EmailService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* @author xiongxiaoyang
|
||||
* @date 2025/10/24
|
||||
*/
|
||||
@ConditionalOnProperty(prefix = "disk-monitor", name = "enabled", havingValue = "true")
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DiskMonitorSchedule {
|
||||
|
||||
private final DiskMonitorProperties properties;
|
||||
|
||||
private final EmailService emailService;
|
||||
|
||||
private final AtomicBoolean criticalAlertSent = new AtomicBoolean(false);
|
||||
|
||||
@Scheduled(fixedDelayString = "#{1000 * 60 * ${disk-monitor.interval-minutes}}")
|
||||
public void checkDiskUsage() {
|
||||
log.info("🔍 开始检查磁盘使用情况...");
|
||||
|
||||
File[] roots = File.listRoots();
|
||||
List<DiskInfo> diskInfos = new ArrayList<>();
|
||||
boolean criticalDetected = false;
|
||||
|
||||
for (File root : roots) {
|
||||
String path = root.getAbsolutePath().trim();
|
||||
if (path.isEmpty()) continue;
|
||||
long total = root.getTotalSpace();
|
||||
if (total == 0) continue;
|
||||
long free = root.getFreeSpace();
|
||||
double usage = (double)(total - free) / total * 100;
|
||||
diskInfos.add(new DiskInfo(path, total, free, usage));
|
||||
if (usage >= properties.getCriticalThreshold()) {
|
||||
criticalDetected = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (criticalDetected) {
|
||||
if (criticalAlertSent.compareAndSet(false, true)) {
|
||||
sendAlertEmail("CRITICAL", diskInfos);
|
||||
log.error("🚨 磁盘使用率 ≥ 95%,10秒后终止进程...");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
System.exit(1);
|
||||
}
|
||||
} else {
|
||||
criticalAlertSent.set(false);
|
||||
double maxUsage = diskInfos.stream().mapToDouble(DiskInfo::getUsage).max().orElse(0);
|
||||
if (maxUsage >= properties.getSevereThreshold() && maxUsage < properties.getCriticalThreshold()) {
|
||||
sendAlertEmail("WARNING", diskInfos);
|
||||
} else if (maxUsage >= properties.getWarningThreshold() && maxUsage < properties.getSevereThreshold()) {
|
||||
sendAlertEmail("INFO", diskInfos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendAlertEmail(String level, List<DiskInfo> diskInfos) {
|
||||
Map<String, Object> model = new HashMap<>();
|
||||
model.put("diskInfos", diskInfos);
|
||||
model.put("alertLevel", getAlertLevelText(level));
|
||||
model.put("icon", getIcon(level));
|
||||
model.put("actionText", getActionText(level));
|
||||
model.put("levelColor", getLevelColor(level));
|
||||
|
||||
String subject = getSubject(level);
|
||||
emailService.sendHtmlEmail(subject, "disk_alert", model, properties.getRecipients());
|
||||
}
|
||||
|
||||
private String getAlertLevelText(String level) {
|
||||
return switch (level) {
|
||||
case "CRITICAL" -> "严重";
|
||||
case "WARNING" -> "警告";
|
||||
case "INFO" -> "提示";
|
||||
default -> "通知";
|
||||
};
|
||||
}
|
||||
|
||||
private String getIcon(String level) {
|
||||
return switch (level) {
|
||||
case "CRITICAL" -> "🚨";
|
||||
case "WARNING" -> "⚠️";
|
||||
case "INFO" -> "💡";
|
||||
default -> "📢";
|
||||
};
|
||||
}
|
||||
|
||||
private String getActionText(String level) {
|
||||
return switch (level) {
|
||||
case "CRITICAL" ->
|
||||
"⚠️ 检测到任一磁盘使用率 ≥ 95%,为防止系统崩溃,系统已自动<strong style='color:#d32f2f'>关闭爬虫程序</strong>。";
|
||||
case "WARNING" ->
|
||||
"📌 建议:<strong style='color:#f57c00'>请立即暂停爬虫程序</strong>,防止磁盘写满导致服务中断。";
|
||||
case "INFO" ->
|
||||
"📌 提示:磁盘使用率已较高,请关注爬虫数据写入情况。";
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
|
||||
private String getLevelColor(String level) {
|
||||
return switch (level) {
|
||||
case "CRITICAL" -> "#d32f2f";
|
||||
case "WARNING" -> "#f57c00";
|
||||
case "INFO" -> "#388e3c";
|
||||
default -> "#1976d2";
|
||||
};
|
||||
}
|
||||
|
||||
private String getSubject(String level) {
|
||||
return switch (level) {
|
||||
case "CRITICAL" -> "🚨 严重告警:磁盘使用率超 95%,爬虫已关闭";
|
||||
case "WARNING" -> "⚠️ 警告:磁盘使用率超 90%,请暂停爬虫";
|
||||
case "INFO" -> "💡 提示:磁盘使用率超 85%";
|
||||
default -> "磁盘使用率告警";
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,13 +47,15 @@ public interface CrawlService {
|
||||
|
||||
/**
|
||||
* 采集并保存小说
|
||||
* @param catId 分类ID
|
||||
* @param bookId 小说ID
|
||||
* @param sourceId 源ID
|
||||
*
|
||||
* @param catId 分类ID
|
||||
* @param ruleBean 采集规则\
|
||||
* @param sourceId 源ID
|
||||
* @param bookId 小说ID
|
||||
* @param task
|
||||
* @return true:成功,false:失败
|
||||
* */
|
||||
boolean parseBookAndSave(int catId, RuleBean ruleBean, Integer sourceId, String bookId);
|
||||
*/
|
||||
boolean parseBookAndSave(int catId, RuleBean ruleBean, Integer sourceId, String bookId, CrawlSingleTask task) throws InterruptedException;
|
||||
|
||||
/**
|
||||
* 根据爬虫状态查询爬虫源集合
|
||||
@@ -117,4 +119,9 @@ public interface CrawlService {
|
||||
* @return
|
||||
*/
|
||||
CrawlSource getCrawlSource(Integer id);
|
||||
|
||||
/**
|
||||
* 采集任务进度查询
|
||||
* */
|
||||
Integer getTaskProgress(Long taskId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.java2nb.novel.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xiongxiaoyang
|
||||
* @date 2025/10/24
|
||||
*/
|
||||
public interface EmailService {
|
||||
|
||||
void sendHtmlEmail(String subject, String templateName, Map<String, Object> templateModel, List<String> to);
|
||||
|
||||
}
|
||||
@@ -2,12 +2,10 @@ package com.java2nb.novel.service.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import com.java2nb.novel.core.crawl.CrawlParser;
|
||||
import com.java2nb.novel.core.crawl.RuleBean;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.core.utils.SpringUtil;
|
||||
import com.java2nb.novel.entity.Book;
|
||||
import com.java2nb.novel.entity.CrawlSingleTask;
|
||||
import com.java2nb.novel.entity.CrawlSource;
|
||||
@@ -34,6 +32,7 @@ import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
||||
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -59,12 +58,14 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
|
||||
private final BookService bookService;
|
||||
|
||||
private final CacheService cacheService;
|
||||
|
||||
private final IdWorker idWorker = IdWorker.INSTANCE;
|
||||
|
||||
private final CrawlHttpClient crawlHttpClient;
|
||||
|
||||
private final Map<Integer, Byte> crawlSourceStatusMap = new HashMap<>();
|
||||
|
||||
private final Map<Integer, Set<Long>> runningCrawlThread = new HashMap<>();
|
||||
|
||||
|
||||
@Override
|
||||
public void addCrawlSource(CrawlSource source) {
|
||||
@@ -99,12 +100,19 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
PageHelper.startPage(page, pageSize);
|
||||
SelectStatementProvider render = select(id, sourceName, sourceStatus, createTime, updateTime)
|
||||
.from(crawlSource)
|
||||
.orderBy(updateTime)
|
||||
.orderBy(updateTime.descending())
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
List<CrawlSource> crawlSources = crawlSourceMapper.selectMany(render);
|
||||
PageBean<CrawlSource> pageBean = PageBuilder.build(crawlSources);
|
||||
pageBean.setList(BeanUtil.copyList(crawlSources, CrawlSourceVO.class));
|
||||
List<CrawlSourceVO> crawlSourceVOS = BeanUtil.copyList(crawlSources, CrawlSourceVO.class);
|
||||
crawlSourceVOS.forEach(crawlSource -> {
|
||||
crawlSource.setSourceStatus(
|
||||
Optional.ofNullable(crawlSourceStatusMap.get(crawlSource.getId())).orElse((byte) 0));
|
||||
crawlSource.setChapterCount(crawlParser.getCrawlSourceChapterCount(crawlSource.getId()));
|
||||
}
|
||||
);
|
||||
pageBean.setList(crawlSourceVOS);
|
||||
return pageBean;
|
||||
}
|
||||
|
||||
@@ -112,14 +120,13 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
@Override
|
||||
public void openOrCloseCrawl(Integer sourceId, Byte sourceStatus) {
|
||||
|
||||
//判断是开启还是关闭,如果是关闭,则修改数据库状态后获取该爬虫正在运行的线程集合并全部停止
|
||||
//如果是开启,先查询数据库中状态,判断该爬虫源是否还在运行,如果在运行,则忽略,
|
||||
// 如果没有则修改数据库状态,并启动线程爬取小说数据加入到runningCrawlThread中
|
||||
// 判断是开启还是关闭,如果是关闭,则获取该爬虫源正在运行的线程集合并全部中断
|
||||
// 如果是开启,先判断该爬虫源是否还在运行,如果在运行,则忽略,如果没有运行则启动线程爬取小说数据并加入到runningCrawlThread中
|
||||
// 最后,保存爬虫源状态
|
||||
if (sourceStatus == (byte) 0) {
|
||||
//关闭,直接修改数据库状态,并直接修改数据库状态后获取该爬虫正在运行的线程集合全部停止
|
||||
SpringUtil.getBean(CrawlService.class).updateCrawlSourceStatus(sourceId, sourceStatus);
|
||||
Set<Long> runningCrawlThreadId = (Set<Long>) cacheService.getObject(
|
||||
CacheKey.RUNNING_CRAWL_THREAD_KEY_PREFIX + sourceId);
|
||||
// 关闭
|
||||
// 将该爬虫源正在运行的线程集合全部停止
|
||||
Set<Long> runningCrawlThreadId = runningCrawlThread.get(sourceId);
|
||||
if (runningCrawlThreadId != null) {
|
||||
for (Long ThreadId : runningCrawlThreadId) {
|
||||
Thread thread = ThreadUtil.findThread(ThreadId);
|
||||
@@ -131,16 +138,13 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
|
||||
|
||||
} else {
|
||||
//开启
|
||||
//查询爬虫源状态和规则
|
||||
CrawlSource source = queryCrawlSource(sourceId);
|
||||
Byte realSourceStatus = source.getSourceStatus();
|
||||
|
||||
// 开启
|
||||
Byte realSourceStatus = Optional.ofNullable(crawlSourceStatusMap.get(sourceId)).orElse((byte) 0);
|
||||
if (realSourceStatus == (byte) 0) {
|
||||
//该爬虫源已经停止运行了,修改数据库状态,并启动线程爬取小说数据加入到runningCrawlThread中
|
||||
SpringUtil.getBean(CrawlService.class).updateCrawlSourceStatus(sourceId, sourceStatus);
|
||||
// 查询爬虫源规则
|
||||
CrawlSource source = queryCrawlSource(sourceId);
|
||||
//该爬虫源已经停止运行了,启动线程爬取小说数据并将线程加入到runningCrawlThread中
|
||||
RuleBean ruleBean = new ObjectMapper().readValue(source.getCrawlRule(), RuleBean.class);
|
||||
|
||||
Set<Long> threadIds = new HashSet<>();
|
||||
//按分类开始爬虫解析任务
|
||||
for (int i = 1; i < 8; i++) {
|
||||
@@ -149,16 +153,15 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
thread.start();
|
||||
//thread加入到监控缓存中
|
||||
threadIds.add(thread.getId());
|
||||
|
||||
}
|
||||
cacheService.setObject(CacheKey.RUNNING_CRAWL_THREAD_KEY_PREFIX + sourceId, threadIds);
|
||||
|
||||
|
||||
runningCrawlThread.put(sourceId, threadIds);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 保存爬虫源状态
|
||||
crawlSourceStatusMap.put(sourceId, sourceStatus);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -196,6 +199,16 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
List<CrawlSingleTask> crawlSingleTasks = crawlSingleTaskMapper.selectMany(render);
|
||||
PageBean<CrawlSingleTask> pageBean = PageBuilder.build(crawlSingleTasks);
|
||||
pageBean.setList(BeanUtil.copyList(crawlSingleTasks, CrawlSingleTaskVO.class));
|
||||
for (CrawlSingleTask crawlSingleTask : pageBean.getList()) {
|
||||
if (crawlSingleTask.getTaskStatus() == 2
|
||||
&& crawlParser.getCrawlTaskProgress(crawlSingleTask.getId()) != null) {
|
||||
// 如果排队中的任务有任务进度,将排队中的任务状态修改成采集中并设置任务进度
|
||||
crawlSingleTask.setTaskStatus((byte) 3);
|
||||
crawlSingleTask.setCrawlChapters(crawlParser.getCrawlTaskProgress(crawlSingleTask.getId()));
|
||||
// 只会有一个任务在采集中
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pageBean;
|
||||
}
|
||||
|
||||
@@ -225,21 +238,27 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
excCount += 1;
|
||||
task.setExcCount(excCount);
|
||||
if (status == 1 || excCount == 5) {
|
||||
//当采集成功或者采集次数等于5,则更新采集最终状态,并停止采集
|
||||
// 当采集成功或者采集次数等于5,则更新采集最终状态,并停止采集
|
||||
task.setTaskStatus(status);
|
||||
}
|
||||
if (status == 1) {
|
||||
// 当采集成功,保存采集的章节数量
|
||||
task.setCrawlChapters(crawlParser.getCrawlTaskProgress(task.getId()));
|
||||
}
|
||||
crawlSingleTaskMapper.updateByPrimaryKeySelective(task);
|
||||
// 删除任务进度
|
||||
crawlParser.removeCrawlTaskProgress(task.getId());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CrawlSource getCrawlSource(Integer id) {
|
||||
Optional<CrawlSource> opt = crawlSourceMapper.selectByPrimaryKey(id);
|
||||
if (opt.isPresent()) {
|
||||
CrawlSource crawlSource = opt.get();
|
||||
return crawlSource;
|
||||
}
|
||||
return null;
|
||||
return crawlSourceMapper.selectByPrimaryKey(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getTaskProgress(Long taskId) {
|
||||
return Optional.ofNullable(crawlParser.getCrawlTaskProgress(taskId)).orElse(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,6 +267,11 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
@Override
|
||||
public void parseBookList(int catId, RuleBean ruleBean, Integer sourceId) {
|
||||
|
||||
String catIdRule = ruleBean.getCatIdRule().get("catId" + catId);
|
||||
if (StringUtils.isBlank(catIdRule)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//当前页码1
|
||||
int page = 1;
|
||||
int totalPage = page;
|
||||
@@ -255,73 +279,91 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
while (page <= totalPage) {
|
||||
|
||||
try {
|
||||
String catIdRule = ruleBean.getCatIdRule().get("catId" + catId);
|
||||
if (StringUtils.isNotBlank(catIdRule)) {
|
||||
String catBookListUrl = "";
|
||||
if (StringUtils.isNotBlank(ruleBean.getBookListUrl())) {
|
||||
// 兼容老规则
|
||||
// 拼接分类URL
|
||||
catBookListUrl = ruleBean.getBookListUrl()
|
||||
.replace("{catId}", catIdRule)
|
||||
.replace("{page}", page + "");
|
||||
} else {
|
||||
// 新规则
|
||||
// 拼接分类URL
|
||||
catBookListUrl = catIdRule.replace("{page}", page + "");
|
||||
}
|
||||
log.info("catBookListUrl:{}", catBookListUrl);
|
||||
String catBookListUrl;
|
||||
if (StringUtils.isNotBlank(ruleBean.getBookListUrl())) {
|
||||
// 兼容老规则
|
||||
// 拼接分类URL
|
||||
catBookListUrl = ruleBean.getBookListUrl()
|
||||
.replace("{catId}", catIdRule)
|
||||
.replace("{page}", page + "");
|
||||
} else {
|
||||
// 新规则
|
||||
// 拼接分类URL
|
||||
catBookListUrl = catIdRule.replace("{page}", page + "");
|
||||
}
|
||||
log.info("catBookListUrl:{}", catBookListUrl);
|
||||
|
||||
String bookListHtml = crawlHttpClient.get(catBookListUrl, ruleBean.getCharset());
|
||||
if (bookListHtml != null) {
|
||||
Pattern bookIdPatten = Pattern.compile(ruleBean.getBookIdPatten());
|
||||
Matcher bookIdMatcher = bookIdPatten.matcher(bookListHtml);
|
||||
boolean isFindBookId = bookIdMatcher.find();
|
||||
while (isFindBookId) {
|
||||
try {
|
||||
//1.阻塞过程(使用了 sleep,同步锁的 wait,socket 中的 receiver,accept 等方法时)
|
||||
//捕获中断异常InterruptedException来退出线程。
|
||||
//2.非阻塞过程中通过判断中断标志来退出线程。
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String bookId = bookIdMatcher.group(1);
|
||||
parseBookAndSave(catId, ruleBean, sourceId, bookId);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
String bookListHtml = crawlHttpClient.get(catBookListUrl, ruleBean.getCharset());
|
||||
if (bookListHtml != null) {
|
||||
Pattern bookIdPatten = Pattern.compile(ruleBean.getBookIdPatten());
|
||||
Matcher bookIdMatcher = bookIdPatten.matcher(bookListHtml);
|
||||
boolean isFindBookId = bookIdMatcher.find();
|
||||
while (isFindBookId) {
|
||||
try {
|
||||
//1.阻塞过程(使用了 sleep,同步锁的 wait,socket 中的 receiver,accept 等方法时)
|
||||
//捕获中断异常InterruptedException来退出线程。
|
||||
//2.非阻塞过程中通过判断中断标志来退出线程。
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
isFindBookId = bookIdMatcher.find();
|
||||
String bookId = bookIdMatcher.group(1);
|
||||
parseBookAndSave(catId, ruleBean, sourceId, bookId, null);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
//1.阻塞过程(使用了 sleep,同步锁的 wait,socket 中的 receiver,accept 等方法时)
|
||||
//捕获中断异常InterruptedException来退出线程。
|
||||
//2.非阻塞过程中通过判断中断标志来退出线程。
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
Pattern totalPagePatten = Pattern.compile(ruleBean.getTotalPagePatten());
|
||||
Matcher totalPageMatcher = totalPagePatten.matcher(bookListHtml);
|
||||
boolean isFindTotalPage = totalPageMatcher.find();
|
||||
if (isFindTotalPage) {
|
||||
isFindBookId = bookIdMatcher.find();
|
||||
}
|
||||
|
||||
totalPage = Integer.parseInt(totalPageMatcher.group(1));
|
||||
|
||||
}
|
||||
Pattern totalPagePatten = Pattern.compile(ruleBean.getTotalPagePatten());
|
||||
Matcher totalPageMatcher = totalPagePatten.matcher(bookListHtml);
|
||||
boolean isFindTotalPage = totalPageMatcher.find();
|
||||
if (isFindTotalPage) {
|
||||
|
||||
totalPage = Integer.parseInt(totalPageMatcher.group(1));
|
||||
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
//1.阻塞过程(使用了 sleep,同步锁的 wait,socket 中的 receiver,accept 等方法时)
|
||||
//捕获中断异常InterruptedException来退出线程。
|
||||
//2.非阻塞过程中通过判断中断标志来退出线程。
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
if (page == totalPage) {
|
||||
if (page >= totalPage) {
|
||||
// 第一遍采集完成,翻到第一页,继续第二次采集,适用于分页数比较少的最近更新列表
|
||||
page = 0;
|
||||
page = 1;
|
||||
try {
|
||||
// 第一遍采集完成,休眠1分钟
|
||||
Thread.sleep(Duration.ofMinutes(1));
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
//1.阻塞过程(使用了 sleep,同步锁的 wait,socket 中的 receiver,accept 等方法时)
|
||||
//捕获中断异常InterruptedException来退出线程。
|
||||
//2.非阻塞过程中通过判断中断标志来退出线程。
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
page += 1;
|
||||
}
|
||||
|
||||
page += 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean parseBookAndSave(int catId, RuleBean ruleBean, Integer sourceId, String bookId) {
|
||||
public boolean parseBookAndSave(int catId, RuleBean ruleBean, Integer sourceId, String bookId, CrawlSingleTask task)
|
||||
throws InterruptedException {
|
||||
|
||||
final AtomicBoolean parseResult = new AtomicBoolean(false);
|
||||
|
||||
@@ -349,11 +391,11 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
book.setCrawlLastTime(new Date());
|
||||
book.setId(idWorker.nextId());
|
||||
//解析章节目录
|
||||
boolean parseIndexContentResult = crawlParser.parseBookIndexAndContent(bookId, book, ruleBean,
|
||||
boolean parseIndexContentResult = crawlParser.parseBookIndexAndContent(bookId, book, ruleBean, sourceId,
|
||||
new HashMap<>(0), chapter -> {
|
||||
bookService.saveBookAndIndexAndContent(book, chapter.getBookIndexList(),
|
||||
chapter.getBookContentList());
|
||||
});
|
||||
}, task);
|
||||
parseResult.set(parseIndexContentResult);
|
||||
|
||||
} else {
|
||||
@@ -385,4 +427,5 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
return crawlSourceMapper.selectMany(render);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.java2nb.novel.service.impl;
|
||||
|
||||
import com.java2nb.novel.service.EmailService;
|
||||
import jakarta.mail.internet.InternetAddress;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.thymeleaf.TemplateEngine;
|
||||
import org.thymeleaf.context.Context;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xiongxiaoyang
|
||||
* @date 2025/10/24
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EmailServiceImpl implements EmailService {
|
||||
|
||||
private final JavaMailSender javaMailSender;
|
||||
private final TemplateEngine templateEngine;
|
||||
|
||||
@Value("${spring.mail.username}")
|
||||
private String fromEmail;
|
||||
|
||||
@Value("${spring.mail.nickname}")
|
||||
private String nickName;
|
||||
|
||||
@Override
|
||||
public void sendHtmlEmail(String subject, String templateName, Map<String, Object> templateModel, List<String> to) {
|
||||
try {
|
||||
MimeMessage message = javaMailSender.createMimeMessage();
|
||||
MimeMessageHelper helper = new MimeMessageHelper(
|
||||
message,
|
||||
MimeMessageHelper.MULTIPART_MODE_MIXED_RELATED,
|
||||
StandardCharsets.UTF_8.name());
|
||||
|
||||
Context context = new Context();
|
||||
context.setVariables(templateModel);
|
||||
|
||||
String htmlBody = templateEngine.process(templateName, context);
|
||||
|
||||
helper.setFrom(new InternetAddress(fromEmail, nickName, "UTF-8"));
|
||||
helper.setTo(to.toArray(new String[0]));
|
||||
helper.setSubject(subject);
|
||||
helper.setText(htmlBody, true);
|
||||
|
||||
javaMailSender.send(message);
|
||||
} catch (Exception e) {
|
||||
log.error("发送邮件失败");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,13 +25,9 @@ public class CrawlHttpClient {
|
||||
|
||||
private static final ThreadLocal<Integer> RETRY_COUNT = new ThreadLocal<>();
|
||||
|
||||
public String get(String url, String charset) {
|
||||
public String get(String url, String charset) throws InterruptedException {
|
||||
if (Objects.nonNull(intervalMin) && Objects.nonNull(intervalMax) && intervalMax > intervalMin) {
|
||||
try {
|
||||
Thread.sleep(random.nextInt(intervalMax - intervalMin + 1) + intervalMin);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
Thread.sleep(random.nextInt(intervalMax - intervalMin + 1) + intervalMin);
|
||||
}
|
||||
String body = HttpUtil.getByHttpClientWithChrome(url, charset);
|
||||
if (Objects.isNull(body) || body.length() < Constants.INVALID_HTML_LENGTH) {
|
||||
@@ -41,7 +37,7 @@ public class CrawlHttpClient {
|
||||
return body;
|
||||
}
|
||||
|
||||
private String processErrorHttpResult(String url, String charset) {
|
||||
private String processErrorHttpResult(String url, String charset) throws InterruptedException{
|
||||
Integer count = RETRY_COUNT.get();
|
||||
if (count == null) {
|
||||
count = 0;
|
||||
|
||||
@@ -20,7 +20,7 @@ public class CrawlSourceVO extends CrawlSource{
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
private Long chapterCount;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -28,6 +28,41 @@ crawl:
|
||||
max: 500
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
#邮箱服务器
|
||||
spring:
|
||||
mail:
|
||||
host: smtp.163.com
|
||||
#发件人昵称
|
||||
nickname: novel-plus
|
||||
#邮箱账户
|
||||
username: xxyopen@163.com
|
||||
#邮箱第三方授权码
|
||||
password: novel123456
|
||||
#编码类型
|
||||
default-encoding: UTF-8
|
||||
port: 465
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
auth: true
|
||||
starttls:
|
||||
enable: true
|
||||
required: rue
|
||||
socketFactory:
|
||||
port: 465
|
||||
class: javax.net.ssl.SSLSocketFactory
|
||||
fallback: false
|
||||
|
||||
# 磁盘监控配置
|
||||
disk-monitor:
|
||||
enabled: false
|
||||
interval-minutes: 5
|
||||
warning-threshold: 85.0
|
||||
severe-threshold: 90.0
|
||||
critical-threshold: 95.0
|
||||
# 告警邮件接收人列表(支持多个邮箱)
|
||||
recipients: xxyopen@foxmail.com,12345678@qq.com
|
||||
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
|
||||
} else if (data.code == 1001) {
|
||||
//未登录
|
||||
location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href);
|
||||
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
|
||||
|
||||
} else {
|
||||
layer.alert(data.msg);
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
<th class="name">
|
||||
采集小说作者名
|
||||
</th>
|
||||
<th class="goread">
|
||||
采集进度
|
||||
</th>
|
||||
<th class="goread">
|
||||
采集次数
|
||||
</th>
|
||||
@@ -113,9 +116,16 @@
|
||||
<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);
|
||||
let curr = 1;
|
||||
let limit = 10;
|
||||
let isUpdate = false;
|
||||
|
||||
function search(curr, limit) {
|
||||
search();
|
||||
setInterval(function () {
|
||||
search();
|
||||
}, 10000);
|
||||
|
||||
function search() {
|
||||
|
||||
$.ajax({
|
||||
type: "get",
|
||||
@@ -140,10 +150,13 @@
|
||||
" " + crawlSource.authorName + "\n" +
|
||||
" </td>\n" +
|
||||
" <td class=\"goread\">\n" +
|
||||
" " + crawlSource.crawlChapters + "\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" +
|
||||
" " + (crawlSource.taskStatus == 0 ? '采集失败' : (crawlSource.taskStatus == 1 ? '采集成功' : (crawlSource.taskStatus == 3 || crawlSource.excCount > 0 ? '采集中' : '排队中'))) + "\n" +
|
||||
" </td>\n" +
|
||||
" <td class=\"name\" valsc=\"291|2037554|1\">"
|
||||
+ crawlSource.createTime + "</td>\n" +
|
||||
@@ -171,7 +184,10 @@
|
||||
|
||||
//首次不执行
|
||||
if (!first) {
|
||||
search(obj.curr, obj.limit);
|
||||
curr = obj.curr;
|
||||
limit = obj.limit;
|
||||
isUpdate = false;
|
||||
search();
|
||||
} else {
|
||||
|
||||
}
|
||||
@@ -182,13 +198,21 @@
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
} else if (data.code == 1001) {
|
||||
//未登录
|
||||
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
|
||||
|
||||
} else if (!isUpdate) {
|
||||
layer.alert(data.msg);
|
||||
}
|
||||
isUpdate = true;
|
||||
|
||||
},
|
||||
error: function () {
|
||||
layer.alert('网络异常');
|
||||
if (!isUpdate) {
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
isUpdate = true;
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -118,6 +118,9 @@
|
||||
示例:<b></p></b>
|
||||
<li><input type="text" id="descEnd" class="s_input icon_key" placeholder="小说简介结束截取字符串:">
|
||||
</li>
|
||||
示例:<b><span\s+class="allshow">([^/]+)</span></b>
|
||||
<li><textarea id="filterDesc"
|
||||
placeholder="过滤简介(多个内容换行)" rows="5" cols="52"></textarea></li>
|
||||
示例:<b>更新:(\d+-\d+-\d+\s\d+:\d+:\d+)</a></b>
|
||||
<li><input type="text" id="upadateTimePatten" class="s_input icon_key"
|
||||
placeholder="小说更新时间的正则表达式:"></li>
|
||||
@@ -338,6 +341,9 @@
|
||||
|
||||
crawlRule.descEnd = descEnd;
|
||||
|
||||
var filterDesc = $("#filterDesc").val();
|
||||
crawlRule.filterDesc = filterDesc;
|
||||
|
||||
var upadateTimePatten = $("#upadateTimePatten").val();
|
||||
|
||||
if (upadateTimePatten.length > 0) {
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<th class="style">
|
||||
序号
|
||||
</th>
|
||||
<th class="chapter">
|
||||
<th class="name">
|
||||
爬虫源
|
||||
</th>
|
||||
<th class="name">
|
||||
@@ -52,6 +52,9 @@
|
||||
<th class="name">
|
||||
更新时间
|
||||
</th>
|
||||
<th class="goread">
|
||||
采集数量
|
||||
</th>
|
||||
<th class="goread">
|
||||
状态
|
||||
</th>
|
||||
@@ -111,11 +114,16 @@
|
||||
<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);
|
||||
let curr = 1;
|
||||
let limit = 10;
|
||||
let isUpdate = false;
|
||||
|
||||
var pageCrawlSourceList = null;
|
||||
search();
|
||||
setInterval(function () {
|
||||
search();
|
||||
}, 10000);
|
||||
|
||||
function search(curr, limit) {
|
||||
function search() {
|
||||
|
||||
$.ajax({
|
||||
type: "get",
|
||||
@@ -125,7 +133,6 @@
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
var crawlSourceList = data.data.list;
|
||||
pageCrawlSourceList = data.data.list;
|
||||
if (crawlSourceList.length > 0) {
|
||||
var crawlSourceListHtml = "";
|
||||
for (var i = 0; i < crawlSourceList.length; i++) {
|
||||
@@ -134,13 +141,15 @@
|
||||
" <td class=\"style bookclass\">\n" +
|
||||
" [" + (i + 1) + "]\n" +
|
||||
" </td>\n" +
|
||||
" <td class=\"chapter\">\n" +
|
||||
" <td class=\"name\">\n" +
|
||||
" " + crawlSource.sourceName + "</td>\n" +
|
||||
" <td class=\"name\" valsc=\"291|2037554|1\">"
|
||||
+ crawlSource.createTime + "</td>\n" +
|
||||
" <td class=\"name\">\n" +
|
||||
" " + crawlSource.updateTime + "\n" +
|
||||
" </td>\n" +
|
||||
" <td class=\"goread\">\n" +
|
||||
" " + crawlSource.chapterCount + "章</td>\n" +
|
||||
" <td class=\"goread\" id='sourceStatus" + crawlSource.id + "'>" + (crawlSource.sourceStatus == 0 ? '停止运行' : '正在运行') +
|
||||
" </td>\n" +
|
||||
|
||||
@@ -169,7 +178,10 @@
|
||||
|
||||
//首次不执行
|
||||
if (!first) {
|
||||
search(obj.curr, obj.limit);
|
||||
curr = obj.curr;
|
||||
limit = obj.limit;
|
||||
isUpdate = false;
|
||||
search();
|
||||
} else {
|
||||
|
||||
}
|
||||
@@ -182,15 +194,19 @@
|
||||
|
||||
} else if (data.code == 1001) {
|
||||
//未登录
|
||||
location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href);
|
||||
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
|
||||
|
||||
} else {
|
||||
} else if (!isUpdate) {
|
||||
layer.alert(data.msg);
|
||||
}
|
||||
isUpdate = true;
|
||||
|
||||
},
|
||||
error: function () {
|
||||
layer.alert('网络异常');
|
||||
if (!isUpdate) {
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
isUpdate = true;
|
||||
}
|
||||
})
|
||||
|
||||
@@ -216,17 +232,17 @@
|
||||
if (status == 0) {
|
||||
//开启
|
||||
$("#sourceStatus" + sourceId).html("正在运行");
|
||||
$("#opt" + sourceId).html("<a href='javascript:openOrStopCrawl(" + sourceId + "," + 1 + ")'>关闭</a>");
|
||||
$("#opt" + sourceId).html("<a href='javascript:openOrStopCrawl(" + sourceId + "," + 1 + ")'>关闭 </a>" + "<a href='javascript:updateCrawlSource(" + sourceId + ")'>修改 </a>");
|
||||
} else {
|
||||
//关闭
|
||||
$("#sourceStatus" + sourceId).html("停止运行");
|
||||
$("#opt" + sourceId).html("<a href='javascript:openOrStopCrawl(" + sourceId + "," + 0 + ")'>开启</a>");
|
||||
$("#opt" + sourceId).html("<a href='javascript:openOrStopCrawl(" + sourceId + "," + 0 + ")'>开启 </a>" + "<a href='javascript:updateCrawlSource(" + sourceId + ")'>修改 </a>");
|
||||
}
|
||||
|
||||
|
||||
} else if (data.code == 1001) {
|
||||
//未登录
|
||||
location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href);
|
||||
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
|
||||
|
||||
} else {
|
||||
layer.alert(data.msg);
|
||||
|
||||
@@ -119,6 +119,9 @@
|
||||
示例:<b></p></b>
|
||||
<li><input type="text" id="descEnd" class="s_input icon_key" placeholder="小说简介结束截取字符串:">
|
||||
</li>
|
||||
示例:<b><span\s+class="allshow">([^/]+)</span></b>
|
||||
<li><textarea id="filterDesc"
|
||||
placeholder="过滤简介(多个内容换行)" rows="5" cols="52"></textarea></li>
|
||||
示例:<b>更新:(\d+-\d+-\d+\s\d+:\d+:\d+)</a></b>
|
||||
<li><input type="text" id="upadateTimePatten" class="s_input icon_key"
|
||||
placeholder="小说更新时间的正则表达式:"></li>
|
||||
@@ -214,7 +217,7 @@
|
||||
loadPage(data.data);
|
||||
} else if (data.code == 1001) {
|
||||
//未登录
|
||||
location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href);
|
||||
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
|
||||
|
||||
} else {
|
||||
layer.alert(data.msg);
|
||||
@@ -266,6 +269,7 @@
|
||||
$("#visitCountPatten").val(crawlRule.visitCountPatten);
|
||||
$("#descStart").val(crawlRule.descStart);
|
||||
$("#descEnd").val(crawlRule.descEnd);
|
||||
$("#filterDesc").val(crawlRule.filterDesc);
|
||||
$("#upadateTimePatten").val(crawlRule.upadateTimePatten);
|
||||
$("#upadateTimeFormatPatten").val(crawlRule.upadateTimeFormatPatten);
|
||||
$("#bookIndexUrl").val(crawlRule.bookIndexUrl);
|
||||
@@ -424,6 +428,9 @@
|
||||
|
||||
crawlRule.descEnd = descEnd;
|
||||
|
||||
var filterDesc = $("#filterDesc").val();
|
||||
crawlRule.filterDesc = filterDesc;
|
||||
|
||||
var upadateTimePatten = $("#upadateTimePatten").val();
|
||||
|
||||
if (upadateTimePatten.length > 0) {
|
||||
|
||||
44
novel-crawl/src/main/resources/templates/disk_alert.html
Normal file
44
novel-crawl/src/main/resources/templates/disk_alert.html
Normal file
@@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; color: #333; background: #f4f6f9; }
|
||||
.container { max-width: 800px; margin: 20px auto; padding: 20px; background: #fff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
|
||||
.header { padding: 15px; border-radius: 6px; text-align: center; color: white; }
|
||||
table { width: 100%; border-collapse: collapse; margin: 20px 0; }
|
||||
th { background: #1976d2; color: white; padding: 12px; text-align: center; }
|
||||
td { padding: 10px; border: 1px solid #ddd; text-align: center; }
|
||||
.action { margin: 20px 0; font-size: 16px; line-height: 1.6; }
|
||||
.footer { margin-top: 30px; font-size: 12px; color: #777; text-align: center; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header" th:style="'background:' + ${levelColor}">
|
||||
<h2 th:text="${icon} + ' ' + ${alertLevel} + ' 告警:磁盘使用率过高'"></h2>
|
||||
</div>
|
||||
|
||||
<p><strong>时间:</strong><span th:text="${#dates.format(#dates.createNow(), 'yyyy-MM-dd HH:mm:ss')}"></span></p>
|
||||
|
||||
<div class="action" th:utext="${actionText}"></div>
|
||||
|
||||
<h3>📊 磁盘使用详情</h3>
|
||||
<table>
|
||||
<tr style="background:#1976d2; color:white;">
|
||||
<th>磁盘路径</th><th>总空间 (GB)</th><th>空闲空间 (GB)</th><th>使用率</th>
|
||||
</tr>
|
||||
<tr th:each="disk : ${diskInfos}" th:style="'background-color:#f9f9f9;'">
|
||||
<td th:text="${disk.path}"></td>
|
||||
<td th:text="${#numbers.formatDecimal(disk.totalGB, 2, 2)}"></td>
|
||||
<td th:text="${#numbers.formatDecimal(disk.freeGB, 2, 2)}"></td>
|
||||
<td th:text="${#numbers.formatDecimal(disk.usage, 2, 2)} + '%'"
|
||||
th:style="'color:' + ${disk.usage >= 95 ? '#d32f2f' : (disk.usage >= 90 ? '#f57c00' : '#388e3c')} + '; font-weight:bold;'">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="footer">此邮件由磁盘监控系统自动发送,请及时处理。</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>novel</artifactId>
|
||||
<groupId>com.java2nb</groupId>
|
||||
<version>5.0.1</version>
|
||||
<version>5.3.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -59,7 +59,13 @@
|
||||
<!-- AI -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
|
||||
<artifactId>spring-ai-starter-model-openai</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.lionsoul</groupId>
|
||||
<artifactId>ip2region</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -90,6 +96,16 @@
|
||||
<include name="application-website.yml"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${basedir}/../templates/green/html" overwrite="true">
|
||||
<fileset dir="${basedir}/src/main/resources/templates">
|
||||
<include name="**/*.*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${basedir}/../templates/green/static" overwrite="true">
|
||||
<fileset dir="${basedir}/src/main/resources/static">
|
||||
<include name="**/*.*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${project.build.directory}/build/templates" overwrite="true">
|
||||
<fileset dir="${basedir}/../templates">
|
||||
<include name="**/*.*"/>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user