2026-4-30:
1.后端代码2次更新
This commit is contained in:
@@ -14,6 +14,47 @@
|
||||
<description>rczn-common(公共模块:实体类、工具类、统一响应)</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<!-- 若想引用modbus4j需要引入下列repository id:ias-snapshots id:ias-releases 两个 ,使用默认仓库下载,不要使用阿里云仓库-->
|
||||
<repositories>
|
||||
<repository>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
<id>ias-snapshots</id>
|
||||
<name>Infinite Automation Snapshot Repository</name>
|
||||
<url>https://maven.mangoautomation.net/repository/ias-snapshot/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<id>ias-releases</id>
|
||||
<name>Infinite Automation Release Repository</name>
|
||||
<url>https://maven.mangoautomation.net/repository/ias-release/</url>
|
||||
</repository>
|
||||
<!-- ====================== 新增:Spring AI 必须的仓库 ====================== -->
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-releases</id>
|
||||
<name>Spring Releases</name>
|
||||
<url>https://repo.spring.io/release</url>
|
||||
</repository>
|
||||
<!-- ===================================================================== -->
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!-- 核心依赖 -->
|
||||
<dependency>
|
||||
@@ -44,11 +85,6 @@
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
<!-- 如果需要 Web 相关类(拦截器等) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
@@ -56,13 +92,41 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- springAI框架 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.ai</groupId>-->
|
||||
<!-- <artifactId>spring-ai-starter-model-openai</artifactId>-->
|
||||
<!-- <version>1.0.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- Servlet API -->
|
||||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- S7connector 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.github.s7connector</groupId>
|
||||
<artifactId>s7connector</artifactId>
|
||||
<version>2.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- modbus4j -->
|
||||
<dependency>
|
||||
<groupId>com.infiniteautomation</groupId>
|
||||
<artifactId>modbus4j</artifactId>
|
||||
<version>3.0.3</version> <!-- 或其他稳定版本 -->
|
||||
</dependency>
|
||||
<!-- 连接池(工业场景必加,优化多设备连接) -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
<version>2.12.0</version>
|
||||
</dependency>
|
||||
<!-- Spring Context(如果需要 @Component 等注解) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
@@ -70,8 +134,9 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
@@ -89,6 +154,12 @@
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- websocket 核心依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.rczn.domain;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class BaseBean {
|
||||
@@ -15,6 +17,7 @@ public class BaseBean {
|
||||
private String remark;
|
||||
|
||||
private LocalDateTime startTime;
|
||||
|
||||
private LocalDateTime endTime;
|
||||
|
||||
// 无参构造器、全参构造器(同步修改 delSign 类型)
|
||||
|
||||
@@ -9,13 +9,29 @@ import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
//@Component
|
||||
@Component
|
||||
public class LoginInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
// 1. 放行OPTIONS预检请求,直接返回200 OK,不做任何校验
|
||||
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
// 手动添加跨域响应头(兜底)
|
||||
response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
response.setHeader("Access-Control-Allow-Methods", "GET,POST,PATCH,PUT,DELETE,OPTIONS");
|
||||
response.setHeader("Access-Control-Allow-Headers", "*");
|
||||
response.setHeader("Access-Control-Max-Age", "3600");
|
||||
return true; // 直接放行,不执行后续拦截逻辑
|
||||
}
|
||||
|
||||
try {
|
||||
String token = request.getHeader("Authorization");
|
||||
String[] tokens = token.split(" ");
|
||||
if(tokens.length>1){
|
||||
token = tokens[1];
|
||||
}
|
||||
Map<String, Object> claims = JwtUtil.parseToken(token);
|
||||
//保存用户数据到ThreadLocalUtil
|
||||
ThreadLocalUtil.set(claims);
|
||||
|
||||
@@ -27,4 +27,11 @@ public class JwtUtil {
|
||||
.asMap();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGFpbXMiOnsicGVybWlzc2lvbnMiOlsiMTExMSIsIjIyMiIsIjU1NSJdLCJpZCI6MywidXNlcm5hbWUiOiJzdHJpbmcifSwiZXhwIjoxNzc2NzE2NzAyfQ.ynjs9Ys0CxoZjRstjz3mjr3c6NYMFiV3MmTGQYpJmKQ";//genToken(null);
|
||||
System.out.println(token);
|
||||
Map<String, Object> claims = parseToken(token);
|
||||
System.out.println(claims);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1 +1,12 @@
|
||||
##spring.application.name=rczn-common
|
||||
#spring:
|
||||
# ai:
|
||||
# openai:
|
||||
# api-key: "sk-b2b55f0bc7e140668e0326c0cc7a86df" #sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
# base-url: "https://api.deepseek.com"
|
||||
# chat:
|
||||
# options:
|
||||
# model: "deepseek-chat"
|
||||
# # 关键:给语音模型也配置上,就不报错了
|
||||
# speech:
|
||||
# api-key: "sk-b2b55f0bc7e140668e0326c0cc7a86df"
|
||||
Reference in New Issue
Block a user