diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..229bd24
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -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
\ No newline at end of file
diff --git a/README.md b/README.md
index baffe3c..7b9ea06 100644
--- a/README.md
+++ b/README.md
@@ -1,28 +1,28 @@
-[]( https://cloud.tencent.com/act/cps/redirect?redirect=2446&cps_key=736e609d66e0ac4e57813316cec6fd0b&from=console )
-
+
",
+ "contentEnd": "
",
+ "filterContent":"
\\\\s*([^/]+)\\\\s*
"
+}', 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;
\ No newline at end of file
diff --git a/doc/sql/20250630.sql b/doc/sql/20250630.sql
new file mode 100644
index 0000000..23ef4c6
--- /dev/null
+++ b/doc/sql/20250630.sql
@@ -0,0 +1,3 @@
+alter table book_comment add column location varchar(50) DEFAULT NULL COMMENT '地理位置' after comment_content ;
+
+
diff --git a/doc/sql/20250711.sql b/doc/sql/20250711.sql
new file mode 100644
index 0000000..e50a849
--- /dev/null
+++ b/doc/sql/20250711.sql
@@ -0,0 +1,3 @@
+alter table crawl_single_task add column crawl_chapters int DEFAULT 0 COMMENT '采集章节数量' after exc_count ;
+
+
diff --git a/doc/sql/20250712.sql b/doc/sql/20250712.sql
new file mode 100644
index 0000000..d2eb17a
--- /dev/null
+++ b/doc/sql/20250712.sql
@@ -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 ='小说评论回复表';
\ No newline at end of file
diff --git a/doc/sql/novel_plus.sql b/doc/sql/novel_plus.sql
index dd7b73b..577d3fd 100644
--- a/doc/sql/novel_plus.sql
+++ b/doc/sql/novel_plus.sql
@@ -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;
\ No newline at end of file
+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": "
",
+ "pagePatten": "(\\\\d+)/\\\\d+",
+ "totalPagePatten": "\\\\d+/(\\\\d+)",
+ "bookDetailUrl": "http://www.xbiqugu.net/{bookId}/",
+ "bookNamePatten": "([^/]+)
",
+ "authorNamePatten": "者:([^/]+)",
+ "picUrlPatten": "src=\\"(http://www.xbiqugu.net/files/article/image/\\\\d+/\\\\d+/\\\\d+s\\\\.jpg)\\"",
+ "bookStatusRule": {},
+ "descStart": "",
+ "descEnd": "
",
+ "upadateTimePatten": "最后更新:(\\\\d+-\\\\d+-\\\\d+\\\\s\\\\d+:\\\\d+:\\\\d+)
",
+ "upadateTimeFormatPatten": "yyyy-MM-dd HH:mm:ss",
+ "bookIndexUrl": "http://www.xbiqugu.net/{bookId}/",
+ "indexIdPatten": "[^/]+",
+ "indexNamePatten": "
([^/]+)",
+ "bookContentUrl": "http://www.xbiqugu.net/{bookId}/{indexId}.html",
+ "contentStart": "
",
+ "contentEnd": "
",
+ "filterContent":"
\\\\s*([^/]+)\\\\s*
"
+}', 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 ='小说评论回复表';
\ No newline at end of file
diff --git a/novel-admin/pom.xml b/novel-admin/pom.xml
index bbf634f..608bb84 100644
--- a/novel-admin/pom.xml
+++ b/novel-admin/pom.xml
@@ -5,7 +5,7 @@
com.java2nb
novel-admin
-
4.3.0
+
5.2.0
jar
novel-admin
@@ -14,18 +14,14 @@
org.springframework.boot
spring-boot-starter-parent
- 2.1.18.RELEASE
+ 2.7.18
- UTF-8
- UTF-8
- 1.8
+ 21
1.7
- 5.22.0
- 3.0.0
- 2.15.1
+ 5.5.1
@@ -60,35 +56,24 @@
net.sourceforge.nekohtml
nekohtml
+
+
+ org.hibernate.validator
+ hibernate-validator
+
mysql
mysql-connector-java
8.0.29
-
- org.mybatis
- mybatis
- 3.5.6
-
org.mybatis.spring.boot
mybatis-spring-boot-starter
1.1.1
-
-
- com.alibaba
- druid
- 1.2.9
-
-
- org.apache.commons
- commons-lang3
- 3.6
-
commons-configuration
commons-configuration
@@ -138,6 +123,12 @@
org.apache.velocity
velocity
1.7
+
+
+ commons-lang
+ commons-lang
+
+
@@ -166,6 +157,12 @@
io.springfox
springfox-swagger2
2.6.1
+
+
+ guava
+ com.google.guava
+
+
io.springfox
@@ -195,24 +192,29 @@
org.apache.commons
commons-text
1.4
+
+
+ commons-lang3
+ org.apache.commons
+
+
+
- io.shardingsphere
- sharding-jdbc-spring-boot-starter
- ${sharding.jdbc.version}
+ org.apache.shardingsphere
+ shardingsphere-jdbc
+ ${shardingsphere-jdbc.version}
-
- io.shardingsphere
- sharding-jdbc-spring-namespace
- ${sharding.jdbc.version}
+ org.yaml
+ snakeyaml
+ 2.2
-
- com.fasterxml.jackson.core
- jackson-databind
- ${jackson.version}
+ com.h2database
+ h2
+ runtime
@@ -330,4 +332,35 @@
+
+
+
+
+ central-repo
+
+
+ central
+ https://repo.maven.apache.org/maven2/
+
+ true
+
+
+ false
+
+
+
+
+
+ central-plugin
+ https://repo.maven.apache.org/maven2/
+
+ true
+
+
+ false
+
+
+
+
+
diff --git a/novel-admin/src/main/build/config/application-prod.yml b/novel-admin/src/main/build/config/application-prod.yml
deleted file mode 100644
index 73d0c2f..0000000
--- a/novel-admin/src/main/build/config/application-prod.yml
+++ /dev/null
@@ -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
diff --git a/novel-admin/src/main/build/config/application.yml b/novel-admin/src/main/build/config/application.yml
new file mode 100644
index 0000000..597dfad
--- /dev/null
+++ b/novel-admin/src/main/build/config/application.yml
@@ -0,0 +1,9 @@
+#端口号
+server:
+ port: 8088
+spring:
+ redis:
+ host: 127.0.0.1
+ port: 6379
+ password: test123456
+
diff --git a/novel-admin/src/main/build/config/shardingsphere-jdbc.yml b/novel-admin/src/main/build/config/shardingsphere-jdbc.yml
new file mode 100644
index 0000000..8659c28
--- /dev/null
+++ b/novel-admin/src/main/build/config/shardingsphere-jdbc.yml
@@ -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
diff --git a/novel-admin/src/main/java/com/java2nb/AdminApplication.java b/novel-admin/src/main/java/com/java2nb/AdminApplication.java
index cb20c22..29b7a12 100644
--- a/novel-admin/src/main/java/com/java2nb/AdminApplication.java
+++ b/novel-admin/src/main/java/com/java2nb/AdminApplication.java
@@ -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"));
};
}
-
}
diff --git a/novel-admin/src/main/java/com/java2nb/common/aspect/WebLogAspect.java b/novel-admin/src/main/java/com/java2nb/common/aspect/WebLogAspect.java
index 889fdb6..0d6dce5 100644
--- a/novel-admin/src/main/java/com/java2nb/common/aspect/WebLogAspect.java
+++ b/novel-admin/src/main/java/com/java2nb/common/aspect/WebLogAspect.java
@@ -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());
}
diff --git a/novel-admin/src/main/java/com/java2nb/common/config/DruidDBConfig.java b/novel-admin/src/main/java/com/java2nb/common/config/DruidDBConfig.java
deleted file mode 100644
index 92a2383..0000000
--- a/novel-admin/src/main/java/com/java2nb/common/config/DruidDBConfig.java
+++ /dev/null
@@ -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;
- }
-}
-
diff --git a/novel-admin/src/main/java/com/java2nb/common/config/Swagger2Config.java b/novel-admin/src/main/java/com/java2nb/common/config/Swagger2Config.java
deleted file mode 100644
index 90b912c..0000000
--- a/novel-admin/src/main/java/com/java2nb/common/config/Swagger2Config.java
+++ /dev/null
@@ -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();
- }
-}
\ No newline at end of file
diff --git a/novel-admin/src/main/java/com/java2nb/common/dao/GeneratorMapper.java b/novel-admin/src/main/java/com/java2nb/common/dao/GeneratorMapper.java
index 38996bb..914affc 100644
--- a/novel-admin/src/main/java/com/java2nb/common/dao/GeneratorMapper.java
+++ b/novel-admin/src/main/java/com/java2nb/common/dao/GeneratorMapper.java
@@ -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
+
+
+
+ maven-antrun-plugin
+ 1.8
+
+
+ package
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/novel-common/src/main/java/com/java2nb/novel/core/advice/CommonExceptionHandler.java b/novel-common/src/main/java/com/java2nb/novel/core/advice/CommonExceptionHandler.java
new file mode 100644
index 0000000..cae9f25
--- /dev/null
+++ b/novel-common/src/main/java/com/java2nb/novel/core/advice/CommonExceptionHandler.java
@@ -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
handlerBindException(BindException e) {
+ log.error(e.getMessage(), e);
+ return RestResult.fail(SysResultCode.PARAM_ERROR);
+ }
+
+ @ExceptionHandler({BusinessException.class})
+ public RestResult 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);
+ }
+
+}
\ No newline at end of file
diff --git a/novel-common/src/main/java/com/java2nb/novel/core/advice/CustomResponseBodyAdvice.java b/novel-common/src/main/java/com/java2nb/novel/core/advice/CustomResponseBodyAdvice.java
new file mode 100644
index 0000000..fa96131
--- /dev/null
+++ b/novel-common/src/main/java/com/java2nb/novel/core/advice/CustomResponseBodyAdvice.java
@@ -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