Compare commits

...

104 Commits

Author SHA1 Message Date
773ce159f7 v5.2.2 发布 2025-07-17 21:14:24 +08:00
91e7d2712b refactor: 重构sort和order参数校验功能 2025-07-17 20:53:41 +08:00
3db8828384 fix: 修复sort和order参数的SQL注入漏洞 2025-07-17 19:03:58 +08:00
54bd194b98 feat(novel-crawl): 增加爬虫源采集章节数量监控功能
可以监测到爬虫源在当前环境下是否可用
2025-07-16 19:52:07 +08:00
3d41cf3ebb perf(novel-crawl): 优化爬虫源列表排序
按照更新时间倒序
2025-07-15 18:53:31 +08:00
720711414c v5.2.1 发布 2025-07-14 22:00:34 +08:00
522bb7c739 fix(novel-front): 修复评论回复中的XSS漏洞 2025-07-14 21:02:13 +08:00
64e1686fd1 v5.2.0 发布 2025-07-12 19:54:23 +08:00
90009a57f4 模版更新 2025-07-12 18:40:05 +08:00
6452c1603f fix(templates): URI编码 2025-07-12 18:32:28 +08:00
d54eda2366 perf: 未登录自动跳转 2025-07-12 18:26:00 +08:00
972a49f1ba docs: 错别字修改 2025-07-12 18:05:06 +08:00
675b156094 perf(novel-front): 优化评论时间显示 2025-07-12 14:08:42 +08:00
3c409023e5 feat(novel-front): 增加评论点赞/点踩功能 2025-07-12 13:33:23 +08:00
02fb819120 feat(novel-front): 增加评论回复功能 2025-07-12 11:15:35 +08:00
8c572edb10 perf(novel-crawl): 优化单本采集任务进度显示功能 2025-07-11 22:55:36 +08:00
8c9013ad05 feat(novel-crawl): 增加单本采集任务进度显示功能 2025-07-11 22:09:28 +08:00
4693c7ffae feat(novel-front): 增加评论用户地理位置显示功能 2025-06-30 20:51:29 +08:00
efb136e3be v5.1.5 发布 2025-06-21 19:45:18 +08:00
7955db0e3c perf(novel-crawl): 去除小说简介前后空格 2025-06-21 19:06:08 +08:00
60dc28c5ed perf(novel-crawl): 去除小说简介末尾冗余的小说名 2025-06-21 18:12:37 +08:00
1534220f0c perf(novel-crawl): 增加小说简介过滤规则 2025-06-21 17:54:59 +08:00
0830f6ffeb Merge remote-tracking branch 'Gitee/develop_xxy' into develop_xxy 2025-06-21 12:33:02 +08:00
adc83db64e perf(novel-crawl): 去除小说内容末尾的所有换行 2025-06-21 12:32:11 +08:00
9c11f22816 v5.1.4 发布 2025-06-19 19:42:03 +08:00
24abe7714f chore: 增加在线演示网站 2025-06-19 19:38:22 +08:00
a9fc80eba1 fix: 修复 ConcurrentModificationException 2025-06-19 19:32:04 +08:00
32541a7cb6 v5.1.3发布 2025-05-13 11:16:08 +08:00
42bcecc304 fix(novel-crawl): 解决爬虫进程间的冲突问题,支持同时启动多个爬虫进程 2025-05-13 11:11:27 +08:00
a07643bde0 fix(novel-crawl): 解决多个爬虫进程间的爬虫源状态冲突问题 2025-05-13 10:45:38 +08:00
1f53b56bd6 fix(novel-crawl): 调整线程终止逻辑 2025-05-13 09:58:47 +08:00
2c86cb9a7d v5.1.2 发布 2025-05-12 18:33:59 +08:00
a4d6272a4f perf(novel-crawl): 减小失效爬虫的CPU占用 2025-05-12 18:18:48 +08:00
55d5deea74 fix(novel-crawl): 修复部分源无法停止的问题 2025-05-12 17:48:24 +08:00
4f474b91a8 Update README.md 2025-05-07 08:50:48 +08:00
ca22eed665 v5.1.1 发布 2025-04-27 18:54:23 +08:00
df1b72fb58 style: 代码格式化 2025-04-25 08:37:10 +08:00
415bf8a64c perf: 设置小说推荐缓存时间 2025-04-25 08:30:35 +08:00
3f009dc1f9 fix: 小说封面图修改 2025-04-21 21:47:01 +08:00
0e156c04b4 fix: 修复部分环境 Public Key Retrieval is not allowed 错误
MySQL 8.0+ 默认使用 caching_sha2_password 认证插件,这种认证方式有两种工作模式:
- 如果使用SSL连接,直接通过安全通道传输密码
- 如果不使用SSL连接,客户端需要从服务器获取RSA公钥来加密密码
当设置 useSSL=false 但未明确允许公钥检索时,JDBC驱动出于安全考虑会阻止这种操作(报错:Public Key Retrieval is not allowed)。
生产环境中,应优先考虑:
1. 启用 SSL/TLS 加密连接
2. 如需禁用 SSL,改用 mysql_native_password 认证
3. 仅在受控环境(如开发环境)中使用 allowPublicKeyRetrieval=true
2025-03-27 22:24:56 +08:00
d4fa0abc4e perf: 使用流式响应处理AI生成文本,提高用户体验 2025-03-23 23:33:24 +08:00
eff4fc4c7c fix: Spring AI 流式 API 请求 400 错误
在对 RestController 返回对象 json 格式化时,将所有 Long 类型转为 String 类型返回,避免前端数据精度丢失的问题。
 主要是为了取代 spring.jackson.generator.write-numbers-as-strings=true 配置,避免影响全局的 ObjectMapper
2025-03-23 21:45:49 +08:00
8c1c0f10be build: 修改外部配置文件 2025-03-23 12:46:13 +08:00
02ad0f93dc v5.1.0 发布 2025-03-23 12:35:08 +08:00
a06132a4c2 模版更新 2025-03-23 11:50:44 +08:00
f043ddff42 style: 代码格式化 2025-03-23 11:49:23 +08:00
328bd55587 feat: AI自动生成小说封面图片 2025-03-23 11:46:12 +08:00
04fc8e878a fix: 修复升级v5.0.0导致图片上传失败的问题
- 当使用 `$.ajax`发起异步请求时 ,设置`dataType: "json"`会在请求头中自动添加`Accept: application/json`,表示客户端期望服务器返回`JSON`格式的数据。
- 当使用 `$.ajaxFileUpload` 上传文件时,它的行为与`$.ajax`不同,不会自动修改`Accept`请求头,即使设置了`dataType: "json"` `$.ajaxFileUpload`也不会在请求头中添加`Accept: application/json`。

Spring Boot 默认返回`JSON`格式的响应,但它支持内容协商,它会根据客户端请求的`Accept`头来决定返回的响应格式。如果浏览器发送的请求中
`Accept`头包含`application/xml`,并且 Spring Boot 支持`XML`格式响应的话,Spring Boot 会返`XML`格式的响应。但 Spring Boot 默认不支持`XML`格式的响应,当升级`Sharding-JDBC `版本后,自动引入了`jackson-dataformat-xml`依赖,才开始支持`XML`格式的响应,由于`$.ajaxFileUpload`上传文件的默认`Accept`头包含`application/xml`,所以需要在后端上传文件接口处明确指定返回的数据类型为`application/json`。
2025-03-23 09:28:01 +08:00
970ad407f1 perf: AI内容生成失败提醒 2025-03-23 06:44:31 +08:00
f8079f443a Update README.md 2025-03-21 13:14:01 +08:00
75a4c3002b 合并 5.0.x 分支 2025-03-21 12:07:21 +08:00
e4e511aed8 feat: 移出书架 2025-03-20 22:03:10 +08:00
ec9674f2aa feat: 移出书架 2025-03-20 21:51:51 +08:00
06074faf9a feat(pc): 移除书架 2025-03-20 17:30:18 +08:00
73654dda2b ci: GitHub Actions 设置上传 token 2025-03-20 14:58:26 +08:00
c0634a335e ci: GitHub Actions 上传ZIP包 2025-03-20 14:48:42 +08:00
5dcc2b0b46 v5.0.1 发布 2025-03-20 13:27:46 +08:00
6cdb68899b ci: GitHub Actions 指定中央仓库下载 maven 依赖 2025-03-20 13:26:10 +08:00
d955b11165 ci: 创建 GitHub Actions 工作流自动发布版本 2025-03-20 13:19:51 +08:00
99f2a15990 build: 创建 GitHub Actions 工作流自动发布版本 2025-03-20 12:21:45 +08:00
1081b8e10a chore: 修改日志 2025-03-19 10:12:22 +08:00
4b1507b2d1 perf: 连接池统一创建 2025-03-19 10:04:54 +08:00
82658f3b5f perf: 兼容其它数据源 2025-03-19 08:03:45 +08:00
acf9c76757 perf: 提前创建数据库连接池
Spring Boot 新版本默认会在第一次请求数据库时创建连接池
2025-03-19 07:50:50 +08:00
4b00ea68a9 perf: 提高第一次登录速度 2025-03-19 00:09:10 +08:00
d9f9fd8bd2 build: 优化打包配置 2025-03-18 21:39:01 +08:00
c1583f83bb fix: 网站icon显示 2025-03-18 21:19:18 +08:00
eecbb2dd9c fix: 通用异常处理 2025-03-18 21:18:51 +08:00
0afc7b1bbf fix: 通用异常处理 2025-03-18 21:03:21 +08:00
f5a9a7423f fix: 生产环境web静态资源目录配置 2025-03-18 20:22:54 +08:00
3858cd4e49 build: 修改版本号 2025-03-18 19:10:10 +08:00
c4a6acf2b3 fix: 网站ico图标显示 2025-03-18 14:24:19 +08:00
8781cc54d4 chore: 模版/配置/SQL/文档更新 2025-03-17 18:47:05 +08:00
84a06a7037 fix: 通用异常处理 2025-03-17 10:18:18 +08:00
a046899dd6 fix:通用异常处理 2025-03-17 10:12:53 +08:00
14a1ff69bf build: 升级配置 2025-03-16 14:27:47 +08:00
467290b908 feat: 集成 Spring AI 实现基础的 AI 写作功能 2025-03-16 13:03:37 +08:00
d77ce5b446 build: Spring Boot 升级到 3.4.0 2025-03-15 23:35:47 +08:00
8d35aa80ab build: 修改打包配置 2025-03-15 19:51:43 +08:00
11978c2c9e build: v5.0.0发布 2025-03-15 19:29:37 +08:00
81c1514a21 build: 构建生产环境配置 2025-03-15 17:25:10 +08:00
af1237e2d7 build: Java版本升级到21 2025-03-15 15:13:36 +08:00
9033ca6331 build: Java版本升级到21 & SpringBoot版本升级到2.7.18 2025-03-15 15:06:59 +08:00
fd200772c9 build: 修改版本号 2025-03-15 09:15:26 +08:00
73502a279b feat: 支持非utf-8编码的网站采集 2025-03-14 20:39:57 +08:00
85b64bbc10 perf: 爬虫采集流程优化 2025-03-14 19:27:46 +08:00
6d0ab33757 perf: 爬虫分类规则优化 2025-03-14 19:03:30 +08:00
74d7ea7000 feat: 代理IP增加用户名密码设置 2025-03-14 18:36:14 +08:00
cdfe481d60 Update README.md 2025-03-14 17:48:35 +08:00
0ff87614ea fix: 修复失效的爬虫规则 2025-02-28 22:02:11 +08:00
2cb9f85081 优化提示 2025-01-18 00:46:39 +08:00
d8e559ab50 修复规则 2024-11-02 21:19:27 +08:00
3849a9b86f build: 修改版本号 2024-11-02 18:32:01 +08:00
71b9d1d916 模版更新 2024-11-02 18:31:47 +08:00
4b9dbe969c 修复i笔趣阁爬虫规则 2024-11-02 18:26:40 +08:00
2136f7490f 增加爬虫规则 2024-11-02 13:24:28 +08:00
3586ffbc0a 优化 2024-09-21 11:14:07 +08:00
f78a2a36cf 优化 2024-09-21 11:10:44 +08:00
a8219253e9 优化 2024-09-21 10:15:45 +08:00
5c35f7af0a 更换默认logo图片 2024-09-16 21:08:32 +08:00
d55e1a3e22 revert: sql格式化还原 2024-08-06 22:42:43 +08:00
21a6a49ce9 fix: 作家稿费统计 2024-08-06 21:14:22 +08:00
3735023cef perf(novel-front): UI优化 2024-07-20 21:48:29 +08:00
89992dc781 perf(novel-crawl): 增加小说内容过滤 2024-06-01 09:56:07 +08:00
226 changed files with 5103 additions and 1871 deletions

79
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,79 @@
name: Create novel-plus Maven Release with ZIPs
on:
push:
# 匹配所有以'v'开头的标签
tags:
- 'v*'
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
# 可选默认是 temurin也可以选择其他发行版
distribution: 'temurin'
- name: Build project with Maven
run: mvn clean install -DskipTests=true -Pcentral-repo
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# 使用 tag_name 而不是 github.ref
tag_name: ${{ github.ref_name }}
release_name: novel-plus ${{ github.ref_name }}
draft: false
prerelease: false
# 使用 action 来替代直接 curl 进行上传
- name: Upload sql.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/novel-common/target/build/sql.zip
asset_name: sql.zip
asset_content_type: application/zip
- name: Upload novel-crawl.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/novel-crawl/target/build/novel-crawl.zip
asset_name: novel-crawl.zip
asset_content_type: application/zip
- name: Upload novel-front.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/novel-front/target/build/novel-front.zip
asset_name: novel-front.zip
asset_content_type: application/zip
- name: Upload novel-admin.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/novel-admin/target/build/novel-admin.zip
asset_name: novel-admin.zip
asset_content_type: application/zip

View File

@ -1,28 +1,28 @@
[![index]( https://youdoc.github.io/img/tencent.jpg )]( https://cloud.tencent.com/act/cps/redirect?redirect=2446&cps_key=736e609d66e0ac4e57813316cec6fd0b&from=console )
<p align="center">
<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">
<a href='https://github.com/201206030/novel-plus'><img alt="Github stars" src="https://img.shields.io/github/stars/201206030/novel-plus?logo=github"></a>
<a href='https://github.com/201206030/novel-plus'><img alt="Github forks" src="https://img.shields.io/github/forks/201206030/novel-plus?logo=github"></a>
<a href='https://gitee.com/novel_dev_team/novel-plus'><img alt="Gitee stars" src="https://gitee.com/novel_dev_team/novel-plus/badge/star.svg?theme=gitee"></a>
<a href='https://gitee.com/novel_dev_team/novel-plus'><img alt="Gitee forks" src="https://gitee.com/novel_dev_team/novel-plus/badge/fork.svg?theme=gitee"></a>
<a href="https://github.com/201206030/novel-plus"><img src="https://visitor-badge.glitch.me/badge?page_id=201206030.novel-plus" alt="visitors"></a>
</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 是一个多端PCWAP阅读功能完善的原创文学 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)
## 项目结构
@ -38,24 +38,25 @@ novel-plus -- 父工程
## 技术选型
| 技术 | 说明
|---------------------| ---------------------------
| Spring Boot | Spring 应用快速开发脚手架
| 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 框架
## 项目截图
@ -69,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-Distill-Llama-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-Distill-Llama-8B
```
novel-plus 项目默认使用的都是免费 AI 模型生成效果有限如果对生成内容有更高的要求建议选用付费的 AI 模型
## 增值服务
👉 [了解详情](https://novel.xxyopen.com/service.htm)
@ -93,3 +127,5 @@ https://www.bilibili.com/video/BV18e41197xs
## 免责声明
本项目提供的爬虫工具仅用于采集项目初期的测试数据请勿用于商业盈利 用户使用本系统从事任何违法违规的事情一切后果由用户自行承担作者不承担任何责任

View File

@ -0,0 +1,53 @@
mode:
# 单机模式
type: Standalone
# 元数据持久化
repository:
# 数据库持久化
type: JDBC
# 数据源配置
dataSources:
ds_1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.cj.jdbc.Driver
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?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456
# 规则配置
rules:
- !SINGLE
tables:
- "*.*"
- !SHARDING
tables: # 数据分片规则配置
book_content:
# 分库策略缺省表示使用默认分库策略
actualDataNodes: ds_${1}.book_content${0..9}
# 分表策略
tableStrategy:
standard:
# 分片列名称
shardingColumn: index_id
# 分片算法名称
shardingAlgorithmName: bookContentSharding
shardingAlgorithms:
bookContentSharding:
# 行表达式分片算法使用 Groovy 的表达式提供对 SQL 语句中的 = IN 的分片操作支持
type: INLINE
props:
# 分片算法的行表达式
algorithm-expression: book_content${index_id % 10}
props:
# 是否在日志中打印 SQL
sql-show: true

44
doc/sql/20250317.sql Normal file
View File

@ -0,0 +1,44 @@
INSERT INTO crawl_source (source_name, crawl_rule, source_status, create_time, update_time)
VALUES ('香书小说网', '{
"bookListUrl": "http://www.xbiqugu.la/fenlei/{catId}_{page}.html",
"catIdRule": {
"catId1": "1",
"catId2": "2",
"catId3": "3",
"catId4": "4",
"catId5": "6",
"catId6": "5"
},
"bookIdPatten": "<a\\\\s+href=\\"http://www.xbiqugu.la/(\\\\d+/\\\\d+)/\\"\\\\s+target=\\"_blank\\">",
"pagePatten": "<em\\\\s+id=\\"pagestats\\">(\\\\d+)/\\\\d+</em>",
"totalPagePatten": "<em\\\\s+id=\\"pagestats\\">\\\\d+/(\\\\d+)</em>",
"bookDetailUrl": "http://www.xbiqugu.la/{bookId}/",
"bookNamePatten": "<h1>([^/]+)</h1>",
"authorNamePatten": "者:([^/]+)</p>",
"picUrlPatten": "src=\\"(http://www.xbiqugu.la/files/article/image/\\\\d+/\\\\d+/\\\\d+s\\\\.jpg)\\"",
"bookStatusRule": {},
"descStart": "<div id=\\"intro\\">",
"descEnd": "</div>",
"upadateTimePatten": "<p>最后更新:(\\\\d+-\\\\d+-\\\\d+\\\\s\\\\d+:\\\\d+:\\\\d+)</p>",
"upadateTimeFormatPatten": "yyyy-MM-dd HH:mm:ss",
"bookIndexUrl": "http://www.xbiqugu.la/{bookId}/",
"indexIdPatten": "<a\\\\s+href=''/\\\\d+/\\\\d+/(\\\\d+)\\\\.html''\\\\s+>[^/]+</a>",
"indexNamePatten": "<a\\\\s+href=''/\\\\d+/\\\\d+/\\\\d+\\\\.html''\\\\s+>([^/]+)</a>",
"bookContentUrl": "http://www.xbiqugu.la/{bookId}/{indexId}.html",
"contentStart": "<div id=\\"content\\">",
"contentEnd": "<p>",
"filterContent":"<div\\\\s+id=\\"content_tip\\">\\\\s*<b>([^/]+)</b>\\\\s*</div>"
}', 0, '2024-06-01 10:11:39', '2024-06-01 10:11:39');
update crawl_source
set crawl_rule = replace(crawl_rule, 'ibiquzw.org', 'biquxs.info')
where id = 16;
delete
from sys_menu
where menu_id = 104;
delete
from sys_menu
where menu_id = 57;

3
doc/sql/20250630.sql Normal file
View 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
View 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
View 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 ='小说评论回复表';

View File

@ -1,7 +1,5 @@
CREATE
database if NOT EXISTS `novel_plus` default character set utf8mb4 collate utf8mb4_unicode_ci;
use
`novel_plus`;
CREATE database if NOT EXISTS `novel_plus` default character set utf8mb4 collate utf8mb4_unicode_ci;
use `novel_plus`;
SET NAMES utf8mb4;
@ -3105,4 +3103,75 @@ where id = 16;
update website_info
set logo = '/images/logo.png',
logo_dark='/images/logo.png'
where id = 1;
where id = 1;
INSERT INTO crawl_source (source_name, crawl_rule, source_status, create_time, update_time)
VALUES ('香书小说网', '{
"bookListUrl": "http://www.xbiqugu.net/fenlei/{catId}_{page}.html",
"catIdRule": {
"catId1": "1",
"catId2": "2",
"catId3": "3",
"catId4": "4",
"catId5": "6",
"catId6": "5"
},
"bookIdPatten": "<a\\\\s+href=\\"http://www.xbiqugu.net/(\\\\d+/\\\\d+)/\\"\\\\s+target=\\"_blank\\">",
"pagePatten": "<em\\\\s+id=\\"pagestats\\">(\\\\d+)/\\\\d+</em>",
"totalPagePatten": "<em\\\\s+id=\\"pagestats\\">\\\\d+/(\\\\d+)</em>",
"bookDetailUrl": "http://www.xbiqugu.net/{bookId}/",
"bookNamePatten": "<h1>([^/]+)</h1>",
"authorNamePatten": "者:([^/]+)</p>",
"picUrlPatten": "src=\\"(http://www.xbiqugu.net/files/article/image/\\\\d+/\\\\d+/\\\\d+s\\\\.jpg)\\"",
"bookStatusRule": {},
"descStart": "<div id=\\"intro\\">",
"descEnd": "</div>",
"upadateTimePatten": "<p>最后更新:(\\\\d+-\\\\d+-\\\\d+\\\\s\\\\d+:\\\\d+:\\\\d+)</p>",
"upadateTimeFormatPatten": "yyyy-MM-dd HH:mm:ss",
"bookIndexUrl": "http://www.xbiqugu.net/{bookId}/",
"indexIdPatten": "<a\\\\s+href=''/\\\\d+/\\\\d+/(\\\\d+)\\\\.html''\\\\s+>[^/]+</a>",
"indexNamePatten": "<a\\\\s+href=''/\\\\d+/\\\\d+/\\\\d+\\\\.html''\\\\s+>([^/]+)</a>",
"bookContentUrl": "http://www.xbiqugu.net/{bookId}/{indexId}.html",
"contentStart": "<div id=\\"content\\">",
"contentEnd": "<p>",
"filterContent":"<div\\\\s+id=\\"content_tip\\">\\\\s*<b>([^/]+)</b>\\\\s*</div>"
}', 0, '2024-06-01 10:11:39', '2024-06-01 10:11:39');
update crawl_source
set crawl_rule = replace(crawl_rule, 'ibiquzw.org', 'biquxs.info')
where id = 16;
update crawl_source
set crawl_rule = replace(crawl_rule, 'xbiqugu.net', 'xbiqugu.la');
delete
from sys_menu
where menu_id = 104;
delete
from sys_menu
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 ='小说评论回复表';

View File

@ -5,7 +5,7 @@
<groupId>com.java2nb</groupId>
<artifactId>novel-admin</artifactId>
<version>4.3.0</version>
<version>5.2.2</version>
<packaging>jar</packaging>
<name>novel-admin</name>
@ -14,18 +14,14 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.18.RELEASE</version>
<version>2.7.18</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<java.version>21</java.version>
<velocity.version>1.7</velocity.version>
<activiti.version>5.22.0</activiti.version>
<sharding.jdbc.version>3.0.0</sharding.jdbc.version>
<jackson.version>2.15.1</jackson.version>
<shardingsphere-jdbc.version>5.5.1</shardingsphere-jdbc.version>
</properties>
<dependencies>
@ -60,35 +56,24 @@
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>
<!-- 请求参数校验相关 -->
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<!--mybatis -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.29</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.6</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>
<!--druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.9</version>
</dependency>
<!--commons -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
@ -138,6 +123,12 @@
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
<exclusions>
<exclusion>
<artifactId>commons-lang</artifactId>
<groupId>commons-lang</groupId>
</exclusion>
</exclusions>
</dependency>
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
@ -166,6 +157,12 @@
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
<exclusions>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
@ -195,24 +192,29 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.4</version>
<exclusions>
<exclusion>
<artifactId>commons-lang3</artifactId>
<groupId>org.apache.commons</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- ShardingSphere-JDBC -->
<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>${sharding.jdbc.version}</version>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc</artifactId>
<version>${shardingsphere-jdbc.version}</version>
</dependency>
<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-namespace</artifactId>
<version>${sharding.jdbc.version}</version>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<!--war包部署需要-->
@ -330,4 +332,35 @@
</snapshots>
</pluginRepository>
</pluginRepositories>
<profiles>
<profile>
<!-- 定义一个用于切换到中央仓库的profile -->
<id>central-repo</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central-plugin</id>
<url>https://repo.maven.apache.org/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</project>

View File

@ -1,20 +0,0 @@
#端口号
server:
port: 8088
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456
redis:
host: 127.0.0.1
port: 6379
password: test123456
sharding:
jdbc:
datasource:
ds0:
jdbc-url: jdbc:mysql://localhost:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456

View File

@ -0,0 +1,9 @@
#端口号
server:
port: 8088
spring:
redis:
host: 127.0.0.1
port: 6379
password: test123456

View File

@ -0,0 +1,47 @@
mode:
# 单机模式
type: Standalone
# 元数据持久化
repository:
# 数据库持久化
type: JDBC
# 数据源配置
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
username: root
password: test123456
# 规则配置
rules:
- !SINGLE
tables:
- "*.*"
- !SHARDING
tables: # 数据分片规则配置
book_content:
# 分库策略缺省表示使用默认分库策略
actualDataNodes: ds_${1}.book_content${0..9}
# 分表策略
tableStrategy:
standard:
# 分片列名称
shardingColumn: index_id
# 分片算法名称
shardingAlgorithmName: bookContentSharding
shardingAlgorithms:
bookContentSharding:
# 行表达式分片算法使用 Groovy 的表达式提供对 SQL 语句中的 = IN 的分片操作支持
type: INLINE
props:
# 分片算法的行表达式
algorithm-expression: book_content${index_id % 10}
props:
# 是否在日志中打印 SQL
sql-show: true

View File

@ -11,27 +11,37 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.sql.DataSource;
import java.net.InetAddress;
import java.sql.Connection;
@EnableTransactionManagement
@ServletComponentScan
@MapperScan("com.java2nb.*.dao")
@SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
})
@EnableCaching
@Slf4j
public class AdminApplication {
public static void main(String[] args) {
SpringApplication.run(AdminApplication.class, args);
}
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
public CommandLineRunner commandLineRunner(ApplicationContext ctx, DataSource dataSource) {
return args -> {
log.info("项目启动啦,访问路径:{}", "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + ctx.getEnvironment().getProperty("server.port"));
log.info("创建连接池...");
try (Connection connection = dataSource.getConnection()) {
log.info("连接池已创建.");
log.info("数据库:{}", connection.getMetaData().getDatabaseProductName());
log.info("数据库版本:{}", connection.getMetaData().getDatabaseProductVersion());
}
log.info("项目启动啦,访问路径:{}",
"http://" + InetAddress.getLocalHost().getHostAddress() + ":" + ctx.getEnvironment()
.getProperty("server.port"));
};
}
}

View File

@ -0,0 +1,13 @@
package com.java2nb.common.annotation;
import java.lang.annotation.*;
/**
* @author xiongxiaoyang
* @date 2025/7/17
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ValidateSortOrder {
}

View File

@ -0,0 +1,56 @@
package com.java2nb.common.aspect;
import com.java2nb.common.annotation.ValidateSortOrder;
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;
/**
* @author xiongxiaoyang
* @date 2025/7/17
*/
@Aspect
@Component
@RequiredArgsConstructor
public class SortOrderValidationAspect {
/**
* 拦截所有的mapper方法
*/
@SneakyThrows
@Around("execution(* com.java2nb.*.dao.*Dao.*(..))")
public Object validateSortAndOrder(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(ValidateSortOrder.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);
}
}

View File

@ -1,19 +1,16 @@
package com.java2nb.common.aspect;
import com.java2nb.common.utils.HttpContextUtils;
import com.java2nb.common.utils.IPUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import sun.net.util.IPAddressUtil;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.Arrays;
@Aspect
@ -37,11 +34,10 @@ public class WebLogAspect {
logger.info("请求地址 : " + request.getRequestURL().toString());
logger.info("HTTP METHOD : " + request.getMethod());
// 获取真实的ip地址
//logger.info("IP : " + IPAddressUtil.getClientIpAddress(request));
logger.info("IP : " + IPUtils.getIpAddr(request));
logger.info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "."
+ joinPoint.getSignature().getName());
+ joinPoint.getSignature().getName());
logger.info("参数 : " + Arrays.toString(joinPoint.getArgs()));
// loggger.info("参数 : " + joinPoint.getArgs());
}

View File

@ -1,132 +0,0 @@
package com.java2nb.common.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.sql.DataSource;
import java.sql.SQLException;
/**
* Created by PrimaryKey on 17/2/4.
*/
@SuppressWarnings("AlibabaRemoveCommentedCode")
@Configuration
public class DruidDBConfig {
private Logger logger = LoggerFactory.getLogger(DruidDBConfig.class);
@Value("${spring.datasource.url}")
private String dbUrl;
@Value("${spring.datasource.username}")
private String username;
@Value("${spring.datasource.password}")
private String password;
@Value("${spring.datasource.driverClassName}")
private String driverClassName;
@Value("${spring.datasource.initialSize}")
private int initialSize;
@Value("${spring.datasource.minIdle}")
private int minIdle;
@Value("${spring.datasource.maxActive}")
private int maxActive;
@Value("${spring.datasource.maxWait}")
private int maxWait;
@Value("${spring.datasource.timeBetweenEvictionRunsMillis}")
private int timeBetweenEvictionRunsMillis;
@Value("${spring.datasource.minEvictableIdleTimeMillis}")
private int minEvictableIdleTimeMillis;
@Value("${spring.datasource.validationQuery}")
private String validationQuery;
@Value("${spring.datasource.testWhileIdle}")
private boolean testWhileIdle;
@Value("${spring.datasource.testOnBorrow}")
private boolean testOnBorrow;
@Value("${spring.datasource.testOnReturn}")
private boolean testOnReturn;
@Value("${spring.datasource.poolPreparedStatements}")
private boolean poolPreparedStatements;
@Value("${spring.datasource.maxPoolPreparedStatementPerConnectionSize}")
private int maxPoolPreparedStatementPerConnectionSize;
@Value("${spring.datasource.filters}")
private String filters;
@Value("{spring.datasource.connectionProperties}")
private String connectionProperties;
@Bean(initMethod = "init", destroyMethod = "close") //声明其为Bean实例
@Primary //在同样的DataSource中首先使用被标注的DataSource
public DataSource dataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(this.dbUrl);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
//configuration
datasource.setInitialSize(initialSize);
datasource.setMinIdle(minIdle);
datasource.setMaxActive(maxActive);
datasource.setMaxWait(maxWait);
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
datasource.setValidationQuery(validationQuery);
datasource.setTestWhileIdle(testWhileIdle);
datasource.setTestOnBorrow(testOnBorrow);
datasource.setTestOnReturn(testOnReturn);
datasource.setPoolPreparedStatements(poolPreparedStatements);
datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
try {
datasource.setFilters(filters);
} catch (SQLException e) {
logger.error("druid configuration initialization filter", e);
}
datasource.setConnectionProperties(connectionProperties);
return datasource;
}
@Bean
public ServletRegistrationBean druidServlet() {
ServletRegistrationBean reg = new ServletRegistrationBean();
reg.setServlet(new StatViewServlet());
reg.addUrlMappings("/druid/*");
reg.addInitParameter("allow", ""); //白名单
return reg;
}
@Bean public FilterRegistrationBean filterRegistrationBean() {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
filterRegistrationBean.setFilter(new WebStatFilter());
filterRegistrationBean.addUrlPatterns("/*");
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
filterRegistrationBean.addInitParameter("profileEnable", "true");
filterRegistrationBean.addInitParameter("principalCookieName","USER_COOKIE");
filterRegistrationBean.addInitParameter("principalSessionName","USER_SESSION");
filterRegistrationBean.addInitParameter("DruidWebStatFilter","/*");
return filterRegistrationBean;
}
}

View File

@ -1,48 +0,0 @@
package com.java2nb.common.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* ${DESCRIPTION}
*
* @author xiongxy
* @create 2019-11-02 23:53
*/
@EnableSwagger2
@Configuration
public class Swagger2Config {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//为当前包路径
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
//构建 api文档的详细信息函数
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
//页面标题
.title("功能测试")
//创建人
.contact(new Contact("xiongxy", "1179705413@qq.com", "1179705413@qq.com"))
//版本号
.version("1.0")
//描述
.description("API 描述")
.build();
}
}

View File

@ -1,5 +1,6 @@
package com.java2nb.common.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String, Object> map);
int count(Map<String, Object> map);

View File

@ -1,5 +1,6 @@
package com.java2nb.common.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -3,6 +3,7 @@ package com.java2nb.common.dao;
import java.util.List;
import java.util.Map;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -9,25 +9,25 @@ import java.util.Map;
public interface GeneratorMapper {
@Select(
"select table_name tableName, engine, table_comment tableComment, create_time createTime from information_schema.tables"
"select table_name tableName, engine, table_comment tableComment, create_time createTime from tables"
+ " where table_schema = 'novel_plus' and table_name like concat('%',#{tableName},'%')")
List<Map<String, Object>> list(@Param("tableName") String tableName);
@Select("select count(*) from information_schema.tables where table_schema = 'novel_plus'")
@Select("select count(*) from tables where table_schema = 'novel_plus'")
int count(Map<String, Object> map);
@Select(
"select table_name tableName, engine, table_comment tableComment, create_time createTime from information_schema.tables \r\n"
"select table_name tableName, engine, table_comment tableComment, create_time createTime from tables \r\n"
+ " where table_schema = 'novel_plus' and table_name = #{tableName}")
Map<String, String> get(String tableName);
@Select(
"select column_name columnName, data_type dataType, column_comment columnComment, column_key columnKey, extra from information_schema.columns\r\n"
"select column_name columnName, data_type dataType, column_comment columnComment, column_key columnKey, extra from columns\r\n"
+ " where table_name = #{tableName} and table_schema = 'novel_plus' order by ordinal_position")
List<Map<String, String>> listColumns(String tableName);
@Select(
"select column_name columnName, data_type dataType, column_comment columnComment, column_key columnKey, extra from information_schema.columns\r\n"
"select column_name columnName, data_type dataType, column_comment columnComment, column_key columnKey, extra from columns\r\n"
+ " where table_name = #{tableName} and table_schema = 'novel_plus' and column_key = 'PRI' limit 1")
Map<String, String> getPriColumn(String tableName);
}

View File

@ -1,5 +1,6 @@
package com.java2nb.common.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -2,32 +2,27 @@ package com.java2nb.common.exception;
import com.java2nb.common.utils.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
@RestController
public class MainsiteErrorController implements ErrorController {
private Logger logger = LoggerFactory.getLogger(getClass());
private static final String ERROR_PATH = "/error";
@Autowired
ErrorAttributes errorAttributes;
@RequestMapping(
value = {ERROR_PATH},
produces = {"text/html"}
value = {ERROR_PATH},
produces = {"text/html"}
)
public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) {
int code = response.getStatus();
@ -58,9 +53,4 @@ public class MainsiteErrorController implements ErrorController {
}
}
@Override
public String getErrorPath() {
// TODO Auto-generated method stub
return ERROR_PATH;
}
}

View File

@ -1,6 +1,5 @@
package com.java2nb.common.utils;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@ -8,79 +7,80 @@ import java.util.HashMap;
import java.util.Map;
public class JSONUtils {
/**
* Bean对象转JSON
*
* @param object
* @param dataFormatString
* @return
*/
public static String beanToJson(Object object, String dataFormatString) {
if (object != null) {
if (StringUtils.isEmpty(dataFormatString)) {
return JSONObject.toJSONString(object);
}
return JSON.toJSONStringWithDateFormat(object, dataFormatString);
} else {
return null;
}
}
/**
* Bean对象转JSON
*
* @param object
* @return
*/
public static String beanToJson(Object object) {
if (object != null) {
return JSON.toJSONString(object);
} else {
return null;
}
}
/**
* Bean对象转JSON
*
* @param object
* @param dataFormatString
* @return
*/
public static String beanToJson(Object object, String dataFormatString) {
if (object != null) {
if (StringUtils.isEmpty(dataFormatString)) {
return JSONObject.toJSONString(object);
}
return JSON.toJSONStringWithDateFormat(object, dataFormatString);
} else {
return null;
}
}
/**
* String转JSON字符串
*
* @param key
* @param value
* @return
*/
public static String stringToJsonByFastjson(String key, String value) {
if (StringUtils.isEmpty(key) || StringUtils.isEmpty(value)) {
return null;
}
Map<String, String> map = new HashMap<String, String>(16);
map.put(key, value);
return beanToJson(map, null);
}
/**
* Bean对象转JSON
*
* @param object
* @return
*/
public static String beanToJson(Object object) {
if (object != null) {
return JSON.toJSONString(object);
} else {
return null;
}
}
/**
* 将json字符串转换成对象
*
* @param json
* @param clazz
* @return
*/
public static Object jsonToBean(String json, Object clazz) {
if (StringUtils.isEmpty(json) || clazz == null) {
return null;
}
return JSON.parseObject(json, clazz.getClass());
}
/**
* String转JSON字符串
*
* @param key
* @param value
* @return
*/
public static String stringToJsonByFastjson(String key, String value) {
if (StringUtils.isEmpty(key) || StringUtils.isEmpty(value)) {
return null;
}
Map<String, String> map = new HashMap<String, String>(16);
map.put(key, value);
return beanToJson(map, null);
}
/**
* json字符串转map
*
* @param json
* @return
*/
@SuppressWarnings("unchecked")
public static Map<String, Object> jsonToMap(String json) {
if (StringUtils.isEmpty(json)) {
return null;
}
return JSON.parseObject(json, Map.class);
}
/**
* json字符串转换成对象
*
* @param json
* @param clazz
* @return
*/
public static Object jsonToBean(String json, Object clazz) {
if (StringUtils.isEmpty(json) || clazz == null) {
return null;
}
return JSON.parseObject(json, clazz.getClass());
}
/**
* json字符串转map
*
* @param json
* @return
*/
@SuppressWarnings("unchecked")
public static Map<String, Object> jsonToMap(String json) {
if (StringUtils.isEmpty(json)) {
return null;
}
return JSON.parseObject(json, Map.class);
}
}

View File

@ -0,0 +1,28 @@
package com.java2nb.common.utils;
import lombok.experimental.UtilityClass;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* @author xiongxiaoyang
* @date 2025/7/17
*/
@UtilityClass
public class SortWhitelistUtil {
private final Set<String> allowedColumns = new HashSet<>(
Arrays.asList("id", "name", "create_time", "update_time", "order_num", "last_index_update_time", "word_count",
"visit_count"));
private final Set<String> allowedOrders = new HashSet<>(Arrays.asList("asc", "desc"));
public String sanitizeColumn(String input) {
return allowedColumns.contains(input.toLowerCase()) ? input.toLowerCase() : "id";
}
public String sanitizeOrder(String input) {
return allowedOrders.contains(input.toLowerCase()) ? input.toLowerCase() : "asc";
}
}

View File

@ -1,5 +1,7 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,6 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
import com.java2nb.novel.domain.BookContentDO;
import org.apache.ibatis.annotations.Mapper;
@ -18,7 +20,7 @@ public interface BookContentDao {
BookContentDO get(Long id);
List<BookContentDO> list(Map<String, Object> map);
List<BookContentDO> list(@ValidateSortOrder Map<String, Object> map);
int count(Map<String, Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String, Object> map);
int count(Map<String, Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String, Object> map);
int count(Map<String, Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String, Object> map);
int count(Map<String, Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.novel.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.system.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.system.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.system.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.system.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.system.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.system.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.system.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
import com.java2nb.system.domain.UserDO;
import java.util.List;
@ -19,7 +21,7 @@ public interface SysUserDao {
UserDO get(Long userId);
List<UserDO> list(Map<String,Object> map);
List<UserDO> list(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -1,5 +1,7 @@
package com.java2nb.system.dao;
import com.java2nb.common.annotation.ValidateSortOrder;
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(@ValidateSortOrder Map<String, Object> map);
int count(Map<String, Object> map);

View File

@ -7,92 +7,11 @@ logging:
root: info
com.java2nb: debug
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: test123456
#password:
initialSize: 1
minIdle: 3
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测检测需要关闭的空闲连接单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间单位是毫秒
minEvictableIdleTimeMillis: 30000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# 打开PSCache并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
# 配置监控统计拦截的filters去掉后监控界面sql无法统计'wall'用于防火墙
filters: stat,slf4j
# 通过connectProperties属性来打开mergeSql功能慢SQL记录
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
# 合并多个DruidDataSource的监控数据
#useGlobalDataSourceStat: true
redis:
host: 127.0.0.1
port: 6379
password: test123456
# 连接超时时间毫秒
timeout: 10000
jedis:
pool:
# 连接池中的最大空闲连接
max-idle: 8
# 连接池中的最小空闲连接
min-idle: 10
# 连接池最大连接数使用负值表示没有限制
max-active: 100
# 连接池最大阻塞等待时间使用负值表示没有限制
max-wait: -1
####使用shardingJdbc时
####所有的jdbcType都不能是LONGVARCHAR,否则会导致java.io.NotSerializableException: java.io.StringReader错误
##### 应该替换所有的 LONGVARCHAR 类型为VARCHAR
sharding:
jdbc:
datasource:
names: ds0,ds1
ds0:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456
ds1:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/information_schema?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456
config:
sharding:
props:
sql.show: true
tables:
book_content: #book_content表
key-generator-column-name: id #主键
actual-data-nodes: ds${0}.book_content${0..9} #数据节点
# database-strategy: #分库策略
# inline:
# sharding-column: book_id
# algorithm-expression: ds${book_id % 10}
table-strategy: #分表策略
inline:
shardingColumn: index_id
algorithm-expression: book_content${index_id % 10}
tables:
actual-data-nodes: ds${1}.tables
columns:
actual-data-nodes: ds${1}.columns
default-data-source-name: ds0

View File

@ -7,86 +7,11 @@ logging:
root: error
com.java2nb: error
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: test123456
#password:
initialSize: 1
minIdle: 3
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测检测需要关闭的空闲连接单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间单位是毫秒
minEvictableIdleTimeMillis: 30000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# 打开PSCache并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
# 配置监控统计拦截的filters去掉后监控界面sql无法统计'wall'用于防火墙
filters: stat,slf4j
# 通过connectProperties属性来打开mergeSql功能慢SQL记录
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
# 合并多个DruidDataSource的监控数据
#useGlobalDataSourceStat: true
redis:
host: 127.0.0.1
port: 6379
password: test
password: test123456
# 连接超时时间毫秒
timeout: 10000
jedis:
pool:
# 连接池中的最大空闲连接
max-idle: 8
# 连接池中的最小空闲连接
min-idle: 10
# 连接池最大连接数使用负值表示没有限制
max-active: 100
# 连接池最大阻塞等待时间使用负值表示没有限制
max-wait: -1
####使用shardingJdbc时
####所有的jdbcType都不能是LONGVARCHAR,否则会导致java.io.NotSerializableException: java.io.StringReader错误
##### 应该替换所有的 LONGVARCHAR 类型为VARCHAR
sharding:
jdbc:
datasource:
names: ds0 #,ds1
ds0:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456
# ds1:
# type: com.alibaba.druid.pool.DruidDataSource
# driver-class-name: com.mysql.jdbc.Driver
# url: jdbc:mysql://localhost:3306/novel_plus2
# username: root
# password: test123456
config:
sharding:
props:
sql.show: true
tables:
book_content: #book_content表
key-generator-column-name: id #主键
actual-data-nodes: ds${0}.book_content${0..9} #数据节点
# database-strategy: #分库策略
# inline:
# sharding-column: book_id
# algorithm-expression: ds${book_id % 10}
table-strategy: #分表策略
inline:
shardingColumn: index_id
algorithm-expression: book_content${index_id % 10}

View File

@ -9,6 +9,9 @@ server:
# basic:
# enabled: false
spring:
datasource:
driverClassName: org.apache.shardingsphere.driver.ShardingSphereDriver
url: jdbc:shardingsphere:absolutepath:${user.dir}/config/shardingsphere-jdbc.yml
thymeleaf:
mode: LEGACYHTML5
cache: false
@ -23,10 +26,7 @@ spring:
multipart:
max-file-size: 100MB
max-request-size: 100MB
devtools:
restart:
enabled: true
main:
allow-bean-definition-overriding: true
@ -36,9 +36,6 @@ mybatis:
map-underscore-to-camel-case: true
mapper-locations: mybatis/**/*Mapper.xml
typeAliasesPackage: com.java2nb.**.domain
#[弃用]配置缓存和session存储方式默认ehcache,可选redis,[弃用]调整至 spring cache typeshiro.用户权限sessionspring.cache通用
#[弃用]cacheType: ehcache
logging:
config: classpath:logback-boot.xml

View File

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 162 KiB

View File

@ -79,7 +79,7 @@ function update() {
},
success: function (data) {
if (data.code == 0) {
layer.msg("操作成功");
layer.msg("操作成功,重启 novel-front 后生效");
} else {
layer.alert(data.msg)
}

View File

@ -6,7 +6,7 @@
<title>小说精品屋 - 文件管理器</title>
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="shortcut icon" href="favicon.ico">
<link rel="shortcut icon" href="/favicon.ico">
<link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="/css/animate.css" rel="stylesheet">

View File

@ -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(@ValidateSortOrder Map<String,Object> map);
int count(Map<String,Object> map);

View File

@ -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(@ValidateSortOrder Map<String,Object> map);
@Select("<script>" +
"select count(*) from ${tableName} " +

View File

@ -6,7 +6,7 @@
<title>403 页面</title>
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="shortcut icon" href="favicon.ico">
<link rel="shortcut icon" href="/favicon.ico">
<link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="/css/animate.css" rel="stylesheet">

View File

@ -10,7 +10,7 @@
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="shortcut icon" href="favicon.ico"> <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link rel="shortcut icon" href="/favicon.ico"> <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="/css/animate.css" rel="stylesheet">

View File

@ -11,7 +11,7 @@
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="shortcut icon" href="favicon.ico"> <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link rel="shortcut icon" href="/favicon.ico"> <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="/css/animate.css" rel="stylesheet">

View File

@ -6,7 +6,7 @@
<title>500错误</title>
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="shortcut icon" href="favicon.ico"> <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link rel="shortcut icon" href="/favicon.ico"> <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="/css/animate.css" rel="stylesheet">
<link href="/css/style.css?v=4.1.0" rel="stylesheet">

View File

@ -4,7 +4,7 @@
<title></title>
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="shortcut icon" href="favicon.ico">
<link rel="shortcut icon" href="/favicon.ico">
<link href="css/bootstrap.min.css?v=3.3.6"
th:href="@{/css/bootstrap.min.css?v=3.3.6}" rel="stylesheet">
<link href="/css/font-awesome.css?v=4.4.0"

View File

@ -10,7 +10,7 @@
<!--[if lt IE 9]>
<meta http-equiv="refresh" content="0;ie.html"/>
<![endif]-->
<link rel="shortcut icon" href="favicon.ico">
<link rel="shortcut icon" href="/favicon.ico">
<link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<link href="/css/plugins/toastr/toastr.min.css" rel="stylesheet">

View File

@ -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">

View File

@ -11,7 +11,7 @@
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="shortcut icon" href="favicon.ico">
<link rel="shortcut icon" href="/favicon.ico">
<link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="/css/animate.css" rel="stylesheet">

View File

@ -4,7 +4,7 @@
<title></title>
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="shortcut icon" href="favicon.ico">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="stylesheet" href="/css/bootstrap.min.css" />
<link rel="stylesheet" href="/css/animate.css" />
<link rel="stylesheet" href="/css/font-awesome.css" />

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>novel</artifactId>
<groupId>com.java2nb</groupId>
<version>4.3.0</version>
<version>5.2.2</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>
@ -52,18 +58,16 @@
</dependency>
<!-- 分库分表-->
<!-- sharding jdbc依赖 -->
<!-- ShardingSphere-JDBC -->
<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>${sharding.jdbc.version}</version>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc</artifactId>
<version>${shardingsphere-jdbc.version}</version>
</dependency>
<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-namespace</artifactId>
<version>${sharding.jdbc.version}</version>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
@ -73,11 +77,6 @@
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.version}</version>
</dependency>
<dependency>
<groupId>com.cuisongliu</groupId>
<artifactId>orderbyhelper-spring-boot-starter</artifactId>
<version>${orderbyhelper.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
@ -86,15 +85,8 @@
</dependency>
<!--httpclient-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
<dependency>
@ -117,6 +109,12 @@
<optional>true</optional>
</dependency>
<!-- 请求参数校验相关 -->
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>io.github.xxyopen</groupId>
<artifactId>xxy-model</artifactId>
@ -138,5 +136,29 @@
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<zip destfile='${project.build.directory}/build/sql.zip'>
<zipfileset filemode="755" dir='${basedir}/../doc/sql'/>
</zip>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,55 @@
package com.java2nb.novel.core.advice;
import io.github.xxyopen.model.resp.RestResult;
import io.github.xxyopen.model.resp.SysResultCode;
import io.github.xxyopen.web.exception.BusinessException;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.ModelAndView;
/**
* 统一异常处理器
*
* @author xiongxiaoyang
*/
@Slf4j
@RestControllerAdvice
public class CommonExceptionHandler {
public CommonExceptionHandler() {
}
@ExceptionHandler({BindException.class})
public RestResult<Void> handlerBindException(BindException e) {
log.error(e.getMessage(), e);
return RestResult.fail(SysResultCode.PARAM_ERROR);
}
@ExceptionHandler({BusinessException.class})
public RestResult<Void> handlerBusinessException(BusinessException e) {
log.error(e.getMessage(), e);
return RestResult.fail(e.getResultCode());
}
@ExceptionHandler(Exception.class)
public Object handleException(HttpServletRequest request, Exception e) {
log.error(e.getMessage(), e);
if (isJsonRequest(request)) {
// 如果是REST请求返回JSON格式的错误响应
return RestResult.error();
} else {
//跳转页面过程中出现异常时统一跳转到404页面
return new ModelAndView("404");
}
}
private boolean isJsonRequest(HttpServletRequest request) {
String acceptHeader = request.getHeader("Accept");
return acceptHeader != null && acceptHeader.contains(MediaType.APPLICATION_JSON_VALUE);
}
}

View File

@ -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;
}
}
}

View File

@ -1,26 +0,0 @@
package com.java2nb.novel.core.advice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
/**
* 页面异常处理器
*
* @author 11797
*/
@Slf4j
@ControllerAdvice(basePackages = "com.java2nb.novel.controller.page")
public class PageExceptionHandler {
/**
* 处理所有异常
*/
@ExceptionHandler(Exception.class)
public String handlerException(Exception e) {
log.error(e.getMessage(), e);
//跳转页面过程中出现异常时统一跳转到404页面
return "404";
}
}

View File

@ -0,0 +1,13 @@
package com.java2nb.novel.core.annotation;
import java.lang.annotation.*;
/**
* @author xiongxiaoyang
* @date 2025/7/17
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ValidateSortOrder {
}

View File

@ -0,0 +1,101 @@
package com.java2nb.novel.core.aspect;
import com.java2nb.novel.core.annotation.ValidateSortOrder;
import com.java2nb.novel.core.utils.SortWhitelistUtil;
import com.java2nb.novel.core.vo.SortOrderVO;
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.Field;
import java.lang.reflect.Method;
import java.util.*;
/**
* @author xiongxiaoyang
* @date 2025/7/17
*/
@Aspect
@Component
@RequiredArgsConstructor
public class SortOrderValidationAspect {
/**
* 拦截所有的mapper方法
*/
@SneakyThrows
@Around("execution(* com.java2nb.novel.mapper.*Mapper.*(..))")
public Object processSortOrderFields(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(ValidateSortOrder.class));
if (hasAnnotation && args[i] != null) {
handleAnnotatedParameter(args[i]);
}
}
return joinPoint.proceed(args);
}
@SneakyThrows
private void handleAnnotatedParameter(Object obj) {
if (obj instanceof SortOrderVO sortOrderVO){
processSortOrderVO(sortOrderVO);
} else if (obj instanceof Map<?, ?> map) {
processMap(map);
} else {
processGenericObject(obj);
}
}
private void processSortOrderVO(SortOrderVO sortOrderVO) {
if(sortOrderVO.getSort() != null){
sortOrderVO.setSort(SortWhitelistUtil.sanitizeColumn(sortOrderVO.getSort()));
}
if(sortOrderVO.getOrder() != null){
sortOrderVO.setOrder(SortWhitelistUtil.sanitizeOrder(sortOrderVO.getOrder()));
}
}
private void processMap(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));
}
}
@SneakyThrows
private void processGenericObject(Object obj) {
for (Field field : obj.getClass().getDeclaredFields()) {
switch (field.getName()) {
case "sort", "order" -> {
field.setAccessible(true);
Object value = field.get(obj);
if (value instanceof String strValue) {
String sanitized = "sort".equals(field.getName())
? SortWhitelistUtil.sanitizeColumn(strValue)
: SortWhitelistUtil.sanitizeOrder(strValue);
field.set(obj, sanitized);
}
}
default -> {
}
}
}
}
}

View File

@ -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";
}

View File

@ -19,4 +19,8 @@ public class HttpProxyProperties {
private Integer port;
private String username;
private String password;
}

View File

@ -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,"手机号或密码错误!"),

View File

@ -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));

View File

@ -5,7 +5,7 @@ import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.Charsets;
import org.apache.http.client.utils.DateUtils;
import org.apache.hc.client5.http.utils.DateUtils;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@ -14,7 +14,15 @@ import org.springframework.http.ResponseEntity;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
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;
@ -37,10 +45,13 @@ public class FileUtil {
//本地图片保存
HttpHeaders headers = new HttpHeaders();
HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
ResponseEntity<Resource> resEntity = RestTemplateUtil.getInstance(Charsets.ISO_8859_1.name()).exchange(picSrc, HttpMethod.GET, requestEntity, Resource.class);
ResponseEntity<Resource> resEntity = RestTemplates.newInstance(Charsets.ISO_8859_1.name())
.exchange(picSrc, HttpMethod.GET, requestEntity, Resource.class);
input = Objects.requireNonNull(resEntity.getBody()).getInputStream();
Date currentDate = new Date();
picSrc = visitPrefix + DateUtils.formatDate(currentDate, "yyyy") + "/" + DateUtils.formatDate(currentDate, "MM") + "/" + DateUtils.formatDate(currentDate, "dd") + "/"
picSrc =
visitPrefix + DateUtils.formatDate(currentDate, "yyyy") + "/" + DateUtils.formatDate(currentDate, "MM")
+ "/" + DateUtils.formatDate(currentDate, "dd") + "/"
+ UUIDUtil.getUUID32()
+ picSrc.substring(picSrc.lastIndexOf("."));
File picFile = new File(picSavePath + picSrc);
@ -67,7 +78,6 @@ public class FileUtil {
closeStream(input, out);
}
return picSrc;
}
@ -120,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);
}
}
}

View File

@ -1,47 +1,52 @@
package com.java2nb.novel.core.utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.*;
import org.springframework.web.client.RestTemplate;
import java.nio.charset.Charset;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author Administrator
*/
@Slf4j
public class HttpUtil {
private static RestTemplate restTemplate = RestTemplateUtil.getInstance("utf-8");
private static final String DEFAULT_CHARSET = "utf-8";
private static final Map<String, RestTemplate> REST_TEMPLATE_MAP = new ConcurrentHashMap<>();
public static String getByHttpClient(String url) {
public static String getByHttpClientWithChrome(String url, String charset) {
log.debug("Get url{}", url);
if (!Charset.isSupported(charset)) {
log.error("字符编码{}无效!", charset);
return null;
}
RestTemplate restTemplate = REST_TEMPLATE_MAP.computeIfAbsent(charset,
k -> RestTemplates.newInstance(charset));
try {
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);
HttpHeaders headers = new HttpHeaders();
headers.add("user-agent",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36");
HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
ResponseEntity<String> forEntity = restTemplate.exchange(url, HttpMethod.GET, requestEntity,
String.class);
log.debug("Response code{}", forEntity.getStatusCode());
if (forEntity.getStatusCode() == HttpStatus.OK) {
return forEntity.getBody();
} else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
return null;
}
}
public static String getByHttpClientWithChrome(String url) {
try {
HttpHeaders headers = new HttpHeaders();
headers.add("user-agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36");
HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
ResponseEntity<String> forEntity = restTemplate.exchange(url.toString(), HttpMethod.GET, requestEntity, String.class);
if (forEntity.getStatusCode() == HttpStatus.OK) {
return forEntity.getBody();
} else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return getByHttpClientWithChrome(url, DEFAULT_CHARSET);
}
}

View File

@ -1,11 +1,21 @@
package com.java2nb.novel.core.utils;
import javax.servlet.http.HttpServletRequest;
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;
}
}

View File

@ -2,17 +2,22 @@ package com.java2nb.novel.core.utils;
import com.java2nb.novel.core.config.HttpProxyProperties;
import lombok.SneakyThrows;
import org.apache.http.HttpHost;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.commons.lang3.StringUtils;
import org.apache.hc.client5.http.auth.AuthScope;
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.config.Registry;
import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.hc.core5.ssl.SSLContexts;
import org.apache.hc.core5.ssl.TrustStrategy;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
@ -26,21 +31,21 @@ import java.util.List;
import java.util.Objects;
@Component
public class RestTemplateUtil {
public class RestTemplates {
private static HttpProxyProperties httpProxyProperties;
RestTemplateUtil(HttpProxyProperties properties) {
RestTemplates(HttpProxyProperties properties) {
httpProxyProperties = properties;
}
@SneakyThrows
public static RestTemplate getInstance(String charset) {
public static RestTemplate newInstance(String charset) {
TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
//忽略证书
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom()
SSLContext sslContext = SSLContexts.custom()
.loadTrustMaterial(null, acceptingTrustStrategy)
.build();
@ -61,6 +66,15 @@ public class RestTemplateUtil {
if (Objects.nonNull(httpProxyProperties) && Boolean.TRUE.equals(httpProxyProperties.getEnabled())) {
HttpHost proxy = new HttpHost(httpProxyProperties.getIp(), httpProxyProperties.getPort());
clientBuilder.setProxy(proxy);
if (StringUtils.isNotBlank(httpProxyProperties.getUsername()) && StringUtils.isNotBlank(
httpProxyProperties.getPassword())) {
// 创建CredentialsProvider实例并添加代理认证信息
BasicCredentialsProvider provider = new BasicCredentialsProvider();
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(
httpProxyProperties.getUsername(), httpProxyProperties.getPassword().toCharArray());
provider.setCredentials(new AuthScope(null, -1), credentials);
clientBuilder.setDefaultCredentialsProvider(provider);
}
}
CloseableHttpClient httpClient = clientBuilder.setConnectionManager(connectionManager)
.build();

View File

@ -0,0 +1,28 @@
package com.java2nb.novel.core.utils;
import lombok.experimental.UtilityClass;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* @author xiongxiaoyang
* @date 2025/7/17
*/
@UtilityClass
public class SortWhitelistUtil {
private final Set<String> allowedColumns = new HashSet<>(
Arrays.asList("id", "name", "create_time", "update_time", "last_index_update_time", "word_count",
"visit_count"));
private final Set<String> allowedOrders = new HashSet<>(Arrays.asList("asc", "desc"));
public String sanitizeColumn(String input) {
return allowedColumns.contains(input.toLowerCase()) ? input.toLowerCase() : "id";
}
public String sanitizeOrder(String input) {
return allowedOrders.contains(input.toLowerCase()) ? input.toLowerCase() : "asc";
}
}

View File

@ -0,0 +1,37 @@
package com.java2nb.novel.core.utils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class SpringUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext;
public SpringUtil() {
}
public void setApplicationContext(ApplicationContext applicationContext) {
if (SpringUtil.applicationContext == null) {
SpringUtil.applicationContext = applicationContext;
}
}
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
public static Object getBean(String name) {
return getApplicationContext().getBean(name);
}
public static <T> T getBean(Class<T> clazz) {
return (T)getApplicationContext().getBean(clazz);
}
public static <T> T getBean(String name, Class<T> clazz) {
return (T)getApplicationContext().getBean(name, clazz);
}
}

View File

@ -0,0 +1,16 @@
package com.java2nb.novel.core.vo;
import lombok.Data;
/**
* @author xiongxiaoyang
* @date 2025/7/17
*/
@Data
public class SortOrderVO {
private String sort;
private String order;
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;

View File

@ -2,9 +2,9 @@ package com.java2nb.novel.entity;
import io.github.xxyopen.web.valid.AddGroup;
import io.github.xxyopen.web.valid.UpdateGroup;
import jakarta.validation.constraints.*;
import javax.annotation.Generated;
import javax.validation.constraints.*;
import java.util.Date;
public class User {

View File

@ -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);

View File

@ -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)

View File

@ -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");
}
}
}

View File

@ -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))
);
}
}

View File

@ -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() {

View File

@ -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))
);
}
}

View File

@ -1,71 +1,18 @@
spring:
profiles:
include: [ common ]
config:
import: classpath:application-common.yml
main:
allow-bean-definition-overriding: true
#Redis服务器IP
redis:
host: 127.0.0.1
#Redis服务器连接端口
port: 6379
#Redis服务器连接密码
password: test123456
jedis:
pool:
#连接池最大连接数使用负值表示没有限制
max-active: 8
#连接池最大阻塞等待时间使用负值表示没有限制
max-wait: 1
#连接池最大阻塞等待时间使用负值表示没有限制
max-idle: 8
#连接池中的最小空闲连接
min-idle: 0
#连接超时时间毫秒
timeout: 30000
datasource:
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456
driver-class-name: com.mysql.cj.jdbc.Driver
####使用shardingJdbc时
####所有的jdbcType都不能是LONGVARCHAR,否则会导致java.io.NotSerializableException: java.io.StringReader错误
##### 应该替换所有的 LONGVARCHAR 类型为VARCHAR
sharding:
jdbc:
datasource:
names: ds0 #,ds1
ds0:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456
# ds1:
# type: com.alibaba.druid.pool.DruidDataSource
# driver-class-name: com.mysql.jdbc.Driver
# url: jdbc:mysql://localhost:3306/novel_plus2
# username: root
# password: test123456
config:
sharding:
props:
sql.show: true
tables:
book_content: #book_content表
key-generator-column-name: id #主键
actual-data-nodes: ds${0}.book_content${0..9} #数据节点
# database-strategy: #分库策略
# inline:
# sharding-column: book_id
# algorithm-expression: ds${book_id % 10}
table-strategy: #分表策略
inline:
shardingColumn: index_id
algorithm-expression: book_content${index_id % 10}
data:
redis:
host: 127.0.0.1
#Redis服务器连接端口
port: 6379
#Redis服务器连接密码
password: test123456
#连接超时时间毫秒
timeout: 10000
content:
save:
@ -78,6 +25,10 @@ http:
# 是否开启 HTTP 代理true-开启false-不开启
enabled: false
# 代理 IP
ip: u493.kdltps.com
ip: us.swiftproxy.net
# 代理端口号
port: 15818
port: 7878
# 代理用户名
username: swiftproxy_u
# 代理密码
password: swiftproxy_p

View File

@ -1,71 +1,18 @@
spring:
profiles:
include: [ common ]
config:
import: classpath:application-common.yml
main:
allow-bean-definition-overriding: true
#Redis服务器IP
redis:
host: 127.0.0.1
#Redis服务器连接端口
port: 6379
#Redis服务器连接密码
password: test
jedis:
pool:
#连接池最大连接数使用负值表示没有限制
max-active: 8
#连接池最大阻塞等待时间使用负值表示没有限制
max-wait: 1
#连接池最大阻塞等待时间使用负值表示没有限制
max-idle: 8
#连接池中的最小空闲连接
min-idle: 0
#连接超时时间毫秒
timeout: 30000
datasource:
url: jdbc:mysql://127.0.0.1:3306/novel_biz?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456
driver-class-name: com.mysql.cj.jdbc.Driver
####使用shardingJdbc时
####所有的jdbcType都不能是LONGVARCHAR,否则会导致java.io.NotSerializableException: java.io.StringReader错误
##### 应该替换所有的 LONGVARCHAR 类型为VARCHAR
sharding:
jdbc:
datasource:
names: ds0 #,ds1
ds0:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456
# ds1:
# type: com.alibaba.druid.pool.DruidDataSource
# driver-class-name: com.mysql.jdbc.Driver
# url: jdbc:mysql://localhost:3306/novel_plus2
# username: root
# password: test123456
config:
sharding:
props:
sql.show: true
tables:
book_content: #book_content表
key-generator-column-name: id #主键
actual-data-nodes: ds${0}.book_content${0..9} #数据节点
# database-strategy: #分库策略
# inline:
# sharding-column: book_id
# algorithm-expression: ds${book_id % 10}
table-strategy: #分表策略
inline:
shardingColumn: index_id
algorithm-expression: book_content${index_id % 10}
data:
redis:
#Redis服务器IP
host: 127.0.0.1
#Redis服务器连接端口
port: 6379
#Redis服务器连接密码
password: test123456
#连接超时时间毫秒
timeout: 10000
logging:
level:

View File

@ -1,16 +1,11 @@
spring:
cache:
ehcache:
config: classpath:ehcache.xml
datasource:
url: jdbc:shardingsphere:absolutepath:${user.dir}/config/shardingsphere-jdbc.yml
driver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriver
thymeleaf:
mode: LEGACYHTML5 #去除thymeleaf的html严格校验thymeleaf.mode=LEGACYHTML5
cache: false # 是否开启模板缓存默认true,建议在开发时关闭缓存,不然没法看到实时
# 将所有数字转为 String 类型返回避免前端数据精度丢失的问题
jackson:
generator:
write-numbers-as-strings: true
#上传文件的最大值100M
servlet:
multipart:
@ -27,6 +22,8 @@ mybatis:
logging:
config: classpath:logback-boot.xml
pagehelper:
helper-dialect: mysql

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>novel</artifactId>
<groupId>com.java2nb</groupId>
<version>4.3.0</version>
<version>5.2.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -21,6 +21,12 @@
<artifactId>novel-common</artifactId>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
@ -29,7 +35,6 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>

View File

@ -1,53 +0,0 @@
#端口号
server:
port: 8083
#不分表的数据库配置
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
redis:
host: 127.0.0.1
port: 6379
password: test123456
####使用shardingJdbc时
####所有的jdbcType都不能是LONGVARCHAR,否则会导致java.io.NotSerializableException: java.io.StringReader错误
##### 应该替换所有的 LONGVARCHAR 类型为VARCHAR
sharding:
jdbc:
datasource:
ds0:
jdbc-url: jdbc:mysql://localhost:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456
#登录用户名密码
admin:
username: admin
password: admin
#
##爬虫自动更新的线程数
##建议小说数量不多或者正在运行新书入库爬虫的情况下设置为1即可
##随着小说数量的增多可以逐渐增加但建议不要超出CPU的线程数
crawl:
update:
thread: 1
#小说内容保存配置
content:
save:
storage: db # 小说内容存储方式db-数据库txt-TXT文本
path: /Users/xiongxiaoyang/books # 小说TXT文本保存路径
# HTTP 代理配置
http:
proxy:
# 是否开启 HTTP 代理true-开启false-不开启
enabled: false
# 代理 IP
ip: u493.kdltps.com
# 代理端口号
port: 15818

View File

@ -0,0 +1,47 @@
#端口号
server:
port: 8083
spring:
data:
redis:
#Redis服务器IP
host: 127.0.0.1
#Redis服务器连接端口
port: 6379
#Redis服务器连接密码
password: test123456
#连接超时时间毫秒
timeout: 10000
#登录用户名密码
admin:
username: admin
password: admin
#
##爬虫自动更新的线程数
##建议小说数量不多或者正在运行新书入库爬虫的情况下设置为1即可
##随着小说数量的增多可以逐渐增加但建议不要超出CPU的线程数
crawl:
update:
thread: 1
#小说内容保存配置
content:
save:
storage: db # 小说内容存储方式db-数据库txt-TXT文本
path: /Users/xiongxiaoyang/books # 小说TXT文本保存路径
# HTTP 代理配置
http:
proxy:
# 是否开启 HTTP 代理true-开启false-不开启
enabled: false
# 代理 IP
ip: us.swiftproxy.net
# 代理端口号
port: 7878
# 代理用户名
username: swiftproxy_u
# 代理密码
password: swiftproxy_p

View File

@ -0,0 +1,47 @@
mode:
# 单机模式
type: Standalone
# 元数据持久化
repository:
# 数据库持久化
type: JDBC
# 数据源配置
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
username: root
password: test123456
# 规则配置
rules:
- !SINGLE
tables:
- "*.*"
- !SHARDING
tables: # 数据分片规则配置
book_content:
# 分库策略缺省表示使用默认分库策略
actualDataNodes: ds_${1}.book_content${0..9}
# 分表策略
tableStrategy:
standard:
# 分片列名称
shardingColumn: index_id
# 分片算法名称
shardingAlgorithmName: bookContentSharding
shardingAlgorithms:
bookContentSharding:
# 行表达式分片算法使用 Groovy 的表达式提供对 SQL 语句中的 = IN 的分片操作支持
type: INLINE
props:
# 分片算法的行表达式
algorithm-expression: book_content${index_id % 10}
props:
# 是否在日志中打印 SQL
sql-show: true

View File

@ -153,6 +153,14 @@ public class CrawlController {
return RestResult.ok();
}
/**
* 采集任务进度查询
* */
@GetMapping("getTaskProgress/{id}")
public RestResult<Integer> getTaskProgress(@PathVariable("id") Long id){
return RestResult.ok(crawlService.getTaskProgress(id));
}

Some files were not shown because too many files have changed in this diff Show More