mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a23f4b202e | ||
|
cd3a7206a9 | ||
|
ab166a392a | ||
|
9d8709ed2d | ||
|
60488258f5 | ||
|
b7bb98db16 | ||
|
e54b656799 | ||
|
dccce83d1c | ||
|
b2c0340048 | ||
|
9f71aa4a59 | ||
|
295a9096b5 | ||
|
c46864bbb6 | ||
|
d63be23aca | ||
|
8da6f8263c | ||
|
b4ce4dd35d | ||
|
63760c8e90 | ||
|
e7005b9008 | ||
|
876d9b8cbe | ||
|
9da5064a9e | ||
|
03b3ca1d83 | ||
|
b0d2adebf6 | ||
|
f547a8b7d8 | ||
|
e09aad2415 | ||
|
7b4b97569b |
53
README.md
53
README.md
@ -1,14 +1,10 @@
|
||||
[]( https://cloud.tencent.com/act/cps/redirect?redirect=2446&cps_key=736e609d66e0ac4e57813316cec6fd0b&from=console )
|
||||
|
||||
<p align="center">
|
||||
<a href='https://docs.oracle.com/en/java/javase/17'><img alt="Java 17" src="https://img.shields.io/badge/Java%2017-%234479A1.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAABNVBMVEUAAABkmP9ml/9mmf9mmf9lmv9nmf9mmf9mmf9nmP9mmf9mmf9mmv9mmf9mmf9mmf9mmf9mmP9llv9mmf9mmf9mmv9mmf9mmf9mmf9mmf//AABlmf9mmf9km/9mmf9mmf9lmf9mmf9mmf//AABmmf9mmf9mmf9lmv9mmf//AABmmf9mmP9mmf9mmf//AABgl/9mmf//AABmmP//AABmmf//AAD/AABmmf9mmv9mmf//AABnmf//AAD/AAD/AABmmf//AAD/AABlmf9mmf//AABmmf9mmv9mmf//AAD/AAD/AABmmf//AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AABmmf//AAD/AAD/AABsof9mmf//AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AABmmf//AAB37HanAAAAZX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AyQxWn05sSgtXTaJErSG/hRS1xpT/41IKoxumsqtMTWJPSa72xsW8PV8tKUnj2mK9jEe9U/l8zYDUhY8vtIUXU244mqz+9WXFfosYN/hKro5/aNQ2u6sx0bq6afldoqArbc+Dtm/EUeREaGET3n/rbc+4gP+iPgNo04Ue6Gbq9gAAAABJRU5ErkJggg=="></a>
|
||||
<a href='https://docs.spring.io/spring-boot/docs/3.0.0-SNAPSHOT/reference/html'><img alt="Spring Boot 3" src="https://img.shields.io/badge/Spring%20Boot%203-%23000000.svg?logo=springboot"></a>
|
||||
<a href='https://staging-cn.vuejs.org'><img alt="Vue 3" src="https://img.shields.io/badge/Vue%203%20-%232b3847.svg?logo=vue.js"></a><br/>
|
||||
<a href='https://github.com/201206030/novel'><img alt="Github stars" src="https://img.shields.io/github/stars/201206030/novel?logo=github"></a>
|
||||
<a href='https://github.com/201206030/novel'><img alt="Github forks" src="https://img.shields.io/github/forks/201206030/novel?logo=github"></a>
|
||||
<a href='https://gitee.com/novel_dev_team/novel'><img alt="Gitee stars" src="https://gitee.com/novel_dev_team/novel/badge/star.svg?theme=gitee"></a>
|
||||
<a href='https://gitee.com/novel_dev_team/novel'><img alt="Gitee forks" src="https://gitee.com/novel_dev_team/novel/badge/fork.svg?theme=gitee"></a>
|
||||
<a href="https://github.com/201206030/novel"><img src="https://visitor-badge.glitch.me/badge?page_id=201206030.novel" alt="visitors"></a>
|
||||
</p>
|
||||
|
||||
## 项目简介
|
||||
@ -32,37 +28,38 @@ novel 是一套基于时下**最新** Java 技术栈 Spring Boot 3 + Vue 3 开
|
||||
- Elasticsearch 8.2.0(可选)
|
||||
- RabbitMQ 3.10.2(可选)
|
||||
- XXL-JOB 2.3.1(可选)
|
||||
- JDK 17
|
||||
- JDK 21
|
||||
- Maven 3.8
|
||||
- IntelliJ IDEA 2021.3(可选)
|
||||
- IntelliJ IDEA(可选)
|
||||
- Node 16.14
|
||||
|
||||
**注:Elasticsearch、RabbitMQ 和 XXL-JOB 默认关闭,可通过 application.yml 配置文件中相应的`enable`配置属性开启。**
|
||||
|
||||
## 后端技术选型
|
||||
|
||||
| 技术 | 版本 | 说明 | 官网 | 学习 |
|
||||
|---------------------|:--------------:|---------------------| --------------------------------------- |:-----------------------------------------------------------------------------------------------------------------------------:|
|
||||
| Spring Boot | 3.0.0 | 容器 + MVC 框架 | [进入](https://spring.io/projects/spring-boot) | [进入](https://docs.spring.io/spring-boot/docs/3.0.0/reference/html) |
|
||||
| MyBatis | 3.5.9 | ORM 框架 | [进入](http://www.mybatis.org) | [进入](https://mybatis.org/mybatis-3/zh/index.html) |
|
||||
| MyBatis-Plus | 3.5.3 | MyBatis 增强工具 | [进入](https://baomidou.com/) | [进入](https://baomidou.com/pages/24112f/) |
|
||||
| JJWT | 0.11.5 | JWT 登录支持 | [进入](https://github.com/jwtk/jjwt) | - |
|
||||
| Lombok | 1.18.24 | 简化对象封装工具 | [进入](https://github.com/projectlombok/lombok) | [进入](https://projectlombok.org/features/all) |
|
||||
| Caffeine | 3.1.0 | 本地缓存支持 | [进入](https://github.com/ben-manes/caffeine) | [进入](https://github.com/ben-manes/caffeine/wiki/Home-zh-CN) |
|
||||
| Redis | 7.0 | 分布式缓存支持 | [进入](https://redis.io) | [进入](https://redis.io/docs) |
|
||||
| Redisson | 3.17.4 | 分布式锁实现 | [进入](https://github.com/redisson/redisson) | [进入](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) |
|
||||
| MySQL | 8.0 | 数据库服务 | [进入](https://www.mysql.com) | [进入](https://docs.oracle.com/en-us/iaas/mysql-database/doc/getting-started.html) |
|
||||
| ShardingSphere-JDBC | 5.1.1 | 数据库分库分表支持 | [进入](https://shardingsphere.apache.org) | [进入](https://shardingsphere.apache.org/document/5.1.1/cn/overview) |
|
||||
| Elasticsearch | 8.2.0 | 搜索引擎服务 | [进入](https://www.elastic.co) | [进入](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html) |
|
||||
| RabbitMQ | 3.10.2 | 开源消息中间件 | [进入](https://www.rabbitmq.com) | [进入](https://www.rabbitmq.com/tutorials/tutorial-one-java.html) |
|
||||
| XXL-JOB | 2.3.1 | 分布式任务调度平台 | [进入](https://www.xuxueli.com/xxl-job) | [进入](https://www.xuxueli.com/xxl-job) |
|
||||
| Sentinel | 1.8.4 | 流量控制组件 | [进入](https://github.com/alibaba/Sentinel) | [进入](https://github.com/alibaba/Sentinel/wiki/%E4%B8%BB%E9%A1%B5) |
|
||||
| Springdoc-openapi | 2.0.0 | Swagger 3 接口文档自动生成 | [进入](https://github.com/springdoc/springdoc-openapi) | [进入](https://springdoc.org/) |
|
||||
| Spring Boot Admin | 3.0.0-M1 | 应用管理和监控 | [进入](https://github.com/codecentric/spring-boot-admin) | [进入](https://codecentric.github.io/spring-boot-admin/3.0.0-M1) |
|
||||
| Undertow | 2.2.17.Final | Java 开发的高性能 Web 服务器 | [进入](https://undertow.io) | [进入](https://undertow.io/documentation.html) |
|
||||
| Docker | - | 应用容器引擎 | [进入](https://www.docker.com/) | - |
|
||||
| Jenkins | - | 自动化部署工具 | [进入](https://github.com/jenkinsci/jenkins) | - |
|
||||
| Sonarqube | - | 代码质量控制 | [进入](https://www.sonarqube.org/) | - |
|
||||
| 技术 | 版本 | 说明 | 官网 | 学习 |
|
||||
|---------------------|:------------:|-------------------------| ------------------------------------ |:------------------------------------------------------------------------------------------------------------------------:|
|
||||
| Spring Boot | 3.3.0 | 容器 + MVC 框架 | [进入](https://spring.io/projects/spring-boot) | [进入](https://docs.spring.io/spring-boot/docs/3.0.0/reference/html) |
|
||||
| Spring AI | 1.0.0-M6 | Spring 官方 AI 框架 | [进入](https://spring.io/projects/spring-ai) | [进入](https://docs.spring.io/spring-ai/reference/) |
|
||||
| MyBatis | 3.5.9 | ORM 框架 | [进入](http://www.mybatis.org) | [进入](https://mybatis.org/mybatis-3/zh/index.html) |
|
||||
| MyBatis-Plus | 3.5.3 | MyBatis 增强工具 | [进入](https://baomidou.com/) | [进入](https://baomidou.com/pages/24112f/) |
|
||||
| JJWT | 0.11.5 | JWT 登录支持 | [进入](https://github.com/jwtk/jjwt) | - |
|
||||
| Lombok | 1.18.24 | 简化对象封装工具 | [进入](https://github.com/projectlombok/lombok) | [进入](https://projectlombok.org/features/all) |
|
||||
| Caffeine | 3.1.0 | 本地缓存支持 | [进入](https://github.com/ben-manes/caffeine) | [进入](https://github.com/ben-manes/caffeine/wiki/Home-zh-CN) |
|
||||
| Redis | 7.0 | 分布式缓存支持 | [进入](https://redis.io) | [进入](https://redis.io/docs) |
|
||||
| Redisson | 3.17.4 | 分布式锁实现 | [进入](https://github.com/redisson/redisson) | [进入](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) |
|
||||
| MySQL | 8.0 | 数据库服务 | [进入](https://www.mysql.com) | [进入](https://docs.oracle.com/en-us/iaas/mysql-database/doc/getting-started.html) |
|
||||
| ShardingSphere-JDBC | 5.5.1 | 数据库分库分表支持 | [进入](https://shardingsphere.apache.org) | [进入](https://shardingsphere.apache.org/document/5.1.1/cn/overview) |
|
||||
| Elasticsearch | 8.2.0 | 搜索引擎服务 | [进入](https://www.elastic.co) | [进入](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html) |
|
||||
| RabbitMQ | 3.10.2 | 开源消息中间件 | [进入](https://www.rabbitmq.com) | [进入](https://www.rabbitmq.com/tutorials/tutorial-one-java.html) |
|
||||
| XXL-JOB | 2.3.1 | 分布式任务调度平台 | [进入](https://www.xuxueli.com/xxl-job) | [进入](https://www.xuxueli.com/xxl-job) |
|
||||
| Sentinel | 1.8.4 | 流量控制组件 | [进入](https://github.com/alibaba/Sentinel) | [进入](https://github.com/alibaba/Sentinel/wiki/%E4%B8%BB%E9%A1%B5) |
|
||||
| Springdoc-openapi | 2.0.0 | Swagger 3 接口文档自动生成 | [进入](https://github.com/springdoc/springdoc-openapi) | [进入](https://springdoc.org/) |
|
||||
| Spring Boot Admin | 3.0.0-M1 | 应用管理和监控 | [进入](https://github.com/codecentric/spring-boot-admin) | [进入](https://codecentric.github.io/spring-boot-admin/3.0.0-M1) |
|
||||
| Tomcat | 10.1.24 | Spring Boot 默认内嵌 Web 容器 | [进入](https://tomcat.apache.org) | [进入](https://tomcat.apache.org/tomcat-10.1-doc/index.html) |
|
||||
| Docker | - | 应用容器引擎 | [进入](https://www.docker.com/) | - |
|
||||
| Jenkins | - | 自动化部署工具 | [进入](https://github.com/jenkinsci/jenkins) | - |
|
||||
| Sonarqube | - | 代码质量控制 | [进入](https://www.sonarqube.org/) | - |
|
||||
|
||||
**注:更多热门新技术待集成。**
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
1. 初始状态下,MySQL 只需要执行 `novel.sql` 文件即可正常运行本系统
|
||||
2. 代码更新后再执行以日期命名的增量 SQL 文件
|
||||
3. 只有开启 XXL-JOB 的功能,才需要执行 `xxl-job.sql` 和以 xxl-job 开头日期结尾的增量 SQL 文件
|
||||
4. 只有开启 ShardingSphere-JDBC 的功能,才需要执行 `shardingsphere-jdbc.sql` 和以 shardingsphere-jdbc 开头日期结尾的增量 SQL
|
||||
文件
|
||||
2. 只有开启 XXL-JOB 的功能,才需要执行 `xxl-job.sql` 文件
|
||||
3. 只有开启 ShardingSphere-JDBC 的功能,才需要执行 `shardingsphere-jdbc.sql` 文件
|
||||
|
||||
|
77
pom.xml
77
pom.xml
@ -6,51 +6,38 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.3.0</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<artifactId>novel</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.5.1-SNAPSHOT</version>
|
||||
<name>novel</name>
|
||||
<description>Spring Boot 3 + Vue 3 构建的前后端分离小说系统</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<mybatis-plus.version>3.5.3</mybatis-plus.version>
|
||||
<java.version>21</java.version>
|
||||
<mybatis-plus.version>3.5.6</mybatis-plus.version>
|
||||
<mybatis-plus-generator.version>3.5.1</mybatis-plus-generator.version>
|
||||
<jjwt.version>0.11.5</jjwt.version>
|
||||
<elasticsearch.version>8.2.0</elasticsearch.version>
|
||||
<xxl-job.version>2.3.1</xxl-job.version>
|
||||
<sentinel.version>1.8.4</sentinel.version>
|
||||
<shardingsphere-jdbc.version>5.1.1</shardingsphere-jdbc.version>
|
||||
<shardingsphere-jdbc.version>5.5.1</shardingsphere-jdbc.version>
|
||||
<redisson.version>3.19.1</redisson.version>
|
||||
<spring-boot-admin.version>3.0.0-M1</spring-boot-admin.version>
|
||||
<springdoc-openapi.version>2.0.0</springdoc-openapi.version>
|
||||
<springdoc-openapi.version>2.5.0</springdoc-openapi.version>
|
||||
<logbook.version>3.9.0</logbook.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<!-- Exclude the Tomcat dependency -->
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Use Undertow instead -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis-plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
@ -107,15 +94,9 @@
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- elasticsearch 相关 -->
|
||||
<dependency>
|
||||
<groupId>co.elastic.clients</groupId>
|
||||
<artifactId>elasticsearch-java</artifactId>
|
||||
<version>${elasticsearch.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MQ 相关 -->
|
||||
@ -146,9 +127,14 @@
|
||||
<!-- ShardingSphere-JDBC -->
|
||||
<dependency>
|
||||
<groupId>org.apache.shardingsphere</groupId>
|
||||
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
|
||||
<artifactId>shardingsphere-jdbc</artifactId>
|
||||
<version>${shardingsphere-jdbc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot 管理和监控 -->
|
||||
<dependency>
|
||||
@ -191,6 +177,12 @@
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- AI -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
@ -211,8 +203,33 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-mysql</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.zalando</groupId>
|
||||
<artifactId>logbook-spring-boot-starter</artifactId>
|
||||
<version>${logbook.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-bom</artifactId>
|
||||
<version>1.0.0-M6</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.github.xxyopen.novel;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
@ -14,6 +15,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.util.Map;
|
||||
|
||||
@SpringBootApplication
|
||||
@ -28,7 +31,7 @@ public class NovelApplication {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CommandLineRunner commandLineRunner(ApplicationContext context) {
|
||||
public CommandLineRunner commandLineRunner(ApplicationContext context, DataSource dataSource) {
|
||||
return args -> {
|
||||
Map<String, CacheManager> beans = context.getBeansOfType(CacheManager.class);
|
||||
log.info("加载了如下缓存管理器:");
|
||||
@ -36,7 +39,17 @@ public class NovelApplication {
|
||||
log.info("{}:{}", k, v.getClass().getName());
|
||||
log.info("缓存:{}", v.getCacheNames());
|
||||
});
|
||||
|
||||
if(dataSource instanceof HikariDataSource hikariDataSource) {
|
||||
// 如果使用的是HikariDataSource,需要提前创建连接池,而不是在第一次访问数据库时才创建,提高第一次访问接口的速度
|
||||
log.info("创建连接池...");
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
log.info("最小空闲连接数:{}", hikariDataSource.getMinimumIdle());
|
||||
log.info("最大连接数:{}", hikariDataSource.getMaximumPoolSize());
|
||||
log.info("创建连接池完成.");
|
||||
log.info("数据库:{}", connection.getMetaData().getDatabaseProductName());
|
||||
log.info("数据库版本:{}", connection.getMetaData().getDatabaseProductVersion());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,83 @@
|
||||
package io.github.xxyopen.novel.controller.author;
|
||||
|
||||
import io.github.xxyopen.novel.core.common.resp.RestResp;
|
||||
import io.github.xxyopen.novel.core.constant.ApiRouterConsts;
|
||||
import io.github.xxyopen.novel.core.constant.SystemConfigConsts;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 作家后台-AI模块API控制器
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2025/2/19
|
||||
*/
|
||||
@Tag(name = "AiController", description = "作家后台-AI模块")
|
||||
@SecurityRequirement(name = SystemConfigConsts.HTTP_AUTH_HEADER_NAME)
|
||||
@RestController
|
||||
@RequestMapping(ApiRouterConsts.API_AUTHOR_AI_URL_PREFIX)
|
||||
@RequiredArgsConstructor
|
||||
public class AuthorAiController {
|
||||
|
||||
private final ChatClient chatClient;
|
||||
|
||||
/**
|
||||
* AI扩写
|
||||
*/
|
||||
@Operation(summary = "AI扩写接口")
|
||||
@PostMapping("/expand")
|
||||
public RestResp<String> expandText(@RequestParam("text") String text, @RequestParam("ratio") Double ratio) {
|
||||
String prompt = "请将以下文本扩写为原长度的" + ratio/100 + "倍:" + text;
|
||||
return RestResp.ok(chatClient.prompt()
|
||||
.user(prompt)
|
||||
.call()
|
||||
.content());
|
||||
}
|
||||
|
||||
/**
|
||||
* AI缩写
|
||||
*/
|
||||
@Operation(summary = "AI缩写接口")
|
||||
@PostMapping("/condense")
|
||||
public RestResp<String> condenseText(@RequestParam("text") String text, @RequestParam("ratio") Integer ratio) {
|
||||
String prompt = "请将以下文本缩写为原长度的" + 100/ratio + "分之一:" + text;
|
||||
return RestResp.ok(chatClient.prompt()
|
||||
.user(prompt)
|
||||
.call()
|
||||
.content());
|
||||
}
|
||||
|
||||
/**
|
||||
* AI续写
|
||||
*/
|
||||
@Operation(summary = "AI续写接口")
|
||||
@PostMapping("/continue")
|
||||
public RestResp<String> continueText(@RequestParam("text") String text, @RequestParam("length") Integer length) {
|
||||
String prompt = "请续写以下文本,续写长度约为" + length + "字:" + text;
|
||||
return RestResp.ok(chatClient.prompt()
|
||||
.user(prompt)
|
||||
.call()
|
||||
.content());
|
||||
}
|
||||
|
||||
/**
|
||||
* AI润色
|
||||
*/
|
||||
@Operation(summary = "AI润色接口")
|
||||
@PostMapping("/polish")
|
||||
public RestResp<String> polishText(@RequestParam("text") String text) {
|
||||
String prompt = "请润色优化以下文本,保持原意:" + text;
|
||||
return RestResp.ok(chatClient.prompt()
|
||||
.user(prompt)
|
||||
.call()
|
||||
.content());
|
||||
}
|
||||
|
||||
}
|
@ -8,6 +8,7 @@ import io.github.xxyopen.novel.service.HomeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@ -24,6 +25,7 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping(ApiRouterConsts.API_FRONT_HOME_URL_PREFIX)
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class HomeController {
|
||||
|
||||
private final HomeService homeService;
|
||||
@ -34,6 +36,8 @@ public class HomeController {
|
||||
@Operation(summary = "首页小说推荐查询接口")
|
||||
@GetMapping("books")
|
||||
public RestResp<List<HomeBookRespDto>> listHomeBooks() {
|
||||
// 测试虚拟线程处理请求
|
||||
log.debug("处理请求的线程:{}", Thread.currentThread());
|
||||
return homeService.listHomeBooks();
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,12 @@ package io.github.xxyopen.novel.core.common.exception;
|
||||
import io.github.xxyopen.novel.core.common.constant.ErrorCodeEnum;
|
||||
import io.github.xxyopen.novel.core.common.resp.RestResp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||
|
||||
/**
|
||||
* 通用的异常处理器
|
||||
@ -17,6 +20,15 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
@RestControllerAdvice
|
||||
public class CommonExceptionHandler {
|
||||
|
||||
/**
|
||||
* 处理404异常
|
||||
*/
|
||||
@ExceptionHandler(NoResourceFoundException.class)
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public String handlerNotFound() {
|
||||
return "404";
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理数据校验异常
|
||||
*/
|
||||
|
@ -0,0 +1,47 @@
|
||||
package io.github.xxyopen.novel.core.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
/**
|
||||
* Ai 相关配置
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2025/2/19
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class AiConfig {
|
||||
|
||||
/**
|
||||
* 目的:配置自定义的 RestClientBuilder 对象
|
||||
* <p>
|
||||
* 原因:Spring AI 框架的 ChatClient 内部通过 RestClient(Spring Framework 6 和 Spring Boot 3 中引入) 发起 HTTP REST 请求与远程的大模型服务进行通信,
|
||||
* 如果项目中没有配置自定义的 RestClientBuilder 对象, 那么在 RestClient 的自动配置类 org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration
|
||||
* 中配置的 RestClientBuilder 对象会使用 Spring 容器中提供的 HttpMessageConverters, 由于本项目中配置了 spring.jackson.generator.write-numbers-as-strings
|
||||
* = true, 所以 Spring 容器中的 HttpMessageConverters 在 RestClient 发起 HTTP REST 请求转换 Java 对象为 JSON 字符串时会自动将 Number 类型的
|
||||
* Java 对象属性转换为字符串而导致请求参数错误
|
||||
* <p>
|
||||
* 示例:"temperature": 0.7 =》"temperature": "0.7"
|
||||
* {"code":20015,"message":"The parameter is invalid. Please check again.","data":null}
|
||||
*/
|
||||
@Bean
|
||||
public RestClient.Builder restClientBuilder() {
|
||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||
// 连接超时时间
|
||||
factory.setConnectTimeout(5000);
|
||||
// 读取超时时间
|
||||
factory.setReadTimeout(60000);
|
||||
return RestClient.builder().requestFactory(factory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ChatClient chatClient(ChatClient.Builder chatClientBuilder) {
|
||||
return chatClientBuilder.build();
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package io.github.xxyopen.novel.core.config;
|
||||
|
||||
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
|
||||
import org.elasticsearch.client.RestClient;
|
||||
@ -29,14 +28,6 @@ import java.security.cert.X509Certificate;
|
||||
@Slf4j
|
||||
public class EsConfig {
|
||||
|
||||
/**
|
||||
* 解决 ElasticsearchClientConfigurations 修改默认 ObjectMapper 配置的问题
|
||||
*/
|
||||
@Bean
|
||||
JacksonJsonpMapper jacksonJsonpMapper() {
|
||||
return new JacksonJsonpMapper();
|
||||
}
|
||||
|
||||
/**
|
||||
* fix `sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
|
||||
* unable to find valid certification path to requested target`
|
||||
|
@ -0,0 +1,37 @@
|
||||
package io.github.xxyopen.novel.core.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.zalando.logbook.Logbook;
|
||||
|
||||
import static org.zalando.logbook.core.Conditions.*;
|
||||
|
||||
/**
|
||||
* Logbook 配置
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2024/9/13
|
||||
*/
|
||||
@Configuration
|
||||
public class LogbookConfig {
|
||||
|
||||
@Bean
|
||||
public Logbook logbook() {
|
||||
return Logbook.builder()
|
||||
.condition(exclude(
|
||||
// 忽略 OPTIONS 请求
|
||||
requestWithMethod("OPTIONS"),
|
||||
// 忽略 /actuator 以及其子路径(Spring Boot Actuator 提供的端点)的请求
|
||||
requestTo("/actuator/**"),
|
||||
// 忽略 Swagger 文档路径
|
||||
requestTo("/swagger-ui/**"),
|
||||
requestTo("/v3/api-docs/**"),
|
||||
// 忽略二进制文件请求
|
||||
contentType("application/octet-stream"),
|
||||
// 忽略文件上传请求
|
||||
contentType("multipart/form-data")
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package io.github.xxyopen.novel.core.config;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
|
||||
import org.apache.shardingsphere.infra.url.core.ShardingSphereURL;
|
||||
import org.apache.shardingsphere.infra.url.core.ShardingSphereURLLoadEngine;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* ShardingSphere 配置类,控制是否开启 ShardingSphere
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2023/12/21
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(
|
||||
prefix = "spring.shardingsphere",
|
||||
name = {"enabled"},
|
||||
havingValue = "true"
|
||||
)
|
||||
@Slf4j
|
||||
public class ShardingSphereConfiguration {
|
||||
|
||||
private static final String URL = "classpath:shardingsphere-jdbc.yml";
|
||||
|
||||
@Bean
|
||||
@SneakyThrows
|
||||
public DataSource shardingSphereDataSource() {
|
||||
log.info(">>>>>>>>>>> shardingSphereDataSource init.");
|
||||
ShardingSphereURLLoadEngine urlLoadEngine = new ShardingSphereURLLoadEngine(
|
||||
ShardingSphereURL.parse(URL));
|
||||
return YamlShardingSphereDataSourceFactory.createDataSource(urlLoadEngine.loadContent());
|
||||
}
|
||||
|
||||
}
|
@ -62,6 +62,11 @@ public class ApiRouterConsts {
|
||||
*/
|
||||
public static final String SEARCH_URL_PREFIX = "/search";
|
||||
|
||||
/**
|
||||
* AI模块请求路径前缀
|
||||
*/
|
||||
public static final String AI_URL_PREFIX = "/ai";
|
||||
|
||||
/**
|
||||
* 前台门户首页API请求路径前缀
|
||||
*/
|
||||
@ -94,4 +99,10 @@ public class ApiRouterConsts {
|
||||
public static final String API_FRONT_SEARCH_URL_PREFIX =
|
||||
API_FRONT_URL_PREFIX + SEARCH_URL_PREFIX;
|
||||
|
||||
/**
|
||||
* 作家后台AI相关API请求路径前缀
|
||||
*/
|
||||
public static final String API_AUTHOR_AI_URL_PREFIX = API_AUTHOR_URL_PREFIX + AI_URL_PREFIX;
|
||||
|
||||
|
||||
}
|
||||
|
@ -65,6 +65,12 @@
|
||||
"name": "spring.elasticsearch.ssl.verification-mode",
|
||||
"type": "java.lang.String",
|
||||
"description": "设置 ssl 的认证模式,如果该配置项为 none ,说明不需要认证,信任所有的 ssl 证书."
|
||||
},
|
||||
{
|
||||
"defaultValue": true,
|
||||
"name": "spring.shardingsphere.enabled",
|
||||
"description": "Whether enable shardingsphere or not.",
|
||||
"type": "java.lang.Boolean"
|
||||
}
|
||||
]
|
||||
}
|
@ -16,14 +16,44 @@ spring:
|
||||
multipart:
|
||||
# 上传文件最大大小
|
||||
max-file-size: 5MB
|
||||
# 启用虚拟线程
|
||||
threads:
|
||||
virtual:
|
||||
enabled: true
|
||||
# 即使所有的用户线程(包括虚拟线程)都是守护线程的情况下,JVM 也不会立即退出,
|
||||
# Spring Boot 官方建议在开启虚拟线程时设置该属性
|
||||
main:
|
||||
keep-alive: true
|
||||
|
||||
flyway:
|
||||
# 是否开启 Flyway
|
||||
enabled: false
|
||||
# initialize the schema history table
|
||||
baseline-on-migrate: true
|
||||
# url: jdbc:mysql://localhost:3306/novel?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
# user: root
|
||||
# password: test123456
|
||||
|
||||
server:
|
||||
# 端口号
|
||||
port: 8888
|
||||
|
||||
--- #--------------------- Spring AI 配置----------------------
|
||||
spring:
|
||||
ai:
|
||||
openai:
|
||||
api-key: sk-rrrupturhdofbiqzjutduuiceecpvfqlnvmgcyiaipbdikoi
|
||||
base-url: https://api.siliconflow.cn
|
||||
chat:
|
||||
options:
|
||||
model: deepseek-ai/DeepSeek-R1-Distill-Llama-8B
|
||||
|
||||
|
||||
|
||||
--- #---------------------数据库配置---------------------------
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/novel_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://localhost:3306/novel?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: test123456
|
||||
# ShardingSphere-JDBC 配置
|
||||
@ -32,53 +62,6 @@ spring:
|
||||
shardingsphere:
|
||||
# 是否开启分库分表
|
||||
enabled: false
|
||||
props:
|
||||
# 是否在日志中打印 SQL
|
||||
sql-show: true
|
||||
# 模式配置
|
||||
mode:
|
||||
# 单机模式
|
||||
type: Standalone
|
||||
repository:
|
||||
# 文件持久化
|
||||
type: File
|
||||
props:
|
||||
# 元数据存储路径
|
||||
path: .shardingsphere
|
||||
# 使用本地配置覆盖持久化配置
|
||||
overwrite: true
|
||||
# 数据源配置
|
||||
datasource:
|
||||
names: ds_0
|
||||
ds_0:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
jdbcUrl: jdbc:mysql://localhost:3306/novel_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: test123456
|
||||
# 规则配置
|
||||
rules:
|
||||
# 数据分片
|
||||
sharding:
|
||||
tables:
|
||||
# book_content 表
|
||||
book_content:
|
||||
# 数据节点
|
||||
actual-data-nodes: ds_$->{0}.book_content$->{0..9}
|
||||
# 分表策略
|
||||
table-strategy:
|
||||
standard:
|
||||
# 分片列名称
|
||||
sharding-column: chapter_id
|
||||
# 分片算法名称
|
||||
sharding-algorithm-name: bookContentSharding
|
||||
sharding-algorithms:
|
||||
bookContentSharding:
|
||||
# 行表达式分片算法,使用 Groovy 的表达式,提供对 SQL 语句中的 = 和 IN 的分片操作支持
|
||||
type: INLINE
|
||||
props:
|
||||
# 分片算法的行表达式
|
||||
algorithm-expression: book_content$->{chapter_id % 10}
|
||||
|
||||
--- #---------------------中间件配置---------------------------
|
||||
spring:
|
||||
@ -87,7 +70,7 @@ spring:
|
||||
redis:
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
password: 123456
|
||||
password: test123456
|
||||
|
||||
# Elasticsearch 配置
|
||||
elasticsearch:
|
||||
@ -221,6 +204,19 @@ spring:
|
||||
class: javax.net.ssl.SSLSocketFactory
|
||||
fallback: false
|
||||
|
||||
--- #----------------------Logbook配置-----------------------------
|
||||
logbook:
|
||||
format:
|
||||
# 输出格式
|
||||
style: http
|
||||
obfuscate:
|
||||
headers:
|
||||
# 隐藏 Authorization 头信息
|
||||
- Authorization
|
||||
parameters:
|
||||
# 隐藏密码参数
|
||||
- password
|
||||
|
||||
--- #---------------------自定义配置----------------------------
|
||||
novel:
|
||||
# 跨域配置
|
||||
@ -229,7 +225,7 @@ novel:
|
||||
allow-origins:
|
||||
- http://localhost:1024
|
||||
- http://localhost:8080
|
||||
# JWT密钥
|
||||
# JWT 密钥
|
||||
jwt:
|
||||
secret: E66559580A1ADF48CDD928516062F12E
|
||||
# XSS 过滤配置
|
||||
@ -251,9 +247,15 @@ spring:
|
||||
config:
|
||||
activate:
|
||||
on-profile: dev
|
||||
# 开启 SpringDoc 接口文档
|
||||
springdoc:
|
||||
api-docs:
|
||||
enabled: true
|
||||
# /env 端点显示属性值
|
||||
management:
|
||||
endpoint:
|
||||
env:
|
||||
show-values: when_authorized
|
||||
|
||||
--- #------------------- test 特定配置--------------------------
|
||||
spring:
|
||||
|
@ -62,6 +62,10 @@
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</logger>
|
||||
<logger name="org.zalando.logbook" level="TRACE" additivity="false">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</logger>
|
||||
</springProfile>
|
||||
|
||||
<springProfile name="prod">
|
||||
|
55
src/main/resources/shardingsphere-jdbc.yml
Normal file
55
src/main/resources/shardingsphere-jdbc.yml
Normal file
@ -0,0 +1,55 @@
|
||||
mode:
|
||||
# 单机模式
|
||||
type: Standalone
|
||||
# 元数据持久化
|
||||
repository:
|
||||
# 数据库持久化
|
||||
type: JDBC
|
||||
props:
|
||||
# 元数据存储类型
|
||||
provider: H2
|
||||
jdbc_url: jdbc:h2:./.h2/shardingsphere
|
||||
|
||||
# 数据源配置
|
||||
dataSources:
|
||||
ds_1:
|
||||
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
jdbcUrl: jdbc:mysql://localhost:3306/novel?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: chapter_id
|
||||
# 分片算法名称
|
||||
shardingAlgorithmName: bookContentSharding
|
||||
|
||||
shardingAlgorithms:
|
||||
bookContentSharding:
|
||||
# 行表达式分片算法,使用 Groovy 的表达式,提供对 SQL 语句中的 = 和 IN 的分片操作支持
|
||||
type: INLINE
|
||||
props:
|
||||
# 分片算法的行表达式
|
||||
algorithm-expression: book_content${chapter_id % 10}
|
||||
|
||||
|
||||
|
||||
props:
|
||||
# 是否在日志中打印 SQL
|
||||
sql-show: true
|
Loading…
x
Reference in New Issue
Block a user