Compare commits
47 Commits
798c7b0592
...
dev/3.1_re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d700f94f9d | ||
|
|
b277479e73 | ||
|
|
83cbd57dea | ||
|
|
4d3b22de82 | ||
|
|
6b5c2cfec0 | ||
|
|
b676de054a | ||
|
|
4c169ef67e | ||
|
|
f2bce066b6 | ||
|
|
6af442eb15 | ||
|
|
768df55309 | ||
|
|
f351277b73 | ||
|
|
a799162ea4 | ||
|
|
c035eb9d7d | ||
|
|
906a54b3c8 | ||
|
|
643799546b | ||
|
|
f582464cd3 | ||
|
|
b864b393bc | ||
|
|
c03a8762e7 | ||
|
|
cb87ad1099 | ||
|
|
fb229764f8 | ||
|
|
8bec1f842d | ||
|
|
b54bd04cff | ||
|
|
b4ccad6242 | ||
|
|
6068bf7d7d | ||
|
|
d36baf747f | ||
| 7c8f1bee6a | |||
|
|
62bd145e2c | ||
|
|
23716984cc | ||
|
|
d0b8b8d674 | ||
|
|
92e7dbf258 | ||
|
|
32a228485b | ||
|
|
560e47747a | ||
|
|
c8dc38575a | ||
|
|
c00d906083 | ||
| 4df3f9cc53 | |||
|
|
b0343be544 | ||
|
|
d33cb9f0bf | ||
|
|
40f2735831 | ||
| 01d3806d5f | |||
| 107e4e9771 | |||
|
|
716d720782 | ||
|
|
6b5bacc49b | ||
|
|
409bc7b1fd | ||
|
|
ec6a5df8af | ||
|
|
029b96ae99 | ||
|
|
14002e7331 | ||
| 14dfe2806c |
111
.gitea/workflows/develop_3.1_MS_build_manual.yaml
Normal file
111
.gitea/workflows/develop_3.1_MS_build_manual.yaml
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
name: 手动 AiDA back-java 开发分支构建部署
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_deploy:
|
||||||
|
runs-on: java21
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
build_status: ${{ job.status }}
|
||||||
|
build_url: ${{ gitea.server_url }}/${{ gitea.repository.owner.name }}/${{ gitea.repository.name }}/actions/runs/${{ gitea.run_id }}
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
REMOTE_DEPLOY_PATH: /workspace/workspace_aida/DevelopVersion/develop-MS-version-aida-back
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 0.记录开始时间
|
||||||
|
id: build_start_time
|
||||||
|
run: echo "current_time=$(TZ='Asia/Hong_Kong' date '+%Y-%m-%d %H:%M:%S %Z')" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: 1.检出代码
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: dev/3.1_release_merge_MS
|
||||||
|
|
||||||
|
|
||||||
|
- name: 3.缓存 Maven 依赖
|
||||||
|
uses: actions/cache@v5
|
||||||
|
with:
|
||||||
|
path: ~/.m2/repository
|
||||||
|
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-maven-
|
||||||
|
|
||||||
|
- name: 4.构建项目
|
||||||
|
run: |
|
||||||
|
java -version
|
||||||
|
mvn -v
|
||||||
|
mvn clean package -DskipTests
|
||||||
|
|
||||||
|
- name: 5.生成Dockerfile
|
||||||
|
run: |
|
||||||
|
echo "===== 生成Dockerfile ====="
|
||||||
|
cat > Dockerfile << 'EOF'
|
||||||
|
FROM openjdk:21-ea-21-jdk-slim
|
||||||
|
VOLUME /tmp
|
||||||
|
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
|
RUN echo 'Asia/Shanghai' > /etc/timezone
|
||||||
|
ADD ./target/aida-0.0.1-SNAPSHOT.jar /app.jar
|
||||||
|
ENTRYPOINT ["java","-jar","/app.jar"]
|
||||||
|
EOF
|
||||||
|
echo "Dockerfile内容:"
|
||||||
|
cat Dockerfile
|
||||||
|
|
||||||
|
- name: 6.生成docker-compose.yml
|
||||||
|
run: |
|
||||||
|
echo "===== 生成docker-compose.yml ====="
|
||||||
|
cat > docker-compose.yml << 'EOF'
|
||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
aida_back:
|
||||||
|
container_name: develop-aida-ms
|
||||||
|
build: .
|
||||||
|
volumes:
|
||||||
|
# 数据挂载
|
||||||
|
- ./log:/log
|
||||||
|
- ./temp:/temp
|
||||||
|
- ./uploads:/temp/uploads
|
||||||
|
ports:
|
||||||
|
- '10092:10092'
|
||||||
|
restart: always
|
||||||
|
EOF
|
||||||
|
# 验证docker-compose.yml生成
|
||||||
|
echo "docker-compose.yml内容:"
|
||||||
|
cat docker-compose.yml
|
||||||
|
|
||||||
|
- name: 7.上传jar到远程服务器
|
||||||
|
uses: appleboy/scp-action@master
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
port: 22
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
source: "target/*.jar,Dockerfile,docker-compose.yml"
|
||||||
|
target: ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
preserve_host_directory_structure: false
|
||||||
|
|
||||||
|
- name: 8. 重启 Docker 服务
|
||||||
|
uses: appleboy/ssh-action@master # 👈 专门执行命令的 action
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
key_base64: true
|
||||||
|
script: |
|
||||||
|
echo "========= 进入部署目录 ========="
|
||||||
|
cd ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
ls -l
|
||||||
|
|
||||||
|
echo "========= 停止旧服务 ========="
|
||||||
|
docker compose down
|
||||||
|
|
||||||
|
echo "========= 启动新服务 ========="
|
||||||
|
docker compose up -d --build
|
||||||
|
|
||||||
|
echo "========= 查看运行状态 ========="
|
||||||
|
docker compose ps
|
||||||
@@ -103,7 +103,13 @@ jobs:
|
|||||||
- ./uploads:/temp/uploads
|
- ./uploads:/temp/uploads
|
||||||
ports:
|
ports:
|
||||||
- '10090:5567'
|
- '10090:5567'
|
||||||
|
networks:
|
||||||
|
- aida_java_net
|
||||||
restart: always
|
restart: always
|
||||||
|
networks:
|
||||||
|
aida_java_net:
|
||||||
|
external: true
|
||||||
|
name: aida_java_net
|
||||||
EOF
|
EOF
|
||||||
# 验证docker-compose.yml生成
|
# 验证docker-compose.yml生成
|
||||||
echo "docker-compose.yml内容:"
|
echo "docker-compose.yml内容:"
|
||||||
|
|||||||
65
pom.xml
65
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>3.1.6</version>
|
<version>3.2.5</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.aida</groupId>
|
<groupId>com.aida</groupId>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<description>ai da</description>
|
<description>ai da</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>21</java.version>
|
<java.version>21</java.version>
|
||||||
<mybatis.plus.version>3.5.5</mybatis.plus.version>
|
<mybatis.plus.version>3.5.7</mybatis.plus.version>
|
||||||
<hutool.version>5.8.23</hutool.version>
|
<hutool.version>5.8.23</hutool.version>
|
||||||
<wx.java.version>4.2.7.B</wx.java.version>
|
<wx.java.version>4.2.7.B</wx.java.version>
|
||||||
<fastjson.version>2.0.43</fastjson.version>
|
<fastjson.version>2.0.43</fastjson.version>
|
||||||
@@ -28,6 +28,11 @@
|
|||||||
<javacv.version>1.5.5</javacv.version>
|
<javacv.version>1.5.5</javacv.version>
|
||||||
<system.windowsx64>windows-x86_64</system.windowsx64>
|
<system.windowsx64>windows-x86_64</system.windowsx64>
|
||||||
<javacpp.platform.linux-x86_64>linux-x86_64</javacpp.platform.linux-x86_64>
|
<javacpp.platform.linux-x86_64>linux-x86_64</javacpp.platform.linux-x86_64>
|
||||||
|
|
||||||
|
<!-- Spring Cloud Alibaba 版本 -->
|
||||||
|
<spring-cloud-alibaba.version>2023.0.3.4</spring-cloud-alibaba.version>
|
||||||
|
<!-- Spring Cloud 版本 -->
|
||||||
|
<spring-cloud.version>2023.0.4</spring-cloud.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -38,6 +43,22 @@
|
|||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Spring Cloud 依赖版本管理 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Spring Cloud Alibaba 依赖版本管理 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud-alibaba.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -74,9 +95,14 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||||
<version>${mybatis.plus.version}</version>
|
<version>${mybatis.plus.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis</groupId>
|
||||||
|
<artifactId>mybatis-spring</artifactId>
|
||||||
|
<version>3.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@@ -237,6 +263,12 @@
|
|||||||
<version>2.15.1</version>
|
<version>2.15.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.13.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.stripe</groupId>
|
<groupId>com.stripe</groupId>
|
||||||
<artifactId>stripe-java</artifactId>
|
<artifactId>stripe-java</artifactId>
|
||||||
@@ -432,6 +464,33 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-aop</artifactId>
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- ==================== Spring Cloud Alibaba 微服务相关 ==================== -->
|
||||||
|
<!-- 启用 bootstrap.yml 加载 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Nacos 服务注册与发现 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Nacos 配置中心 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- OpenFeign 服务调用 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Spring Cloud LoadBalancer 负载均衡 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.ai.da;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
@@ -10,6 +12,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
|
@EnableFeignClients
|
||||||
|
@EnableDiscoveryClient
|
||||||
public class AiDaApplication {
|
public class AiDaApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -559,83 +559,83 @@ public class GenerateConsumer {
|
|||||||
log.info("============ProcessPoseTransformResult End listening==========");
|
log.info("============ProcessPoseTransformResult End listening==========");
|
||||||
}
|
}
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void generateConsumer1(Message msg, Channel channel) {
|
// public void generateConsumer1(Message msg, Channel channel) {
|
||||||
generate(msg, channel, "consumer 1");
|
// generate(msg, channel, "consumer 1");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void generateConsumer2(Message msg, Channel channel) {
|
// public void generateConsumer2(Message msg, Channel channel) {
|
||||||
generate(msg, channel, "consumer 2");
|
// generate(msg, channel, "consumer 2");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void generateConsumer3(Message msg, Channel channel) {
|
// public void generateConsumer3(Message msg, Channel channel) {
|
||||||
generate(msg, channel, "consumer 3");
|
// generate(msg, channel, "consumer 3");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void generateConsumer4(Message msg, Channel channel) {
|
// public void generateConsumer4(Message msg, Channel channel) {
|
||||||
generate(msg, channel, "consumer 4");
|
// generate(msg, channel, "consumer 4");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void generateConsumer5(Message msg, Channel channel) {
|
// public void generateConsumer5(Message msg, Channel channel) {
|
||||||
generate(msg, channel, "consumer 5");
|
// generate(msg, channel, "consumer 5");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void generateConsumer6(Message msg, Channel channel) {
|
// public void generateConsumer6(Message msg, Channel channel) {
|
||||||
generate(msg, channel, "consumer 6");
|
// generate(msg, channel, "consumer 6");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void generateConsumer7(Message msg, Channel channel) {
|
// public void generateConsumer7(Message msg, Channel channel) {
|
||||||
generate(msg, channel, "consumer 7");
|
// generate(msg, channel, "consumer 7");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void generateConsumer8(Message msg, Channel channel) {
|
// public void generateConsumer8(Message msg, Channel channel) {
|
||||||
generate(msg, channel, "consumer 8");
|
// generate(msg, channel, "consumer 8");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void generateConsumer9(Message msg, Channel channel) {
|
// public void generateConsumer9(Message msg, Channel channel) {
|
||||||
generate(msg, channel, "consumer 9");
|
// generate(msg, channel, "consumer 9");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generateResult}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.generateResult}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void getGenerateResult(Message msg, Channel channel) {
|
// public void getGenerateResult(Message msg, Channel channel) {
|
||||||
processGenerateResult(msg, channel);
|
// processGenerateResult(msg, channel);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.toProductImageResult}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.toProductImageResult}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void getToProductImageResult(Message msg, Channel channel) {
|
// public void getToProductImageResult(Message msg, Channel channel) {
|
||||||
processToProductImageResult(msg, channel);
|
// processToProductImageResult(msg, channel);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.relightResult}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.relightResult}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void getRelightResult(Message msg, Channel channel) {
|
// public void getRelightResult(Message msg, Channel channel) {
|
||||||
processRelightResult(msg, channel);
|
// processRelightResult(msg, channel);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.poseTransform}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.poseTransform}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void getPoseTransformationResult(Message msg, Channel channel) {
|
// public void getPoseTransformationResult(Message msg, Channel channel) {
|
||||||
processPoseTransformResult(msg, channel);
|
// processPoseTransformResult(msg, channel);
|
||||||
}
|
// }
|
||||||
// @RabbitListener(queues = "#{rabbitMQProperties.queues.designBatch}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.designBatch}")
|
||||||
// @RabbitHandler
|
// @RabbitHandler
|
||||||
// public void getDesignBatchResult(Message msg, Channel channel) {
|
// public void getDesignBatchResult(Message msg, Channel channel) {
|
||||||
|
|||||||
@@ -222,16 +222,16 @@ public class SRConsumer {
|
|||||||
taskListService.updateTaskStatusOrOutputRedis(uniqueId, "fail", null);
|
taskListService.updateTaskStatusOrOutputRedis(uniqueId, "fail", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.sr}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.sr}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void SRConsumer1(Message msg, Channel channel) {
|
// public void SRConsumer1(Message msg, Channel channel) {
|
||||||
superResolution(msg, channel, "consumer 1");
|
// superResolution(msg, channel, "consumer 1");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.srResult}")
|
// @RabbitListener(queues = "#{rabbitMQProperties.queues.srResult}")
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void SRResultConsumer1(Message msg, Channel channel) {
|
// public void SRResultConsumer1(Message msg, Channel channel) {
|
||||||
getSRResult(msg, channel, "consumer 1");
|
// getSRResult(msg, channel, "consumer 1");
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
34
src/main/java/com/ai/da/common/config/SecurityConfig.java
Normal file
34
src/main/java/com/ai/da/common/config/SecurityConfig.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package com.ai.da.common.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||||
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spring Security 配置。
|
||||||
|
* 由于鉴权逻辑已迁移至 Gateway(GlobalAuthWebFilter),
|
||||||
|
* 后端服务 (aida-back) 默认放行所有请求,仅依赖网关传递的用户信息。
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@EnableWebSecurity
|
||||||
|
public class SecurityConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
|
http
|
||||||
|
// 禁用 CSRF(微服务通常不需要)
|
||||||
|
.csrf(AbstractHttpConfigurer::disable)
|
||||||
|
// 允许所有请求,具体鉴权在网关层完成
|
||||||
|
.authorizeHttpRequests(auth -> auth
|
||||||
|
.anyRequest().permitAll()
|
||||||
|
)
|
||||||
|
// 禁用默认的表单登录和 HTTP Basic 认证,防止 302 重定向
|
||||||
|
.formLogin(AbstractHttpConfigurer::disable)
|
||||||
|
.httpBasic(AbstractHttpConfigurer::disable);
|
||||||
|
|
||||||
|
return http.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,16 @@
|
|||||||
package com.ai.da.common.config;
|
package com.ai.da.common.config;
|
||||||
|
|
||||||
|
|
||||||
|
import com.ai.da.common.interceptor.UserContextInterceptor;
|
||||||
import org.hibernate.validator.HibernateValidator;
|
import org.hibernate.validator.HibernateValidator;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
|
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.Validation;
|
import jakarta.validation.Validation;
|
||||||
import jakarta.validation.Validator;
|
import jakarta.validation.Validator;
|
||||||
import jakarta.validation.ValidatorFactory;
|
import jakarta.validation.ValidatorFactory;
|
||||||
@@ -17,11 +20,20 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
|
|
||||||
static final String ORIGINS[] = new String[]{"GET", "POST", "PUT", "DELETE"};
|
static final String ORIGINS[] = new String[]{"GET", "POST", "PUT", "DELETE"};
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserContextInterceptor userContextInterceptor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
registry.addMapping("/**").allowedOriginPatterns("*").allowCredentials(true).allowedMethods(ORIGINS).maxAge(3600);
|
registry.addMapping("/**").allowedOriginPatterns("*").allowCredentials(true).allowedMethods(ORIGINS).maxAge(3600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(userContextInterceptor)
|
||||||
|
.addPathPatterns("/**");
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Validator validator() {
|
public Validator validator() {
|
||||||
ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class)
|
ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class)
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ import com.ai.da.common.response.Response;
|
|||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.ai.da.common.response.ResultEnum;
|
import com.ai.da.common.response.ResultEnum;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.validation.BindException;
|
import org.springframework.validation.BindException;
|
||||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: dangweijian
|
* @author: dangweijian
|
||||||
@@ -36,6 +38,14 @@ public class ExceptionCatch {
|
|||||||
return Response.error(e.getCode(), e.getMsg());
|
return Response.error(e.getCode(), e.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@ResponseStatus(HttpStatus.UNAUTHORIZED)
|
||||||
|
@ExceptionHandler(UnauthorizedException.class)
|
||||||
|
public Response<String> unauthorizedExceptionCatch(UnauthorizedException e) {
|
||||||
|
log.error("Unauthorized: {}", e.getMessage());
|
||||||
|
return Response.error(401, e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ExceptionHandler(Exception.class)
|
@ExceptionHandler(Exception.class)
|
||||||
public Response<String> exceptionCatch(Exception e) {
|
public Response<String> exceptionCatch(Exception e) {
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
package com.ai.da.common.config.exception;
|
|
||||||
|
|
||||||
public class TokenMissingOrExpiredException extends RuntimeException {
|
|
||||||
public TokenMissingOrExpiredException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Throwable fillInStackTrace() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.ai.da.common.config.exception;
|
||||||
|
|
||||||
|
public class UnauthorizedException extends RuntimeException {
|
||||||
|
|
||||||
|
public UnauthorizedException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnauthorizedException() {
|
||||||
|
super("Gateway token verification failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ public class CommonConstant {
|
|||||||
// 单位 秒 两天过期
|
// 单位 秒 两天过期
|
||||||
public static final Long CREDITS_EXPIRE_TIME = 2 * 24 * 60 * 60L;
|
public static final Long CREDITS_EXPIRE_TIME = 2 * 24 * 60 * 60L;
|
||||||
// 单位 分钟
|
// 单位 分钟
|
||||||
public static final Integer MINIO_IMAGE_EXPIRE_TIME = 24 * 60;
|
public static final Integer MINIO_IMAGE_EXPIRE_TIME = 24 * 60 * 7;
|
||||||
// 单位 秒 一天过期 in redis
|
// 单位 秒 一天过期 in redis
|
||||||
public static final Long GENERATE_RESULT_EXPIRE_TIME = 24 * 60 * 60L;
|
public static final Long GENERATE_RESULT_EXPIRE_TIME = 24 * 60 * 60L;
|
||||||
// 单位 秒 7天过期
|
// 单位 秒 7天过期
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ public class ModelConstants {
|
|||||||
|
|
||||||
// 模型名称常量
|
// 模型名称常量
|
||||||
public static final String PRINTBOARD_ADVANCED_T2I = "qwen-image";
|
public static final String PRINTBOARD_ADVANCED_T2I = "qwen-image";
|
||||||
public static final String MOODBOARD_ADVANCED = "doubao-seedream-3-0-t2i-250415";
|
public static final String MOODBOARD_ADVANCED = "doubao-seedream-4-5-251128";
|
||||||
public static final String PRINTBOARD_HIGH_T2I = "doubao-seedream-3-0-t2i-250415";
|
public static final String PRINTBOARD_HIGH_T2I = "doubao-seedream-4-0-250828-high";
|
||||||
public static final String PRINTBOARD_HIGH_I2I = "doubao-seedream-4-0-250828-fast";
|
public static final String PRINTBOARD_HIGH_I2I = "doubao-seedream-4-0-250828-fast";
|
||||||
public static final String PRINTBOARD_ADVANCED_I2I = "doubao-seedream-4-0-250828";
|
public static final String PRINTBOARD_ADVANCED_I2I = "doubao-seedream-4-0-250828";
|
||||||
public static final String IMAGEN_MODEL = "imagen-4.0-generate-001";
|
public static final String IMAGEN_MODEL = "imagen-4.0-generate-001";
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package com.ai.da.common.constant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author yanglei
|
|
||||||
* 异常类常量
|
|
||||||
*/
|
|
||||||
public class TokenConstant {
|
|
||||||
/**
|
|
||||||
* 固定session
|
|
||||||
*/
|
|
||||||
public static final String FIX_SESSION = "qrLS_003af9d8c1363fc4_6c97e932665c4460a1fdbfbf47ce3490";
|
|
||||||
|
|
||||||
public static final String PERMISSIONS = "9672233956";
|
|
||||||
}
|
|
||||||
@@ -3,17 +3,39 @@ package com.ai.da.common.context;
|
|||||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||||
|
|
||||||
public class UserContext {
|
public class UserContext {
|
||||||
private static ThreadLocal<AuthPrincipalVo> userHolder = new ThreadLocal<AuthPrincipalVo>();
|
private static final ThreadLocal<AuthPrincipalVo> userHolder = new ThreadLocal<>();
|
||||||
|
|
||||||
|
public static void setUserHolder(AuthPrincipalVo authPrincipalVo) {
|
||||||
|
userHolder.set(authPrincipalVo);
|
||||||
|
}
|
||||||
|
|
||||||
public static AuthPrincipalVo getUserHolder() {
|
public static AuthPrincipalVo getUserHolder() {
|
||||||
return userHolder.get();
|
AuthPrincipalVo holder = userHolder.get();
|
||||||
|
if (holder == null) {
|
||||||
|
throw new RuntimeException("User not authenticated");
|
||||||
|
}
|
||||||
|
if (!"AIDA".equals(holder.getSource())) {
|
||||||
|
throw new RuntimeException("Access denied: source must be AIDA");
|
||||||
|
}
|
||||||
|
return holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void delete() {
|
public static void delete() {
|
||||||
userHolder.remove();
|
userHolder.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setUserHolder(AuthPrincipalVo authPrincipalVo) {
|
public static Long getUserId() {
|
||||||
userHolder.set(authPrincipalVo);
|
return getUserHolder().getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Long getBuyerId() {
|
||||||
|
AuthPrincipalVo holder = userHolder.get();
|
||||||
|
if (holder == null) {
|
||||||
|
throw new RuntimeException("User not authenticated");
|
||||||
|
}
|
||||||
|
if (!"BUYER".equals(holder.getSource())) {
|
||||||
|
throw new RuntimeException("Access denied: source must be BUYER");
|
||||||
|
}
|
||||||
|
return holder.getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.ai.da.common.httpdata.token;
|
|
||||||
|
|
||||||
public enum TokenApis {
|
|
||||||
/**
|
|
||||||
* token
|
|
||||||
*/
|
|
||||||
GET_TOKEN("POST", "/api/openApi/v2/Weixin/QrCodeLoginCheck?session="),
|
|
||||||
GENERATE_USER("POST", "/api/openApi/v2/Welink/TopicGetjson");
|
|
||||||
|
|
||||||
private String method;
|
|
||||||
private String url;
|
|
||||||
|
|
||||||
TokenApis(String method, String url) {
|
|
||||||
this.method = method;
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMethod() {
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMethod(String method) {
|
|
||||||
this.method = method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUrl(String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package com.ai.da.common.httpdata.token;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.http.HttpResponse;
|
|
||||||
import cn.hutool.http.HttpUtil;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class TokenQuery {
|
|
||||||
|
|
||||||
private static final String GET_TOKEN_DOMAIN = "https://www.szsige.com";
|
|
||||||
private static final String GENERATE_USER_DOMAIN = "https://www.szsige.com";
|
|
||||||
|
|
||||||
public static JSONObject getToken(String session) {
|
|
||||||
String url = GET_TOKEN_DOMAIN + TokenApis.GET_TOKEN.getUrl() + session;
|
|
||||||
log.info("获取用户token接口请求url:" + url);
|
|
||||||
HttpResponse httpResponse = HttpUtil.createPost(url).execute();
|
|
||||||
log.info("获取用户token接口响应:" + httpResponse);
|
|
||||||
if (httpResponse.isOk() && StrUtil.isNotEmpty(httpResponse.body())) {
|
|
||||||
return JSONObject.parseObject(httpResponse.body());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JSONObject generateUser(Map<String, Object> param, String token) {
|
|
||||||
HttpResponse httpResponse = HttpUtil.createPost(GENERATE_USER_DOMAIN + TokenApis.GENERATE_USER.getUrl())
|
|
||||||
.body(JSONObject.toJSONString(param != null ? param : new HashMap<>()))
|
|
||||||
.header("Authorization", "Bearer " + token)
|
|
||||||
.header("X-Promiss", "9672233956")
|
|
||||||
.execute();
|
|
||||||
log.info("生成用户信息接口响应:" + httpResponse);
|
|
||||||
if (httpResponse.isOk() && StrUtil.isNotEmpty(httpResponse.body())) {
|
|
||||||
return JSONObject.parseObject(httpResponse.body());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.ai.da.common.interceptor;
|
||||||
|
|
||||||
|
import com.ai.da.common.context.UserContext;
|
||||||
|
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从 Gateway 转发的请求头中读取已鉴权的用户身份,写入 UserContext。
|
||||||
|
* <p>
|
||||||
|
* Gateway 验证 JWT 后将 X-User-Id 和 X-User-Info 写入请求头,
|
||||||
|
* 此拦截器负责将信息填充到 ThreadLocal,供业务代码使用。
|
||||||
|
* 不需要 Gateway 鉴权路径(如 login、静态资源)不会有这两个头,
|
||||||
|
* 此时 UserContext 保持为空,业务代码应自行处理。
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class UserContextInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
|
private static final String USER_ID_HEADER = "X-User-Id";
|
||||||
|
private static final String USER_INFO_HEADER = "X-User-Info";
|
||||||
|
|
||||||
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||||
|
String userInfoJson = request.getHeader(USER_INFO_HEADER);
|
||||||
|
if (userInfoJson != null && !userInfoJson.isBlank()) {
|
||||||
|
try {
|
||||||
|
AuthPrincipalVo principal = objectMapper.readValue(userInfoJson, AuthPrincipalVo.class);
|
||||||
|
UserContext.setUserHolder(principal);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Failed to parse X-User-Info header: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
|
||||||
|
Object handler, Exception ex) {
|
||||||
|
UserContext.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.ai.da.common.security;
|
|
||||||
|
|
||||||
import com.ai.da.common.response.Response;
|
|
||||||
import com.ai.da.common.response.ResultEnum;
|
|
||||||
import com.ai.da.common.utils.JSONResponseUtils;
|
|
||||||
import org.springframework.security.access.AccessDeniedException;
|
|
||||||
import org.springframework.security.web.access.AccessDeniedHandler;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName UserAuthAccessDeniedHandler
|
|
||||||
* @Description 无权限处理类
|
|
||||||
* @Author dwjian
|
|
||||||
* @Date 2020/7/9 20:30
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class UserAuthAccessDeniedHandler implements AccessDeniedHandler {
|
|
||||||
@Override
|
|
||||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException exception) throws IOException {
|
|
||||||
Response<String> response = Response.error(ResultEnum.NO_PERMISSION.getCode(), ResultEnum.NO_PERMISSION.getMsg());
|
|
||||||
JSONResponseUtils.build(httpServletResponse, response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package com.ai.da.common.security;
|
|
||||||
|
|
||||||
import com.ai.da.common.response.Response;
|
|
||||||
import com.ai.da.common.response.ResultEnum;
|
|
||||||
import com.ai.da.common.utils.JSONResponseUtils;
|
|
||||||
import org.springframework.security.core.AuthenticationException;
|
|
||||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName UserAuthenticationEntryPointHandler
|
|
||||||
* @Description 未登录处理类
|
|
||||||
* @Author dwjian
|
|
||||||
* @Date 2020/7/9 20:13
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class UserAuthenticationEntryPointHandler implements AuthenticationEntryPoint {
|
|
||||||
@Override
|
|
||||||
public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
|
|
||||||
Response<String> response = Response.error(ResultEnum.NO_LOGIN.getCode(), ResultEnum.NO_LOGIN.getMsg());
|
|
||||||
httpServletResponse.setStatus(401);
|
|
||||||
JSONResponseUtils.build(httpServletResponse, response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package com.ai.da.common.security;
|
|
||||||
|
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.security.core.AuthenticationException;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: dangweijian
|
|
||||||
* @description: 认证管理器
|
|
||||||
* @create: 2020-07-10 15:58
|
|
||||||
**/
|
|
||||||
@Component
|
|
||||||
public class UserAuthenticationManager implements AuthenticationManager {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private UserAuthenticationProvider userAuthenticationProvider;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
|
||||||
return userAuthenticationProvider.authenticate(authentication);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
package com.ai.da.common.security;
|
|
||||||
|
|
||||||
import com.ai.da.common.config.RsaProperties;
|
|
||||||
import com.ai.da.common.utils.RsaDecryptUtils;
|
|
||||||
import org.springframework.security.authentication.AuthenticationProvider;
|
|
||||||
import org.springframework.security.authentication.BadCredentialsException;
|
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.security.core.AuthenticationException;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: dangweijian
|
|
||||||
* @description: 登录校验处理类
|
|
||||||
* @create: 2020-07-09 14:39
|
|
||||||
**/
|
|
||||||
@Component
|
|
||||||
public class UserAuthenticationProvider implements AuthenticationProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
|
||||||
String userName = (String) authentication.getPrincipal();
|
|
||||||
String password = (String) authentication.getCredentials();
|
|
||||||
try {
|
|
||||||
password = RsaDecryptUtils.decrypt(password, RsaProperties.privateKey);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new BadCredentialsException("用户名或密码错误");
|
|
||||||
}
|
|
||||||
// User user = userService.getByUsername(userName);
|
|
||||||
// if (user == null) {
|
|
||||||
// throw new UsernameNotFoundException("用户名或密码错误");
|
|
||||||
// }
|
|
||||||
// //账号已冻结
|
|
||||||
// if(user.getStatus() == 1){
|
|
||||||
// throw new LockedException("账号已冻结");
|
|
||||||
// }
|
|
||||||
// if(!passwordEncoder.matches(password, user.getPassword())){
|
|
||||||
// throw new BadCredentialsException("用户名或密码错误");
|
|
||||||
// }
|
|
||||||
// //超级管理员
|
|
||||||
// Set<SimpleGrantedAuthority> authorities = new HashSet<>();
|
|
||||||
// if(user.getIsAdmin()) {
|
|
||||||
// authorities.add(new SimpleGrantedAuthority("admin"));
|
|
||||||
// return new UsernamePasswordAuthenticationToken(user, password, authorities);
|
|
||||||
// }else {
|
|
||||||
// List<RoleMenuDto> userMenus = menuService.getRoleMenusByUserId(user.getId(), null);
|
|
||||||
// if(CollUtil.isNotEmpty(userMenus)){
|
|
||||||
// authorities.addAll(userMenus.stream().map(RoleMenuDto::getPermission).filter(StringUtils::isNotEmpty).map(SimpleGrantedAuthority::new).collect(Collectors.toSet()));
|
|
||||||
// }
|
|
||||||
// return new UsernamePasswordAuthenticationToken(user, password, authorities);
|
|
||||||
// }
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supports(Class<?> aClass) {
|
|
||||||
return UsernamePasswordAuthenticationToken.class.isAssignableFrom(aClass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
package com.ai.da.common.security;
|
|
||||||
|
|
||||||
import com.ai.da.common.response.Response;
|
|
||||||
import com.ai.da.common.response.ResultEnum;
|
|
||||||
import com.ai.da.common.utils.JSONResponseUtils;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.security.authentication.*;
|
|
||||||
import org.springframework.security.core.AuthenticationException;
|
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|
||||||
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName UserLoginFailureHandler
|
|
||||||
* @Description 登录失败处理类
|
|
||||||
* @Author dwjian
|
|
||||||
* @Date 2020/7/9 20:17
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class UserLoginFailureHandler implements AuthenticationFailureHandler {
|
|
||||||
@Override
|
|
||||||
public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
|
|
||||||
Response<String> response;
|
|
||||||
if (e instanceof UsernameNotFoundException || e instanceof BadCredentialsException) {
|
|
||||||
response = Response.fail(e.getMessage());
|
|
||||||
} else if (e instanceof LockedException) {
|
|
||||||
response = Response.fail(ResultEnum.ACCOUNT_LOCK);
|
|
||||||
} else if (e instanceof CredentialsExpiredException) {
|
|
||||||
response = Response.fail("证书过期,请联系管理员!");
|
|
||||||
} else if (e instanceof AccountExpiredException) {
|
|
||||||
response = Response.fail("账户过期,请联系管理员!");
|
|
||||||
} else if (e instanceof DisabledException) {
|
|
||||||
response = Response.fail("账户被禁用,请联系管理员!");
|
|
||||||
} else if (e instanceof AuthenticationServiceException) {
|
|
||||||
response = Response.fail(e.getMessage());
|
|
||||||
} else {
|
|
||||||
log.error("登录失败:", e);
|
|
||||||
response = Response.fail("登录失败!");
|
|
||||||
}
|
|
||||||
JSONResponseUtils.build(httpServletResponse, response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
package com.ai.da.common.security;
|
|
||||||
|
|
||||||
import com.ai.da.common.response.ResultEnum;
|
|
||||||
import com.ai.da.common.utils.JSONResponseUtils;
|
|
||||||
import com.ai.da.common.response.Response;
|
|
||||||
import com.ai.da.common.security.jwt.JWTTokenHelper;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: dangweijian
|
|
||||||
* @description: 登录成功处理类
|
|
||||||
* @create: 2020-07-09 14:58
|
|
||||||
**/
|
|
||||||
@Component
|
|
||||||
public class UserLoginSuccessHandler implements AuthenticationSuccessHandler {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private JWTTokenHelper jwtTokenHelper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
|
||||||
// User user = (User) authentication.getPrincipal();
|
|
||||||
// AuthPrincipalVo principal = new AuthPrincipalVo();
|
|
||||||
// BeanUtils.copyProperties(user, principal);
|
|
||||||
// // 获取用户角色
|
|
||||||
// List<UserRoleDto> userRoles = roleService.getUserRoles(user.getId(), 0);
|
|
||||||
// principal.setRoles(userRoles);
|
|
||||||
// // 获取角色部门
|
|
||||||
// if(CollUtil.isNotEmpty(userRoles)){
|
|
||||||
// principal.setDepts(deptService.getDeptByRoleIds(userRoles.stream().map(UserRoleDto::getRoleId).collect(Collectors.toList())));
|
|
||||||
// }
|
|
||||||
// // 用户角色权限
|
|
||||||
// List<String> authorities = new ArrayList<>(authentication.getAuthorities()).stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
|
|
||||||
// principal.setAuthorities(authorities);
|
|
||||||
// AuthVo authVo = new AuthVo();
|
|
||||||
// authVo.setAuthorities(authorities);
|
|
||||||
// authVo.setToken(jwtTokenHelper.createToken(principal));
|
|
||||||
// authVo.setPrincipal(principal);
|
|
||||||
// user.setLastLoginTime(new Date());
|
|
||||||
// userService.updateById(user);
|
|
||||||
JSONResponseUtils.build(response, Response.success(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(), null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package com.ai.da.common.security;
|
|
||||||
|
|
||||||
import org.springframework.security.access.PermissionEvaluator;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName UserPermissionEvaluator
|
|
||||||
* @Description 权限校验处理器
|
|
||||||
* @Author dwjian
|
|
||||||
* @Date 2020/7/12 10:16
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class UserPermissionEvaluator implements PermissionEvaluator {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPermission(Authentication authentication, Object targetUrl, Object permission) {
|
|
||||||
System.out.println(authentication);
|
|
||||||
System.out.println(targetUrl);
|
|
||||||
System.out.println(permission);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType, Object permission) {
|
|
||||||
System.out.println(authentication);
|
|
||||||
System.out.println(targetId);
|
|
||||||
System.out.println(targetType);
|
|
||||||
System.out.println(permission);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
package com.ai.da.common.security.config;
|
|
||||||
|
|
||||||
import com.ai.da.common.security.*;
|
|
||||||
import com.ai.da.common.security.filter.AuthenticationFilter;
|
|
||||||
import com.ai.da.common.security.filter.UserAuthenticationProcessingFilter;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
|
||||||
import org.springframework.security.config.Customizer;
|
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
|
||||||
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
|
|
||||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
|
||||||
import org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler;
|
|
||||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
|
||||||
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
|
|
||||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableWebSecurity
|
|
||||||
@EnableMethodSecurity(prePostEnabled = true)
|
|
||||||
@EnableConfigurationProperties(SecurityProperties.class)
|
|
||||||
public class SecurityConfig {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private SecurityProperties securityProperties;
|
|
||||||
@Resource
|
|
||||||
private UserLoginSuccessHandler userLoginSuccessHandler;
|
|
||||||
@Resource
|
|
||||||
private UserLoginFailureHandler userLoginFailureHandler;
|
|
||||||
@Resource
|
|
||||||
private UserAuthAccessDeniedHandler userAuthAccessDeniedHandler;
|
|
||||||
@Resource
|
|
||||||
private UserAuthenticationEntryPointHandler userAuthenticationEntryPointHandler;
|
|
||||||
@Resource
|
|
||||||
private UserAuthenticationManager userAuthenticationManager;
|
|
||||||
@Resource
|
|
||||||
private UserAuthenticationProcessingFilter userAuthenticationProcessingFilter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 不通过注入spring管理 让Security来管理 这样自定义的Filter就不会走,.permitAll()才能起作用
|
|
||||||
*/
|
|
||||||
@Resource
|
|
||||||
private AuthenticationFilter authenticationFilter;
|
|
||||||
@Resource
|
|
||||||
private UserPermissionEvaluator userPermissionEvaluator;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public AuthenticationManager authenticationManager() throws Exception {
|
|
||||||
return this.userAuthenticationManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception {
|
|
||||||
httpSecurity
|
|
||||||
.cors(Customizer.withDefaults())
|
|
||||||
.authorizeHttpRequests(auth -> auth
|
|
||||||
.requestMatchers(
|
|
||||||
new AntPathRequestMatcher("/doc.html"),
|
|
||||||
new AntPathRequestMatcher("/swagger-ui.html"),
|
|
||||||
new AntPathRequestMatcher("/swagger-ui/**"),
|
|
||||||
new AntPathRequestMatcher("/swagger-resources/**"),
|
|
||||||
new AntPathRequestMatcher("/v2/api-docs"),
|
|
||||||
new AntPathRequestMatcher("/v3/api-docs/**"),
|
|
||||||
new AntPathRequestMatcher("/webjars/**")
|
|
||||||
).permitAll()
|
|
||||||
.requestMatchers(securityProperties.getIgnorePaths()).permitAll()
|
|
||||||
.anyRequest().authenticated()
|
|
||||||
)
|
|
||||||
.headers(headers -> headers
|
|
||||||
.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)
|
|
||||||
.cacheControl(cache -> cache.disable())
|
|
||||||
)
|
|
||||||
.exceptionHandling(exception -> exception
|
|
||||||
.authenticationEntryPoint(userAuthenticationEntryPointHandler)
|
|
||||||
.accessDeniedHandler(userAuthAccessDeniedHandler)
|
|
||||||
)
|
|
||||||
.formLogin(form -> form
|
|
||||||
.loginProcessingUrl(securityProperties.getAuthApi())
|
|
||||||
.successHandler(userLoginSuccessHandler)
|
|
||||||
.failureHandler(userLoginFailureHandler)
|
|
||||||
)
|
|
||||||
.csrf(AbstractHttpConfigurer::disable)
|
|
||||||
.sessionManagement(session -> session
|
|
||||||
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
|
||||||
);
|
|
||||||
|
|
||||||
//自定义过滤器在登录时认证用户名、密码
|
|
||||||
httpSecurity.addFilterAt(userAuthenticationProcessingFilter, UsernamePasswordAuthenticationFilter.class)
|
|
||||||
.addFilterBefore(authenticationFilter, BasicAuthenticationFilter.class);
|
|
||||||
|
|
||||||
return httpSecurity.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public DefaultWebSecurityExpressionHandler userSecurityExpressionHandler() {
|
|
||||||
DefaultWebSecurityExpressionHandler handler = new DefaultWebSecurityExpressionHandler();
|
|
||||||
handler.setPermissionEvaluator(userPermissionEvaluator);
|
|
||||||
return handler;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.ai.da.common.security.config;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: dangweijian
|
|
||||||
* @description: JWT配置类
|
|
||||||
* @create: 2020-07-09 09:38
|
|
||||||
**/
|
|
||||||
@Data
|
|
||||||
@ConfigurationProperties(prefix = "spring.security")
|
|
||||||
public class SecurityProperties {
|
|
||||||
|
|
||||||
private String jwtSecret;
|
|
||||||
|
|
||||||
private String jwtTokenHeader;
|
|
||||||
|
|
||||||
private String jwtTokenPrefix;
|
|
||||||
|
|
||||||
private long jwtExpiration;
|
|
||||||
|
|
||||||
private String[] ignorePaths;
|
|
||||||
|
|
||||||
private String authApi;
|
|
||||||
}
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
package com.ai.da.common.security.filter;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.ai.da.common.config.exception.TokenMissingOrExpiredException;
|
|
||||||
import com.ai.da.common.context.UserContext;
|
|
||||||
import com.ai.da.common.security.config.SecurityProperties;
|
|
||||||
import com.ai.da.common.security.jwt.JWTTokenHelper;
|
|
||||||
import com.ai.da.common.utils.LocalCacheUtils;
|
|
||||||
import com.ai.da.common.utils.RedisUtil;
|
|
||||||
import com.ai.da.common.utils.MultiReadHttpServletRequest;
|
|
||||||
import com.ai.da.common.utils.MultiReadHttpServletResponse;
|
|
||||||
import com.ai.da.common.utils.RequestInfoUtil;
|
|
||||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.lang.NonNull;
|
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.util.StopWatch;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import org.springframework.web.filter.OncePerRequestFilter;
|
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import jakarta.servlet.FilterChain;
|
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: dangweijian
|
|
||||||
* @description: 认证拦截器
|
|
||||||
* @create: 2020-07-10 16:50
|
|
||||||
**/
|
|
||||||
@Slf4j
|
|
||||||
@Configuration
|
|
||||||
public class AuthenticationFilter extends OncePerRequestFilter {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private JWTTokenHelper jwtTokenHelper;
|
|
||||||
@Resource
|
|
||||||
private SecurityProperties properties;
|
|
||||||
@Resource
|
|
||||||
private RedisUtil redisUtil;
|
|
||||||
|
|
||||||
private static final List<String> FILTER_URL =
|
|
||||||
Arrays.asList("/favicon.ico", "/doc.html", "/swagger-ui.html",
|
|
||||||
"/swagger-resources", "/swagger-resources/", "/swagger-resources/configuration/ui", "/swagger-resources/configuration/security",
|
|
||||||
"/webjars/", "/v2/api-docs", "/v3/api-docs", "/v3/api-docs/swagger-config",
|
|
||||||
"/api/account/login", "/api/account/preLogin", "api/account/sendEmail","api/account/noLoginRequired",
|
|
||||||
"/api/account/resetPwd",
|
|
||||||
"/api/python/saveGeneratePicture", "/api/python/getLibraryByUserId",
|
|
||||||
"/api/third/party/addUser","/api/third/party/addTrialUser", "/api/third/party/editUser", "/api/element/initDefaultSysFile",
|
|
||||||
"/api/third/party/addNoLoginRequiredNew","/api/third/party/deleteNoLoginRequiredNew","/api/third/party/updateNoLoginRequiredNew",
|
|
||||||
"/api/third/party/existNoLoginRequired","/api/third/party/getRedirectUrl",
|
|
||||||
"/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify",
|
|
||||||
"/api/portfolio/page", "/api/portfolio/detail", "/api/portfolio/commentPage", "/api/portfolio/viewsIncrease",
|
|
||||||
"/api/account/designWorksRegister","/api/account/questionnaire","/api/stripe/trade/notify",
|
|
||||||
"/notification","/api/account/activateNewEmail","/api/third/party/auth/google_callback","/api/third/party/parseGoogleCredential","/api/third/party/receiveDesignResults","/api/third/party/parseWeChatCode","/api/third/party/receiveDesignParams"
|
|
||||||
, "/api/account/schoolLogin", "/api/account/enterpriseLogin", "/api/account/organizationNameSearch",
|
|
||||||
"/api/llm/stream",
|
|
||||||
//GlobalAwardController
|
|
||||||
"/api/global-award/uploads/pdf/init", "/api/global-award/uploads/pdf/chunk", "/api/global-award/uploads/pdf/complete", "/api/global-award/uploads/pdf/status",
|
|
||||||
"/api/global-award/uploads/video/init", "/api/global-award/uploads/video/chunk", "/api/global-award/uploads/video/complete", "/api/global-award/uploads/video/status",
|
|
||||||
"/api/global-award/contestants/save", "/api/global-award/contestants/by-email", "/api/global-award/checkEmail", "/api/global-award/checkCode","/api/global-award/contestants/export",
|
|
||||||
"/api/global-award/contestants/export/files"
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doFilterInternal(HttpServletRequest httpServletRequest, @NonNull HttpServletResponse httpServletResponse, @NonNull FilterChain filterChain) throws ServletException, IOException {
|
|
||||||
String requestURI = httpServletRequest.getRequestURI();
|
|
||||||
|
|
||||||
if (calculateUrl(requestURI)/* || hasAuthorizationToken(httpServletRequest)*/) {
|
|
||||||
StopWatch stopWatch = new StopWatch();
|
|
||||||
HttpServletRequest wrappedRequest = httpServletRequest;
|
|
||||||
HttpServletResponse wrappedResponse = httpServletResponse;
|
|
||||||
try {
|
|
||||||
stopWatch.start();
|
|
||||||
if ((httpServletRequest.getContentType() == null && httpServletRequest.getContentLength() > 0) || (httpServletRequest.getContentType() != null && !httpServletRequest.getContentType().contains("application/json"))) {
|
|
||||||
extracted(wrappedRequest);
|
|
||||||
filterChain.doFilter(wrappedRequest, wrappedResponse);
|
|
||||||
} else {
|
|
||||||
wrappedRequest = new MultiReadHttpServletRequest(httpServletRequest);
|
|
||||||
wrappedResponse = new MultiReadHttpServletResponse(httpServletResponse);
|
|
||||||
extracted(wrappedRequest);
|
|
||||||
// excel导出使用原始response,不对响应做包装
|
|
||||||
if (requestURI.equals("/api/account/exportAccountsToExcel")) {
|
|
||||||
filterChain.doFilter(httpServletRequest, httpServletResponse); // 不包装
|
|
||||||
} else {
|
|
||||||
filterChain.doFilter(wrappedRequest, wrappedResponse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
SecurityContextHolder.clearContext();
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
stopWatch.stop();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//先清空当前线程变量,防止上一个线程遗留
|
|
||||||
UserContext.delete();
|
|
||||||
filterChain.doFilter(httpServletRequest, httpServletResponse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean calculateUrl(String requestURI) {
|
|
||||||
String filterUrl = FILTER_URL.stream().filter(url -> requestURI.contains(url)).findFirst().orElse(null);
|
|
||||||
return null == filterUrl ? Boolean.TRUE : Boolean.FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasAuthorizationToken(HttpServletRequest request) {
|
|
||||||
String authorizationHeader = request.getHeader("Authorization");
|
|
||||||
return authorizationHeader != null && authorizationHeader.startsWith("Bearer");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void extracted(HttpServletRequest request) {
|
|
||||||
String jwtToken = request.getHeader(properties.getJwtTokenHeader());
|
|
||||||
// log.debug("后台检查令牌:{}", jwtToken);
|
|
||||||
|
|
||||||
if (StrUtil.isBlank(jwtToken)) {
|
|
||||||
String ipAddress = RequestInfoUtil.getIpAddress(request);
|
|
||||||
log.info("本次请求的ip为 : " + ipAddress);
|
|
||||||
// throw new RuntimeException("请传入token!");
|
|
||||||
throw new TokenMissingOrExpiredException("请传入token!");
|
|
||||||
}
|
|
||||||
if(jwtToken.equals("Bearer-eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiIyIiwic3ViIjoie1wiaWRcIjoyLFwidXNlcm5hbWVcIjpcImxpcnNcIn0iLCJpYXQiOjE2NjU3NDEwODcsImlzcyI6IkRXSiIsImF1dGhvcml0aWVzIjoiW10iLCJleHAiOjE2NzQzODEwODd9.ShM9R_NNFD7oo1OvxrEgg7PFeWinOuAKkuInUCMQupp66s64Hhv8tN0Wwr83nIN4rHPqtn95wmd4msWcvaFYJA")){
|
|
||||||
//写死 暂时放行
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 检查token
|
|
||||||
boolean validate = jwtTokenHelper.validateToken(jwtToken);
|
|
||||||
if (validate) {
|
|
||||||
AuthPrincipalVo principal = jwtTokenHelper.parserToUser(jwtToken);
|
|
||||||
if (principal == null) {
|
|
||||||
// throw new RuntimeException("TOKEN已过期,请重新登录!");
|
|
||||||
throw new TokenMissingOrExpiredException("TOKEN已过期,请重新登录!(token without userInfo)");
|
|
||||||
}
|
|
||||||
//先清空当前线程变量,防止上一个线程遗留
|
|
||||||
UserContext.delete();
|
|
||||||
//存取用户信息到缓存
|
|
||||||
UserContext.setUserHolder(principal);
|
|
||||||
// 校验 token:先查本地缓存,再查 Redis,保证服务重启后仍然有效
|
|
||||||
String userIdStr = String.valueOf(principal.getId());
|
|
||||||
String cacheToken = LocalCacheUtils.getTokenCache(userIdStr);
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(cacheToken)) {
|
|
||||||
// 本地缓存为空时,尝试从 Redis 读取
|
|
||||||
cacheToken = redisUtil.getLoginToken(principal.getId());
|
|
||||||
if (StringUtils.isEmpty(cacheToken)) {
|
|
||||||
// throw new RuntimeException("TOKEN已过期,请重新登录!");
|
|
||||||
throw new TokenMissingOrExpiredException("TOKEN已过期,请重新登录!(cache & redis empty)");
|
|
||||||
}
|
|
||||||
// 将 Redis 中的 token 回填到本地缓存,减少后续 Redis 访问
|
|
||||||
LocalCacheUtils.setTokenCache(userIdStr, cacheToken);
|
|
||||||
}
|
|
||||||
if(!cacheToken.equals(jwtToken) ){
|
|
||||||
// throw new RuntimeException("TOKEN已过期,请重新登录!");
|
|
||||||
throw new TokenMissingOrExpiredException("TOKEN已过期,请重新登录!(token not match local cache)");
|
|
||||||
}
|
|
||||||
// UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(null, null);
|
|
||||||
// SecurityContextHolder.getContext().setAuthentication(authentication);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
package com.ai.da.common.security.filter;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.ai.da.common.security.UserLoginSuccessHandler;
|
|
||||||
import com.ai.da.common.security.config.SecurityProperties;
|
|
||||||
import com.ai.da.common.utils.RedisCacheUtils;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.ai.da.common.security.UserAuthenticationManager;
|
|
||||||
import com.ai.da.common.security.UserLoginFailureHandler;
|
|
||||||
import com.ai.da.common.utils.MultiReadHttpServletRequest;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.security.authentication.AuthenticationServiceException;
|
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.security.core.AuthenticationException;
|
|
||||||
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
|
|
||||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: dangweijian
|
|
||||||
* @description: 用户认证过滤器
|
|
||||||
* @create: 2020-07-10 15:58
|
|
||||||
**/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class UserAuthenticationProcessingFilter extends AbstractAuthenticationProcessingFilter {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param securityProperties 配置(从配置中读取登录url)
|
|
||||||
* @param authenticationManager 认证管理器
|
|
||||||
* @param adminAuthenticationSuccessHandler 认证成功处理器
|
|
||||||
* @param adminAuthenticationFailureHandler 认证失败处理器
|
|
||||||
*/
|
|
||||||
public UserAuthenticationProcessingFilter(SecurityProperties securityProperties, UserAuthenticationManager authenticationManager, UserLoginSuccessHandler adminAuthenticationSuccessHandler, UserLoginFailureHandler adminAuthenticationFailureHandler) {
|
|
||||||
super(new AntPathRequestMatcher(securityProperties.getAuthApi(), HttpMethod.POST.name()));
|
|
||||||
this.setAuthenticationManager(authenticationManager);
|
|
||||||
this.setAuthenticationSuccessHandler(adminAuthenticationSuccessHandler);
|
|
||||||
this.setAuthenticationFailureHandler(adminAuthenticationFailureHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
|
|
||||||
if (request.getContentType() == null || !request.getContentType().contains("application/json")) {
|
|
||||||
throw new AuthenticationServiceException("请求头类型不支持: " + request.getContentType());
|
|
||||||
}
|
|
||||||
UsernamePasswordAuthenticationToken authRequest;
|
|
||||||
try {
|
|
||||||
MultiReadHttpServletRequest wrappedRequest = new MultiReadHttpServletRequest(request);
|
|
||||||
// 将前端传递的数据转换成jsonBean数据格式
|
|
||||||
JSONObject jsonObject = JSONObject.parseObject(wrappedRequest.getBodyJsonStrByJson(wrappedRequest));
|
|
||||||
String code = jsonObject.getString("code");
|
|
||||||
String uuid = jsonObject.getString("uuid");
|
|
||||||
if (StrUtil.isEmpty(code) || StrUtil.isEmpty(uuid) || !code.equals(RedisCacheUtils.get("code-key-" + uuid, String.class))) {
|
|
||||||
throw new AuthenticationServiceException("验证码错误");
|
|
||||||
}
|
|
||||||
RedisCacheUtils.delete("code-key-" + uuid);
|
|
||||||
authRequest = new UsernamePasswordAuthenticationToken(jsonObject.get("username"), jsonObject.get("password"), null);
|
|
||||||
authRequest.setDetails(authenticationDetailsSource.buildDetails(wrappedRequest));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new AuthenticationServiceException(e.getMessage());
|
|
||||||
}
|
|
||||||
return this.getAuthenticationManager().authenticate(authRequest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
package com.ai.da.common.security.jwt;
|
|
||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.crypto.digest.DigestUtil;
|
|
||||||
import com.ai.da.common.constant.CommonConstant;
|
|
||||||
import com.ai.da.common.security.config.SecurityProperties;
|
|
||||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import io.jsonwebtoken.Claims;
|
|
||||||
import io.jsonwebtoken.Jwts;
|
|
||||||
import io.jsonwebtoken.security.Keys;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import javax.crypto.SecretKey;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: dangweijian
|
|
||||||
* @description: JWT工具
|
|
||||||
* @create: 2020-07-09 09:27
|
|
||||||
**/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class JWTTokenHelper {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private SecurityProperties securityProperties;
|
|
||||||
|
|
||||||
private static final String ISSUER = "DWJ";
|
|
||||||
private static final String AUTHORITIES = "authorities";
|
|
||||||
private static final String CHANGE_MAILBOX = "changeMailbox";
|
|
||||||
|
|
||||||
public String createToken(AuthPrincipalVo principal) {
|
|
||||||
SecretKey key = buildSigningKey();
|
|
||||||
String token = Jwts.builder()
|
|
||||||
.id(String.valueOf(principal.getId()))
|
|
||||||
.subject(JSONObject.toJSONString(principal))
|
|
||||||
.issuedAt(new Date())
|
|
||||||
.issuer(ISSUER)
|
|
||||||
.claim(AUTHORITIES, JSON.toJSONString(new ArrayList<>()))//自定义属性 权限
|
|
||||||
.expiration(new Date(System.currentTimeMillis() + securityProperties.getJwtExpiration()))
|
|
||||||
.signWith(key)
|
|
||||||
.compact();
|
|
||||||
token = securityProperties.getJwtTokenPrefix() + token;
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean validateToken(String token) {
|
|
||||||
Claims claims = parser(token);
|
|
||||||
if (MapUtil.isEmpty(claims)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthPrincipalVo parserToUser(String token) {
|
|
||||||
String subject = parser(token).getSubject();
|
|
||||||
if (StrUtil.isNotEmpty(subject)) {
|
|
||||||
return JSONObject.parseObject(subject, AuthPrincipalVo.class);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Claims parser(String token) {
|
|
||||||
token = token.replaceAll(securityProperties.getJwtTokenPrefix(), "");
|
|
||||||
SecretKey key = buildSigningKey();
|
|
||||||
return Jwts.parser()
|
|
||||||
.verifyWith(key)
|
|
||||||
.build()
|
|
||||||
.parseSignedClaims(token)
|
|
||||||
.getPayload();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String createToken(Long userId, String userEmail){
|
|
||||||
SecretKey key = buildSigningKey();
|
|
||||||
String token = Jwts.builder()
|
|
||||||
.id(String.valueOf(userId))
|
|
||||||
.subject(userEmail + "_" + userId)
|
|
||||||
.issuedAt(new Date())
|
|
||||||
.issuer(ISSUER)
|
|
||||||
.claim(CHANGE_MAILBOX, JSON.toJSONString(new ArrayList<>()))//自定义属性 权限
|
|
||||||
.expiration(new Date(System.currentTimeMillis() + CommonConstant.CHANGE_MAILBOX_LINK_VALIDITY))
|
|
||||||
.signWith(key)
|
|
||||||
.compact();
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String parseToEmailAndId(String token) {
|
|
||||||
return parser(token).getSubject();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JWT 要求 HMAC-SHA 的密钥至少 256 bit,这里统一扩展/哈希密钥长度避免 WeakKeyException。
|
|
||||||
*/
|
|
||||||
private SecretKey buildSigningKey() {
|
|
||||||
byte[] raw = securityProperties.getJwtSecret().getBytes(StandardCharsets.UTF_8);
|
|
||||||
if (raw.length < 32) {
|
|
||||||
raw = DigestUtil.sha256(raw);
|
|
||||||
}
|
|
||||||
return Keys.hmacShaKeyFor(raw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -28,7 +28,7 @@ public class AccountTask {
|
|||||||
* 每个月月初只刷新教育子账号的积分
|
* 每个月月初只刷新教育子账号的积分
|
||||||
*/
|
*/
|
||||||
// @Scheduled(cron = "0 25 14 * * ?")
|
// @Scheduled(cron = "0 25 14 * * ?")
|
||||||
@Scheduled(cron = "0 0 0 1 * ?")
|
// @Scheduled(cron = "0 0 0 1 * ?")
|
||||||
public void refreshCreditsMonthly() {
|
public void refreshCreditsMonthly() {
|
||||||
log.info("每月1号0点 重置教育版子账号为默认积分");
|
log.info("每月1号0点 重置教育版子账号为默认积分");
|
||||||
accountService.refreshCreditsMonthly();
|
accountService.refreshCreditsMonthly();
|
||||||
@@ -54,7 +54,7 @@ public class AccountTask {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
// 每天检测正式用户到期情况,每天凌晨0点执行
|
// 每天检测正式用户到期情况,每天凌晨0点执行
|
||||||
@Scheduled(cron = "0 0 0 * * ?")
|
// @Scheduled(cron = "0 0 0 * * ?")
|
||||||
public void paidUserToVisitor() {
|
public void paidUserToVisitor() {
|
||||||
// 1、查询当前已过期正式用户或试用用户
|
// 1、查询当前已过期正式用户或试用用户
|
||||||
List<Account> accountList = accountService.getExpiredUserBySystemUser(1);
|
List<Account> accountList = accountService.getExpiredUserBySystemUser(1);
|
||||||
@@ -77,7 +77,7 @@ public class AccountTask {
|
|||||||
accountService.registerUserToVisitor();
|
accountService.registerUserToVisitor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 0 1 * ?")
|
// @Scheduled(cron = "0 0 0 1 * ?")
|
||||||
// 每月初刷新所有用户用户名剩余修改次数
|
// 每月初刷新所有用户用户名剩余修改次数
|
||||||
public void resetUsernameModifyTimes(){
|
public void resetUsernameModifyTimes(){
|
||||||
log.info("重置所有用户的用户名修改次数");
|
log.info("重置所有用户的用户名修改次数");
|
||||||
@@ -85,17 +85,17 @@ public class AccountTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @Scheduled(cron = "0 35 14 * * ?")
|
// @Scheduled(cron = "0 35 14 * * ?")
|
||||||
@Scheduled(cron = "0 5 0 * * ?")
|
// @Scheduled(cron = "0 5 0 * * ?")
|
||||||
public void checkEduAdminExpireStatus() {
|
public void checkEduAdminExpireStatus() {
|
||||||
accountService.checkEduAdminExpireStatus();
|
accountService.checkEduAdminExpireStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 5 0 * * ?")
|
// @Scheduled(cron = "0 5 0 * * ?")
|
||||||
public void activeSubscriptionPlan() {
|
public void activeSubscriptionPlan() {
|
||||||
subscriptionPlanService.activeSubscriptionPlan(null);
|
subscriptionPlanService.activeSubscriptionPlan(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
// @Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
||||||
public void expireSubscription() {
|
public void expireSubscription() {
|
||||||
subscriptionPlanService.expireSubscription();
|
subscriptionPlanService.expireSubscription();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class GenerateTask {
|
|||||||
* 故这里通过定时任务做补偿
|
* 故这里通过定时任务做补偿
|
||||||
* flux五分钟查询一次,万相1小时查询一次
|
* flux五分钟查询一次,万相1小时查询一次
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron = "0 */4 * * * ?")
|
// @Scheduled(cron = "0 */4 * * * ?")
|
||||||
public void fluxCompensationMechanism(){
|
public void fluxCompensationMechanism(){
|
||||||
// 1、查所有 任务还没成功、还没失败,正在等待或者执行中的任务id有哪些
|
// 1、查所有 任务还没成功、还没失败,正在等待或者执行中的任务id有哪些
|
||||||
// (由于获取结果的polling_url在redis中只存一天,大部分结果超过一天之后就无法再找到任务,小部分可以通过公共路径查到结果)
|
// (由于获取结果的polling_url在redis中只存一天,大部分结果超过一天之后就无法再找到任务,小部分可以通过公共路径查到结果)
|
||||||
@@ -98,7 +98,7 @@ public class GenerateTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 万相 -> pose transformation 补偿 当前任务执行完后,5分钟再执行一次(不会出现任务重叠的情况)
|
// 万相 -> pose transformation 补偿 当前任务执行完后,5分钟再执行一次(不会出现任务重叠的情况)
|
||||||
@Scheduled(fixedDelay = 5 * 60 * 1000)
|
// @Scheduled(fixedDelay = 5 * 60 * 1000)
|
||||||
public void wxCompensationMechanism(){
|
public void wxCompensationMechanism(){
|
||||||
List<APIGenerate> apiGenerates = apiGenerateService.getPendingTaskByStatus("wx");
|
List<APIGenerate> apiGenerates = apiGenerateService.getPendingTaskByStatus("wx");
|
||||||
if (apiGenerates != null && !apiGenerates.isEmpty()){
|
if (apiGenerates != null && !apiGenerates.isEmpty()){
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class PaymentTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 定时同步(每分钟一次)
|
// 定时同步(每分钟一次)
|
||||||
@Scheduled(fixedRate = 60000)
|
// @Scheduled(fixedRate = 60000)
|
||||||
public void syncLinkViewCountToDB(){
|
public void syncLinkViewCountToDB(){
|
||||||
affiliateService.syncLinkViewCountToDB();
|
affiliateService.syncLinkViewCountToDB();
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ public class PaymentTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
// @Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
||||||
public void calcCouponsCommission(){
|
public void calcCouponsCommission(){
|
||||||
// log.info("优惠券佣金计算定时器");
|
// log.info("优惠券佣金计算定时器");
|
||||||
affiliateService.calcCouponsCommission();
|
affiliateService.calcCouponsCommission();
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.ai.da.common.utils;
|
|||||||
import com.ai.da.common.constant.CommonConstant;
|
import com.ai.da.common.constant.CommonConstant;
|
||||||
import com.ai.da.model.dto.BasicEmailParamDTO;
|
import com.ai.da.model.dto.BasicEmailParamDTO;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.sun.mail.smtp.SMTPTransport;
|
|
||||||
import io.netty.util.internal.StringUtil;
|
import io.netty.util.internal.StringUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.core.io.InputStreamSource;
|
import org.springframework.core.io.InputStreamSource;
|
||||||
@@ -35,7 +34,8 @@ public class MailUtil {
|
|||||||
* 发送邮件 - 默认发件人
|
* 发送邮件 - 默认发件人
|
||||||
*
|
*
|
||||||
* @param basicEmailParamDTO 发送邮件所需参数
|
* @param basicEmailParamDTO 发送邮件所需参数
|
||||||
* @param inputStreamSource 附件(如果有)
|
* @param fileName 附件名(如果有)
|
||||||
|
* @param inputStreamSource 附件(如果有)
|
||||||
*/
|
*/
|
||||||
public int sendMail(BasicEmailParamDTO basicEmailParamDTO, String fileName, InputStreamSource inputStreamSource) throws MessagingException {
|
public int sendMail(BasicEmailParamDTO basicEmailParamDTO, String fileName, InputStreamSource inputStreamSource) throws MessagingException {
|
||||||
MimeMessage mimeMessage = createSimpleMail(basicEmailParamDTO, fileName, inputStreamSource);
|
MimeMessage mimeMessage = createSimpleMail(basicEmailParamDTO, fileName, inputStreamSource);
|
||||||
@@ -62,36 +62,29 @@ public class MailUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int sendMail(MimeMessage mimeMessage, String host, String username, String password) throws MessagingException {
|
private int sendMail(MimeMessage mimeMessage, String host, String username, String password) throws MessagingException {
|
||||||
SMTPTransport transport = null;
|
|
||||||
try {
|
try {
|
||||||
// 获取 SMTPTransport
|
// 配置连接属性
|
||||||
transport = (SMTPTransport) mimeMessage.getSession().getTransport("smtp");
|
java.util.Properties props = mimeMessage.getSession().getProperties();
|
||||||
// 连接到 SMTP 服务器
|
props.put("mail.smtp.auth", "true");
|
||||||
transport.connect(host, username, password);
|
props.put("mail.smtp.host", host);
|
||||||
// 发送邮件
|
props.put("mail.user", username);
|
||||||
transport.sendMessage(mimeMessage, mimeMessage.getAllRecipients());
|
props.put("mail.password", password);
|
||||||
// 获取 SMTP 服务器的响应
|
|
||||||
String lastServerResponse = transport.getLastServerResponse();
|
|
||||||
int lastReturnCode = transport.getLastReturnCode();
|
|
||||||
|
|
||||||
log.info("SMTP 状态码: {}, SMTP 服务器响应: {}", lastReturnCode, lastServerResponse);
|
// 使用 JavaMailSender 发送邮件(Spring Boot 3.x 标准方式)
|
||||||
return lastReturnCode;
|
javaMailSender.send(mimeMessage);
|
||||||
} catch (MailException | MessagingException e) {
|
log.info("邮件发送成功至: {}", host);
|
||||||
// 记录日志或执行其他补偿逻辑
|
return 1;
|
||||||
|
} catch (MailException e) {
|
||||||
log.info("邮件发送失败:{}", e.getMessage());
|
log.info("邮件发送失败:{}", e.getMessage());
|
||||||
} finally {
|
return 0;
|
||||||
// 关闭连接
|
|
||||||
assert transport != null;
|
|
||||||
transport.close();
|
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一封邮件
|
* 创建一封邮件
|
||||||
*
|
*
|
||||||
* @param basicEmailParamDTO 创建邮件需要的参数
|
* @param basicEmailParamDTO 创建邮件需要的参数
|
||||||
* @param inputStreamSource 附件(如果有)
|
* @param inputStreamSource 附件(如果有)
|
||||||
* @return 一封邮件
|
* @return 一封邮件
|
||||||
*/
|
*/
|
||||||
private MimeMessage createSimpleMail(BasicEmailParamDTO basicEmailParamDTO, String fileName, InputStreamSource inputStreamSource) throws MessagingException {
|
private MimeMessage createSimpleMail(BasicEmailParamDTO basicEmailParamDTO, String fileName, InputStreamSource inputStreamSource) throws MessagingException {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import io.netty.util.internal.StringUtil;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@@ -41,6 +42,9 @@ public class MinioUtil {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private MinioClient minioClient;
|
private MinioClient minioClient;
|
||||||
|
|
||||||
|
@Value("${minio.endpoint}")
|
||||||
|
private String endpoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取MinIO客户端实例
|
* 获取MinIO客户端实例
|
||||||
*/
|
*/
|
||||||
@@ -958,6 +962,166 @@ public class MinioUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测字符串是否为预签名URL
|
||||||
|
* 通过检查URL中是否包含minio endpoint来判断
|
||||||
|
*
|
||||||
|
* @param str 待检测的字符串
|
||||||
|
* @return true表示是预签名URL,false表示不是
|
||||||
|
*/
|
||||||
|
public boolean isPresignedUrl(String str) {
|
||||||
|
if (str == null || str.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// 检查字符串是否是一个有效的URL
|
||||||
|
URL url = new URL(str);
|
||||||
|
String host = url.getHost();
|
||||||
|
// 获取endpoint中的主机部分(去掉http://或https://)
|
||||||
|
String endpointHost = endpoint;
|
||||||
|
if (endpointHost.startsWith("http://")) {
|
||||||
|
endpointHost = endpointHost.substring(7);
|
||||||
|
} else if (endpointHost.startsWith("https://")) {
|
||||||
|
endpointHost = endpointHost.substring(8);
|
||||||
|
}
|
||||||
|
// 去掉端口号
|
||||||
|
if (endpointHost.contains(":")) {
|
||||||
|
endpointHost = endpointHost.substring(0, endpointHost.indexOf(":"));
|
||||||
|
}
|
||||||
|
// 检查URL的host是否与endpoint的host匹配
|
||||||
|
return host.equals(endpointHost);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 不是有效的URL
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测字符串是否为MinIO逻辑路径(bucketName/objectName格式)
|
||||||
|
* 逻辑路径特点:
|
||||||
|
* 1. 包含 "/"(桶名和对象名之间的分隔符)
|
||||||
|
* 2. 不是完整的URL(不以http://或https://开头)
|
||||||
|
* 3. 路径中没有查询参数
|
||||||
|
*
|
||||||
|
* @param str 待检测的字符串
|
||||||
|
* @return true表示是MinIO逻辑路径,false表示不是
|
||||||
|
*/
|
||||||
|
public boolean isMinioLogicalPath(String str) {
|
||||||
|
if (str == null || str.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 必须是字符串
|
||||||
|
if (!(str instanceof String)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String trimStr = str.trim();
|
||||||
|
// 不应该以http://或https://开头
|
||||||
|
if (trimStr.startsWith("http://") || trimStr.startsWith("https://")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 应该包含 "/"(bucket/object格式)
|
||||||
|
if (!trimStr.contains("/")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 不应该包含空格或特殊字符
|
||||||
|
if (trimStr.contains(" ") || trimStr.contains("\n") || trimStr.contains("\t")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将预签名URL转换为逻辑路径
|
||||||
|
*
|
||||||
|
* @param presignedUrl 预签名URL
|
||||||
|
* @return 逻辑路径(格式:bucketName/objectName)
|
||||||
|
*/
|
||||||
|
public String getLogicalPathFromPresignedUrl(String presignedUrl) {
|
||||||
|
try {
|
||||||
|
// 解析URL
|
||||||
|
URL url = new URL(presignedUrl);
|
||||||
|
|
||||||
|
// 获取路径部分(去掉开头的/)
|
||||||
|
String path = url.getPath();
|
||||||
|
if (path.startsWith("/")) {
|
||||||
|
path = path.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 路径格式为 bucketName/objectName
|
||||||
|
// Minio路径中可能包含多个/,需要正确分割
|
||||||
|
int firstSlashIndex = path.indexOf("/");
|
||||||
|
if (firstSlashIndex <= 0) {
|
||||||
|
throw new MinioException("预签名URL路径格式无效,应包含桶名和对象名: " + presignedUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
String bucketName = path.substring(0, firstSlashIndex);
|
||||||
|
String objectName = path.substring(firstSlashIndex + 1);
|
||||||
|
|
||||||
|
// log.info("预签名URL转换成功,桶名: {}, 对象名: {}", bucketName, objectName);
|
||||||
|
return bucketName + "/" + objectName;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("预签名URL解析失败: {}", e.getMessage(), e);
|
||||||
|
throw new BusinessException("system.error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理MinIO资源(预签名URL或逻辑路径),统一生成预签名URL
|
||||||
|
*
|
||||||
|
* @param resource 预签名URL或逻辑路径
|
||||||
|
* @param expires 过期时间(秒)
|
||||||
|
* @return 新的预签名URL
|
||||||
|
*/
|
||||||
|
public String processMinioResource(String resource, int expires) {
|
||||||
|
try {
|
||||||
|
String logicalPath;
|
||||||
|
if (isPresignedUrl(resource)) {
|
||||||
|
// 是预签名URL,解析为逻辑路径
|
||||||
|
logicalPath = getLogicalPathFromPresignedUrl(resource);
|
||||||
|
} else if (isMinioLogicalPath(resource)) {
|
||||||
|
// 本身就是逻辑路径
|
||||||
|
logicalPath = resource.trim();
|
||||||
|
} else {
|
||||||
|
// 不认识的内容,直接返回原始值
|
||||||
|
log.warn("未识别的MinIO资源格式: {}", resource);
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 统一生成预签名URL
|
||||||
|
return getPreSignedUrl(logicalPath, expires);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("处理MinIO资源失败: {}, error: {}", resource, e.getMessage(), e);
|
||||||
|
// 如果失败,返回原始内容
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将任意MinIO URL转换为逻辑路径
|
||||||
|
* 检测URL类型并转换为逻辑路径返回
|
||||||
|
*
|
||||||
|
* @param url 预签名URL或逻辑路径
|
||||||
|
* @return 逻辑路径(格式:bucketName/objectName)
|
||||||
|
* @throws MinioException 如果不是有效的MinIO资源
|
||||||
|
*/
|
||||||
|
public String convertToLogicalPath(String url) {
|
||||||
|
if (url == null || url.isEmpty()) {
|
||||||
|
throw new BusinessException("url.cannot.be.empty");
|
||||||
|
}
|
||||||
|
if (isMinioLogicalPath(url)) {
|
||||||
|
// 本身就是逻辑路径,直接返回
|
||||||
|
return url.trim();
|
||||||
|
} else if (isPresignedUrl(url)) {
|
||||||
|
// 是预签名URL,转换为逻辑路径
|
||||||
|
return getLogicalPathFromPresignedUrl(url);
|
||||||
|
} else {
|
||||||
|
// 不认识的内容,抛出异常
|
||||||
|
throw new BusinessException("无法识别的MinIO资源格式: " + url + ",请提供有效的预签名URL或逻辑路径");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
package com.ai.da.common.utils;
|
|
||||||
|
|
||||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
|
|
||||||
public class SecurityContextUtils {
|
|
||||||
|
|
||||||
public static AuthPrincipalVo getCurrentUser() {
|
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
|
||||||
if (authentication != null && authentication.getPrincipal() != null) {
|
|
||||||
return (AuthPrincipalVo) authentication.getPrincipal();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Long getCurrentUserId() {
|
|
||||||
AuthPrincipalVo currentUser = getCurrentUser();
|
|
||||||
if (currentUser != null) {
|
|
||||||
return currentUser.getId();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getCurrentUsername() {
|
|
||||||
AuthPrincipalVo currentUser = getCurrentUser();
|
|
||||||
if (currentUser != null) {
|
|
||||||
return currentUser.getUsername();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
131
src/main/java/com/ai/da/common/utils/TokenGenerateUtils.java
Normal file
131
src/main/java/com/ai/da/common/utils/TokenGenerateUtils.java
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
package com.ai.da.common.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.crypto.digest.DigestUtil;
|
||||||
|
import com.ai.da.common.constant.CommonConstant;
|
||||||
|
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import io.jsonwebtoken.Claims;
|
||||||
|
import io.jsonwebtoken.Jwts;
|
||||||
|
import io.jsonwebtoken.security.Keys;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.crypto.SecretKey;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Token 生成工具类(仅负责生成,不负责鉴权)。
|
||||||
|
* 鉴权逻辑已迁移至 Gateway(GlobalAuthWebFilter)。
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class TokenGenerateUtils {
|
||||||
|
|
||||||
|
private static final String ISSUER = "DWJ";
|
||||||
|
|
||||||
|
@Value("${spring.security.jwtSecret:JWTSECRET}")
|
||||||
|
private String jwtSecret;
|
||||||
|
|
||||||
|
@Value("${spring.security.jwtExpiration:8640000000}")
|
||||||
|
private long jwtExpiration;
|
||||||
|
|
||||||
|
@Value("${spring.security.jwtTokenPrefix:Bearer-}")
|
||||||
|
private String jwtTokenPrefix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成 JWT Token。
|
||||||
|
* @param principal 用户信息
|
||||||
|
* @return 完整的 token(含 prefix)
|
||||||
|
*/
|
||||||
|
public String createToken(AuthPrincipalVo principal) {
|
||||||
|
SecretKey key = buildSigningKey();
|
||||||
|
String token = Jwts.builder()
|
||||||
|
.id(String.valueOf(principal.getId()))
|
||||||
|
.subject(JSONObject.toJSONString(principal))
|
||||||
|
.issuedAt(new Date())
|
||||||
|
.issuer(ISSUER)
|
||||||
|
.expiration(new Date(System.currentTimeMillis() + jwtExpiration))
|
||||||
|
.signWith(key)
|
||||||
|
.compact();
|
||||||
|
return jwtTokenPrefix + token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 Token 过期时间(毫秒)。
|
||||||
|
*/
|
||||||
|
public long getJwtExpiration() {
|
||||||
|
return jwtExpiration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成用于邮箱变更的简化 Token。
|
||||||
|
* @param userId 用户 ID
|
||||||
|
* @param mailbox 新邮箱
|
||||||
|
* @return token(不含 prefix)
|
||||||
|
*/
|
||||||
|
public String createMailboxToken(Long userId, String mailbox) {
|
||||||
|
SecretKey key = buildSigningKey();
|
||||||
|
return Jwts.builder()
|
||||||
|
.id(String.valueOf(userId))
|
||||||
|
.subject(mailbox + "_" + userId)
|
||||||
|
.issuedAt(new Date())
|
||||||
|
.issuer(ISSUER)
|
||||||
|
.expiration(new Date(System.currentTimeMillis() + CommonConstant.CHANGE_MAILBOX_LINK_VALIDITY))
|
||||||
|
.signWith(key)
|
||||||
|
.compact();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证 Token 是否有效(签名和有效期)。
|
||||||
|
*/
|
||||||
|
public boolean validateToken(String token) {
|
||||||
|
try {
|
||||||
|
Claims claims = parseTokenBody(token);
|
||||||
|
return claims != null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从 Token 中解析用户信息。
|
||||||
|
*/
|
||||||
|
public AuthPrincipalVo parserToUser(String token) {
|
||||||
|
try {
|
||||||
|
String subject = parseTokenBody(token).getSubject();
|
||||||
|
if (StrUtil.isNotEmpty(subject)) {
|
||||||
|
return JSONObject.parseObject(subject, AuthPrincipalVo.class);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("JWT解析用户信息失败: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析邮箱变更 Token,返回 "email_id" 格式字符串。
|
||||||
|
*/
|
||||||
|
public String parseMailboxToken(String token) {
|
||||||
|
return parseTokenBody(token).getSubject();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Claims parseTokenBody(String token) {
|
||||||
|
SecretKey key = buildSigningKey();
|
||||||
|
return Jwts.parser()
|
||||||
|
.verifyWith(key)
|
||||||
|
.build()
|
||||||
|
.parseSignedClaims(token)
|
||||||
|
.getPayload();
|
||||||
|
}
|
||||||
|
|
||||||
|
private SecretKey buildSigningKey() {
|
||||||
|
byte[] raw = jwtSecret.getBytes(StandardCharsets.UTF_8);
|
||||||
|
if (raw.length < 32) {
|
||||||
|
raw = DigestUtil.sha256(raw);
|
||||||
|
}
|
||||||
|
return Keys.hmacShaKeyFor(raw);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import com.ai.da.common.response.Response;
|
|||||||
import com.ai.da.model.dto.*;
|
import com.ai.da.model.dto.*;
|
||||||
import com.ai.da.model.dto.ContestantDTO;
|
import com.ai.da.model.dto.ContestantDTO;
|
||||||
import com.ai.da.model.vo.CheckOTPVO;
|
import com.ai.da.model.vo.CheckOTPVO;
|
||||||
|
import com.ai.da.model.vo.ContestantCountVO;
|
||||||
import com.ai.da.service.GlobalAwardService;
|
import com.ai.da.service.GlobalAwardService;
|
||||||
import com.ai.da.service.upload.UploadService;
|
import com.ai.da.service.upload.UploadService;
|
||||||
import com.ai.da.service.upload.UploadTask;
|
import com.ai.da.service.upload.UploadTask;
|
||||||
@@ -176,10 +177,25 @@ public class GlobalAwardController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/contestants/export/files")
|
@PostMapping("/contestants/export/files")
|
||||||
@ApiOperation(value = "导出参赛者文件到本地", notes = "根据参赛者编号范围导出PDF和视频文件到本地temp/uploads/contestants目录")
|
@ApiOperation(value = "导出参赛者文件为ZIP", notes = "根据参赛者编号范围导出PDF、视频和信息文件为ZIP,直接响应给浏览器")
|
||||||
public Response<Integer> exportContestantFiles(@ApiParam(value = "参赛者文件导出请求", required = true) @RequestBody ContestantExportRequest request) throws Exception {
|
public void exportContestantFiles(@ApiParam(value = "参赛者文件导出请求", required = true) @RequestBody ContestantExportRequest request, HttpServletResponse response) throws Exception {
|
||||||
int exportedCount = globalAwardService.exportContestantFiles(request.getMinContestantNumber(), request.getMaxContestantNumber());
|
byte[] zipData = globalAwardService.exportContestantFilesAsZip(request.getMinContestantNumber(), request.getMaxContestantNumber());
|
||||||
return Response.success(exportedCount);
|
if (zipData.length == 0) {
|
||||||
|
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
response.getWriter().write("No contestants found in the specified range.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
response.setContentType("application/zip");
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=\"contestants.zip\"");
|
||||||
|
response.setContentLength(zipData.length);
|
||||||
|
response.getOutputStream().write(zipData);
|
||||||
|
response.getOutputStream().flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/contestants/count")
|
||||||
|
@ApiOperation(value = "查询参赛者总数", notes = "查询数据库中参赛者的总数量和最大参赛者编号")
|
||||||
|
public Response<ContestantCountVO> getContestantCount() {
|
||||||
|
return Response.success(globalAwardService.getContestantCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ai.da.feign.gateway;
|
||||||
|
|
||||||
|
import com.ai.da.common.response.Response;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用 Gateway 黑名单接口,将指定用户的 token 加入黑名单。
|
||||||
|
* 替代原来的 SellerFeignClient.clearTokenCache。
|
||||||
|
*/
|
||||||
|
@FeignClient(name = "aida-gateway", path = "/internal")
|
||||||
|
public interface GatewayFeignClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将用户 token 加入黑名单。
|
||||||
|
* 后续 Gateway 会拒绝携带该用户 token 的请求。
|
||||||
|
*/
|
||||||
|
@PostMapping("/logout")
|
||||||
|
Response<Void> logout(@RequestParam("userId") Long userId);
|
||||||
|
}
|
||||||
20
src/main/java/com/ai/da/feign/seller/SellerFeignClient.java
Normal file
20
src/main/java/com/ai/da/feign/seller/SellerFeignClient.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package com.ai.da.feign.seller;
|
||||||
|
|
||||||
|
import com.ai.da.common.response.Response;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用 aida-seller 设计师相关接口的 Feign 客户端
|
||||||
|
*/
|
||||||
|
@FeignClient(name = "aida-seller", path = "/api/designer")
|
||||||
|
public interface SellerFeignClient {
|
||||||
|
|
||||||
|
@GetMapping("/check")
|
||||||
|
Response<Boolean> checkDesignerQualification(@RequestParam("userId") Long userId);
|
||||||
|
|
||||||
|
@PostMapping("/cache/clear")
|
||||||
|
Response<Void> clearTokenCache(@RequestParam("userId") Long userId);
|
||||||
|
}
|
||||||
@@ -68,6 +68,9 @@ public class Contestant {
|
|||||||
@TableField("pdf_size")
|
@TableField("pdf_size")
|
||||||
private Long pdfSize;
|
private Long pdfSize;
|
||||||
|
|
||||||
|
@TableField("portfolio_url")
|
||||||
|
private String portfolioUrl;
|
||||||
|
|
||||||
@TableField("created_at")
|
@TableField("created_at")
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
|||||||
17
src/main/java/com/ai/da/model/vo/ContestantCountVO.java
Normal file
17
src/main/java/com/ai/da/model/vo/ContestantCountVO.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package com.ai.da.model.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ContestantCountVO {
|
||||||
|
|
||||||
|
private Long count;
|
||||||
|
|
||||||
|
private Integer maxContestantNumber;
|
||||||
|
}
|
||||||
@@ -77,7 +77,7 @@ public class PythonService {
|
|||||||
@Value("${access.python.generate_sr_port}")
|
@Value("${access.python.generate_sr_port}")
|
||||||
private String srServicePort;
|
private String srServicePort;
|
||||||
|
|
||||||
@Value("${design.callback.url}")
|
@Value("${design.callback.url.aida}")
|
||||||
private String callbackUrl;
|
private String callbackUrl;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|||||||
37
src/main/java/com/ai/da/seller/DesignUrlsDTO.java
Normal file
37
src/main/java/com/ai/da/seller/DesignUrlsDTO.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package com.ai.da.seller;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设计URLs DTO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "设计URLs数据传输对象")
|
||||||
|
public class DesignUrlsDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设计项ID
|
||||||
|
*/
|
||||||
|
@Schema(description = "设计项ID", example = "1")
|
||||||
|
private Long designItemId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TO_PRODUCT_IMAGE类型的URL列表
|
||||||
|
*/
|
||||||
|
@Schema(description = "TO_PRODUCT_IMAGE类型的URL列表")
|
||||||
|
private List<String> toProductImageUrls;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DesignItemDetail的path列表
|
||||||
|
*/
|
||||||
|
@Schema(description = "DesignItemDetail的path列表")
|
||||||
|
private List<String> clothes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 姿势转换视频信息列表
|
||||||
|
*/
|
||||||
|
@Schema(description = "姿势转换视频信息列表")
|
||||||
|
private List<PoseTransformationVideoDTO> videos;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.ai.da.seller;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 姿势转换视频信息DTO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "姿势转换视频信息数据传输对象")
|
||||||
|
public class PoseTransformationVideoDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GIF第一帧截图URL
|
||||||
|
*/
|
||||||
|
@Schema(description = "GIF第一帧截图URL")
|
||||||
|
private String firstFrameUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GIF视频URL
|
||||||
|
*/
|
||||||
|
@Schema(description = "GIF视频URL")
|
||||||
|
private String gifUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频URL
|
||||||
|
*/
|
||||||
|
@Schema(description = "视频URL")
|
||||||
|
private String videoUrl;
|
||||||
|
}
|
||||||
44
src/main/java/com/ai/da/seller/SellerController.java
Normal file
44
src/main/java/com/ai/da/seller/SellerController.java
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package com.ai.da.seller;
|
||||||
|
|
||||||
|
import com.ai.da.common.response.Response;
|
||||||
|
import com.ai.da.service.UserLikeGroupService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seller Controller
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/seller")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Tag(name = "Seller", description = "Seller相关接口")
|
||||||
|
public class SellerController {
|
||||||
|
|
||||||
|
private final UserLikeGroupService userLikeGroupService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据designItemId列表获取设计相关的URL列表
|
||||||
|
* @param designItemIds designItemId列表
|
||||||
|
* @return 设计URLs DTO列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/sketchDetail")
|
||||||
|
@Operation(summary = "获取设计相关URL列表", description = "根据designItemId列表获取设计相关的URL列表,包括TO_PRODUCT_IMAGE类型的URL和DesignItemDetail的path列表")
|
||||||
|
public Response<List<DesignUrlsDTO>> getDesignUrlsByDesignItemIds(
|
||||||
|
@Parameter(description = "设计项ID列表", required = true, example = "1,2,3")
|
||||||
|
@RequestParam List<Long> designItemIds) {
|
||||||
|
List<DesignUrlsDTO> designUrlsDTOList = new ArrayList<>();
|
||||||
|
for (Long designItemId : designItemIds) {
|
||||||
|
DesignUrlsDTO designUrlsDTO = userLikeGroupService.getToProductImageUrlsByDesignItemId(designItemId);
|
||||||
|
designUrlsDTOList.add(designUrlsDTO);
|
||||||
|
}
|
||||||
|
return Response.success(designUrlsDTOList);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.ai.da.service;
|
|||||||
|
|
||||||
import com.ai.da.model.dto.ContestantDTO;
|
import com.ai.da.model.dto.ContestantDTO;
|
||||||
import com.ai.da.model.vo.CheckOTPVO;
|
import com.ai.da.model.vo.CheckOTPVO;
|
||||||
|
import com.ai.da.model.vo.ContestantCountVO;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -33,12 +34,18 @@ public interface GlobalAwardService {
|
|||||||
void saveContestantsToLocal() throws Exception;
|
void saveContestantsToLocal() throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据参赛者编号范围导出参赛者文件到本地目录
|
* 将参赛者文件打包为 ZIP 并返回字节数组(不落盘,直接响应给浏览器)
|
||||||
* @param minContestantNumber 最小参赛者编号
|
* @param minContestantNumber 最小参赛者编号
|
||||||
* @param maxContestantNumber 最大参赛者编号
|
* @param maxContestantNumber 最大参赛者编号
|
||||||
* @return 导出的参赛者数量
|
* @return ZIP 文件的字节数组
|
||||||
*/
|
*/
|
||||||
int exportContestantFiles(Integer minContestantNumber, Integer maxContestantNumber) throws Exception;
|
byte[] exportContestantFilesAsZip(Integer minContestantNumber, Integer maxContestantNumber) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询参赛者总数和最大参赛者编号
|
||||||
|
* @return 参赛者数量和最大参赛者编号
|
||||||
|
*/
|
||||||
|
ContestantCountVO getContestantCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.ai.da.common.response.PageBaseResponse;
|
|||||||
import com.ai.da.mapper.primary.entity.*;
|
import com.ai.da.mapper.primary.entity.*;
|
||||||
import com.ai.da.model.dto.*;
|
import com.ai.da.model.dto.*;
|
||||||
import com.ai.da.model.vo.*;
|
import com.ai.da.model.vo.*;
|
||||||
|
import com.ai.da.seller.DesignUrlsDTO;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
@@ -121,4 +122,11 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
|||||||
Boolean toProductImageElementDelete(Long id);
|
Boolean toProductImageElementDelete(Long id);
|
||||||
|
|
||||||
ToProductElementVO convertRelightElement(Long id);
|
ToProductElementVO convertRelightElement(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据designItemId获取TO_PRODUCT_IMAGE类型的URL列表和DesignItemDetail的path列表
|
||||||
|
* @param designItemId designItemId
|
||||||
|
* @return 包含TO_PRODUCT_IMAGE类型的URL列表和DesignItemDetail的path列表的对象
|
||||||
|
*/
|
||||||
|
DesignUrlsDTO getToProductImageUrlsByDesignItemId(Long designItemId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ import com.ai.da.common.enums.LoginTypeEnum;
|
|||||||
import com.ai.da.common.enums.ProductEnum;
|
import com.ai.da.common.enums.ProductEnum;
|
||||||
import com.ai.da.common.response.PageBaseResponse;
|
import com.ai.da.common.response.PageBaseResponse;
|
||||||
import com.ai.da.common.response.ResultEnum;
|
import com.ai.da.common.response.ResultEnum;
|
||||||
import com.ai.da.common.security.jwt.JWTTokenHelper;
|
import com.ai.da.common.utils.TokenGenerateUtils;
|
||||||
|
import com.ai.da.feign.gateway.GatewayFeignClient;
|
||||||
|
import com.ai.da.feign.seller.SellerFeignClient;
|
||||||
import com.ai.da.common.utils.*;
|
import com.ai.da.common.utils.*;
|
||||||
import com.ai.da.mapper.primary.*;
|
import com.ai.da.mapper.primary.*;
|
||||||
import com.ai.da.mapper.primary.entity.*;
|
import com.ai.da.mapper.primary.entity.*;
|
||||||
@@ -94,7 +96,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
private AccountExtendMapper accountExtendMapper;
|
private AccountExtendMapper accountExtendMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private JWTTokenHelper jwtTokenHelper;
|
private TokenGenerateUtils tokenGenerateUtils;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SellerFeignClient sellerFeignClient;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GatewayFeignClient gatewayFeignClient;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AccountLoginLogService accountLoginLogService;
|
private AccountLoginLogService accountLoginLogService;
|
||||||
@@ -136,9 +144,6 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
@Resource
|
@Resource
|
||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private com.ai.da.common.security.config.SecurityProperties securityProperties;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserFollowService userFollowService;
|
private UserFollowService userFollowService;
|
||||||
|
|
||||||
@@ -353,11 +358,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
principal.setUsername(account.getUserName());
|
principal.setUsername(account.getUserName());
|
||||||
principal.setLanguage(account.getLanguage());
|
principal.setLanguage(account.getLanguage());
|
||||||
principal.setCountry(account.getCountry());
|
principal.setCountry(account.getCountry());
|
||||||
String token2 = jwtTokenHelper.createToken(principal);
|
//区分买家端登录
|
||||||
|
principal.setSource("AIDA");
|
||||||
|
String token2 = tokenGenerateUtils.createToken(principal);
|
||||||
// 本地 JVM 缓存(适配旧逻辑)
|
// 本地 JVM 缓存(适配旧逻辑)
|
||||||
LocalCacheUtils.setTokenCache(String.valueOf(account.getId()), token2);
|
LocalCacheUtils.setTokenCache(String.valueOf(account.getId()), token2);
|
||||||
// 同步写入 Redis,重启后仍然可用
|
// 同步写入 Redis,重启后仍然可用
|
||||||
long jwtExpiration = securityProperties.getJwtExpiration();
|
long jwtExpiration = tokenGenerateUtils.getJwtExpiration();
|
||||||
redisUtil.setLoginToken(account.getId(), token2, jwtExpiration);
|
redisUtil.setLoginToken(account.getId(), token2, jwtExpiration);
|
||||||
return token2;
|
return token2;
|
||||||
}
|
}
|
||||||
@@ -614,11 +621,23 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean logout(AccountLogoutDTO accountLogoutDTO) {
|
public Boolean logout(AccountLogoutDTO accountLogoutDTO) {
|
||||||
// jwt 本身失效比较难做,统一用缓存实现:删除缓存即失效
|
// 1. 删除本地缓存(保留,防止 Gateway 未启动时还能本地验证)
|
||||||
String userIdStr = String.valueOf(accountLogoutDTO.getUserId());
|
String userIdStr = String.valueOf(accountLogoutDTO.getUserId());
|
||||||
LocalCacheUtils.delTokenCache(userIdStr);
|
LocalCacheUtils.delTokenCache(userIdStr);
|
||||||
// 同时删除 Redis 中的 token,防止服务重启后仍然有效
|
// 2. 删除 Redis 中的 token(Gateway 黑名单会接力生效)
|
||||||
redisUtil.deleteLoginToken(accountLogoutDTO.getUserId());
|
redisUtil.deleteLoginToken(accountLogoutDTO.getUserId());
|
||||||
|
// 3. 调用 Gateway 黑名单接口,将 token 加入 Redis 黑名单
|
||||||
|
try {
|
||||||
|
gatewayFeignClient.logout(accountLogoutDTO.getUserId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("调用 Gateway 黑名单接口失败,userId={}, error={}", accountLogoutDTO.getUserId(), e.getMessage());
|
||||||
|
}
|
||||||
|
// 4. 同步调用 seller 清除本地缓存(兼容未接入 Gateway 的节点)
|
||||||
|
try {
|
||||||
|
sellerFeignClient.clearTokenCache(accountLogoutDTO.getUserId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("调用 seller 清理缓存失败,userId={}, error={}", accountLogoutDTO.getUserId(), e.getMessage());
|
||||||
|
}
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2153,7 +2172,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
redisUtil.addToString(key, newMailbox, CommonConstant.CHANGE_MAILBOX_LINK_VALIDITY / 1000);
|
redisUtil.addToString(key, newMailbox, CommonConstant.CHANGE_MAILBOX_LINK_VALIDITY / 1000);
|
||||||
|
|
||||||
String username = userHolder.getUsername();
|
String username = userHolder.getUsername();
|
||||||
String token = jwtTokenHelper.createToken(accountId, newMailbox);
|
String token = tokenGenerateUtils.createMailboxToken(accountId, newMailbox);
|
||||||
// 准备激活链接,链接应该要有有效期
|
// 准备激活链接,链接应该要有有效期
|
||||||
String link = "?" + token;
|
String link = "?" + token;
|
||||||
// 向新邮箱发送邮件,邮件附带激活链接,点击链接进行验证
|
// 向新邮箱发送邮件,邮件附带激活链接,点击链接进行验证
|
||||||
@@ -2163,7 +2182,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
// 验证激活链接
|
// 验证激活链接
|
||||||
public void activateNewEmail(String token){
|
public void activateNewEmail(String token){
|
||||||
// 获取链接地址信息,更新指定用户邮箱
|
// 获取链接地址信息,更新指定用户邮箱
|
||||||
String emailAndId = jwtTokenHelper.parseToEmailAndId(token);
|
String emailAndId = tokenGenerateUtils.parseMailboxToken(token);
|
||||||
String newMailbox = emailAndId.substring(0, emailAndId.lastIndexOf("_"));
|
String newMailbox = emailAndId.substring(0, emailAndId.lastIndexOf("_"));
|
||||||
String accountId = emailAndId.substring(emailAndId.lastIndexOf("_") + 1);
|
String accountId = emailAndId.substring(emailAndId.lastIndexOf("_") + 1);
|
||||||
|
|
||||||
|
|||||||
@@ -524,7 +524,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
|||||||
elementVO.setPrintBoardElements(printBoardElements);
|
elementVO.setPrintBoardElements(printBoardElements);
|
||||||
if (!CollectionUtils.isEmpty(printBoardIds)) {
|
if (!CollectionUtils.isEmpty(printBoardIds)) {
|
||||||
// 从数据库批量查询printBoard元素
|
// 从数据库批量查询printBoard元素
|
||||||
printBoardElements = collectionElementMapper.selectBatchIds(printBoardIds);
|
printBoardElements.addAll(collectionElementMapper.selectBatchIds(printBoardIds));
|
||||||
// 验证查询结果的完整性
|
// 验证查询结果的完整性
|
||||||
if (CollectionUtil.isEmpty(printBoardElements) || printBoardElements.size() != printBoardIds.size()) {
|
if (CollectionUtil.isEmpty(printBoardElements) || printBoardElements.size() != printBoardIds.size()) {
|
||||||
throw new BusinessException("get.printBoards.data.is.mismatch");
|
throw new BusinessException("get.printBoards.data.is.mismatch");
|
||||||
|
|||||||
@@ -756,7 +756,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
print.setPosition("[0.0,0.0]");
|
print.setPosition("[0.0,0.0]");
|
||||||
// print.setScale(1d);
|
// print.setScale(1d);
|
||||||
// todo mark 将print默认scale置为0.3
|
// todo mark 将print默认scale置为0.3
|
||||||
print.setScale(Arrays.toString(new Float[]{0.3f, 0.3f}));
|
print.setScale(Arrays.toString(new Float[]{1.0f, 1.0f}));
|
||||||
print.setAngle(0.0);
|
print.setAngle(0.0);
|
||||||
print.setPriority(1);
|
print.setPriority(1);
|
||||||
QueryWrapper<CollectionElement> getPrintboardLevel2TypeQw = new QueryWrapper<>();
|
QueryWrapper<CollectionElement> getPrintboardLevel2TypeQw = new QueryWrapper<>();
|
||||||
|
|||||||
@@ -1553,11 +1553,11 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
if (imagePath != null) {
|
if (imagePath != null) {
|
||||||
requestBuilder.image(finalImagePath1);
|
requestBuilder.image(finalImagePath1);
|
||||||
}
|
}
|
||||||
if (useModel.equals(ModelConstants.PRINTBOARD_HIGH_I2I)) {
|
if (useModel.equals(ModelConstants.PRINTBOARD_HIGH_I2I)|| useModel.equals(ModelConstants.PRINTBOARD_HIGH_T2I)) {
|
||||||
GenerateImagesRequest.OptimizePromptOptions optimizePromptOptions = new GenerateImagesRequest.OptimizePromptOptions();
|
GenerateImagesRequest.OptimizePromptOptions optimizePromptOptions = new GenerateImagesRequest.OptimizePromptOptions();
|
||||||
optimizePromptOptions.setMode("fast");
|
optimizePromptOptions.setMode("fast");
|
||||||
requestBuilder.optimizePromptOptions(optimizePromptOptions);
|
requestBuilder.optimizePromptOptions(optimizePromptOptions);
|
||||||
//由于PRINTBOARD_HIGH_I2I与PRINTBOARD_ADVANCED_I2I使用模型一致,为了区别积分扣除,PRINTBOARD_HIGH_I2I加入了-fast,但传入模型时需要去掉-fast,用PRINTBOARD_ADVANCED_I2I的常量做替代
|
//由于PRINTBOARD_HIGH_T2I,PRINTBOARD_HIGH_I2I与PRINTBOARD_ADVANCED_I2I使用模型一致,为了区别积分扣除,PRINTBOARD_HIGH_I2I加入了-fast或者-high,但传入模型时需要去掉-fast或者-high,用PRINTBOARD_ADVANCED_I2I的常量做替代
|
||||||
requestBuilder.model(ModelConstants.PRINTBOARD_ADVANCED_I2I);
|
requestBuilder.model(ModelConstants.PRINTBOARD_ADVANCED_I2I);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4225,8 +4225,11 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 发送POST请求到Flux API
|
// 发送POST请求到Flux API
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
String resp = sendRequestUtil.sendFluxPost(fluxRequestUrl, requestBody.toString());
|
String resp = sendRequestUtil.sendFluxPost(fluxRequestUrl, requestBody.toString());
|
||||||
JSONObject respObj = JSONUtil.parseObj(resp);
|
JSONObject respObj = JSONUtil.parseObj(resp);
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
log.info("flux 耗时:{}ms", end - start);
|
||||||
log.info("flux 发起生成请求返回结果: {}", respObj);
|
log.info("flux 发起生成请求返回结果: {}", respObj);
|
||||||
|
|
||||||
// 从响应中提取任务ID
|
// 从响应中提取任务ID
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.ai.da.mapper.primary.entity.Notification;
|
|||||||
import com.ai.da.model.dto.ContestantDTO;
|
import com.ai.da.model.dto.ContestantDTO;
|
||||||
import com.ai.da.model.dto.PublishSysNotificationDTO;
|
import com.ai.da.model.dto.PublishSysNotificationDTO;
|
||||||
import com.ai.da.model.vo.CheckOTPVO;
|
import com.ai.da.model.vo.CheckOTPVO;
|
||||||
|
import com.ai.da.model.vo.ContestantCountVO;
|
||||||
import com.ai.da.service.GlobalAwardService;
|
import com.ai.da.service.GlobalAwardService;
|
||||||
import com.ai.da.service.MessageCenterService;
|
import com.ai.da.service.MessageCenterService;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
@@ -26,24 +27,22 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.util.zip.ZipEntry;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -187,6 +186,7 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
|||||||
.videoSize(request.getVideoSize())
|
.videoSize(request.getVideoSize())
|
||||||
.pdfSize(request.getPdfSize())
|
.pdfSize(request.getPdfSize())
|
||||||
.contestantNumber(nextNumber)
|
.contestantNumber(nextNumber)
|
||||||
|
.portfolioUrl(request.getPortfolioUrl())
|
||||||
.createdAt(now)
|
.createdAt(now)
|
||||||
.updatedAt(now)
|
.updatedAt(now)
|
||||||
.build();
|
.build();
|
||||||
@@ -227,6 +227,7 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
|||||||
existing.setVideoDuration(request.getVideoDuration());
|
existing.setVideoDuration(request.getVideoDuration());
|
||||||
existing.setVideoSize(request.getVideoSize());
|
existing.setVideoSize(request.getVideoSize());
|
||||||
existing.setPdfSize(request.getPdfSize());
|
existing.setPdfSize(request.getPdfSize());
|
||||||
|
existing.setPortfolioUrl(request.getPortfolioUrl());
|
||||||
existing.setUpdatedAt(now);
|
existing.setUpdatedAt(now);
|
||||||
contestantMapper.updateById(existing);
|
contestantMapper.updateById(existing);
|
||||||
resp.put("success", true);
|
resp.put("success", true);
|
||||||
@@ -244,7 +245,7 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
|||||||
String[] headers = new String[] {
|
String[] headers = new String[] {
|
||||||
"contestantNumber", "email", "firstName", "lastName", "gender", "occupation",
|
"contestantNumber", "email", "firstName", "lastName", "gender", "occupation",
|
||||||
"age", "countryRegionCity", "phoneNumber", "designTitle", "designDescription",
|
"age", "countryRegionCity", "phoneNumber", "designTitle", "designDescription",
|
||||||
"pdfPath", "videoPath", "videoDuration", "videoSizeMB", "pdfSizeMB", "createdAt", "updatedAt"
|
"pdfPath", "videoPath", "videoDuration", "videoSizeMB", "pdfSizeMB", "portfolioUrl", "createdAt", "updatedAt"
|
||||||
};
|
};
|
||||||
for (int i = 0; i < headers.length; i++) {
|
for (int i = 0; i < headers.length; i++) {
|
||||||
Cell c = header.createCell(i);
|
Cell c = header.createCell(i);
|
||||||
@@ -265,11 +266,9 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
|||||||
r.createCell(ci++).setCellValue(cst.getPhoneNumber() == null ? "" : cst.getPhoneNumber());
|
r.createCell(ci++).setCellValue(cst.getPhoneNumber() == null ? "" : cst.getPhoneNumber());
|
||||||
r.createCell(ci++).setCellValue(cst.getDesignTitle() == null ? "" : cst.getDesignTitle());
|
r.createCell(ci++).setCellValue(cst.getDesignTitle() == null ? "" : cst.getDesignTitle());
|
||||||
r.createCell(ci++).setCellValue(cst.getDesignDescription() == null ? "" : cst.getDesignDescription());
|
r.createCell(ci++).setCellValue(cst.getDesignDescription() == null ? "" : cst.getDesignDescription());
|
||||||
// r.createCell(ci++).setCellValue(cst.getPdfPath() == null ? "" : cst.getPdfPath());
|
r.createCell(ci++).setCellValue(cst.getPdfPath() == null ? "" : cst.getPdfPath());
|
||||||
// r.createCell(ci++).setCellValue(cst.getVideoPath() == null ? "" : cst.getVideoPath());
|
r.createCell(ci++).setCellValue(cst.getVideoPath() == null ? "" : cst.getVideoPath());
|
||||||
// 视频时长(秒)
|
|
||||||
r.createCell(ci++).setCellValue(cst.getVideoDuration() == null ? "" : cst.getVideoDuration().toString());
|
r.createCell(ci++).setCellValue(cst.getVideoDuration() == null ? "" : cst.getVideoDuration().toString());
|
||||||
// 视频大小、PDF 大小:以 MB 导出,保留两位小数
|
|
||||||
if (cst.getVideoSize() == null) {
|
if (cst.getVideoSize() == null) {
|
||||||
r.createCell(ci++).setCellValue("");
|
r.createCell(ci++).setCellValue("");
|
||||||
} else {
|
} else {
|
||||||
@@ -282,6 +281,7 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
|||||||
double pMb = cst.getPdfSize() / 1024.0 / 1024.0;
|
double pMb = cst.getPdfSize() / 1024.0 / 1024.0;
|
||||||
r.createCell(ci++).setCellValue(String.format("%.2f", pMb));
|
r.createCell(ci++).setCellValue(String.format("%.2f", pMb));
|
||||||
}
|
}
|
||||||
|
r.createCell(ci++).setCellValue(cst.getPortfolioUrl() == null ? "" : cst.getPortfolioUrl());
|
||||||
r.createCell(ci++).setCellValue(cst.getCreatedAt() == null ? "" : cst.getCreatedAt().toString());
|
r.createCell(ci++).setCellValue(cst.getCreatedAt() == null ? "" : cst.getCreatedAt().toString());
|
||||||
r.createCell(ci++).setCellValue(cst.getUpdatedAt() == null ? "" : cst.getUpdatedAt().toString());
|
r.createCell(ci++).setCellValue(cst.getUpdatedAt() == null ? "" : cst.getUpdatedAt().toString());
|
||||||
}
|
}
|
||||||
@@ -311,7 +311,7 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
|||||||
String[] headers = new String[] {
|
String[] headers = new String[] {
|
||||||
"contestantNumber", "email", "firstName", "lastName", "gender", "occupation",
|
"contestantNumber", "email", "firstName", "lastName", "gender", "occupation",
|
||||||
"age", "countryRegionCity", "phoneNumber", "designTitle", "designDescription",
|
"age", "countryRegionCity", "phoneNumber", "designTitle", "designDescription",
|
||||||
"pdfPath", "videoPath", "videoDuration", "videoSizeMB", "pdfSizeMB", "createdAt", "updatedAt"
|
"pdfPath", "videoPath", "videoDuration", "videoSizeMB", "pdfSizeMB", "portfolioUrl", "createdAt", "updatedAt"
|
||||||
};
|
};
|
||||||
for (int i = 0; i < headers.length; i++) {
|
for (int i = 0; i < headers.length; i++) {
|
||||||
Cell c = header.createCell(i);
|
Cell c = header.createCell(i);
|
||||||
@@ -332,11 +332,9 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
|||||||
r.createCell(ci++).setCellValue(cst.getPhoneNumber() == null ? "" : cst.getPhoneNumber());
|
r.createCell(ci++).setCellValue(cst.getPhoneNumber() == null ? "" : cst.getPhoneNumber());
|
||||||
r.createCell(ci++).setCellValue(cst.getDesignTitle() == null ? "" : cst.getDesignTitle());
|
r.createCell(ci++).setCellValue(cst.getDesignTitle() == null ? "" : cst.getDesignTitle());
|
||||||
r.createCell(ci++).setCellValue(cst.getDesignDescription() == null ? "" : cst.getDesignDescription());
|
r.createCell(ci++).setCellValue(cst.getDesignDescription() == null ? "" : cst.getDesignDescription());
|
||||||
// r.createCell(ci++).setCellValue(cst.getPdfPath() == null ? "" : cst.getPdfPath());
|
r.createCell(ci++).setCellValue(cst.getPdfPath() == null ? "" : cst.getPdfPath());
|
||||||
// r.createCell(ci++).setCellValue(cst.getVideoPath() == null ? "" : cst.getVideoPath());
|
r.createCell(ci++).setCellValue(cst.getVideoPath() == null ? "" : cst.getVideoPath());
|
||||||
// 视频时长(秒)
|
|
||||||
r.createCell(ci++).setCellValue(cst.getVideoDuration() == null ? "" : cst.getVideoDuration().toString());
|
r.createCell(ci++).setCellValue(cst.getVideoDuration() == null ? "" : cst.getVideoDuration().toString());
|
||||||
// 视频大小、PDF 大小:以 MB 导出,保留两位小数
|
|
||||||
if (cst.getVideoSize() == null) {
|
if (cst.getVideoSize() == null) {
|
||||||
r.createCell(ci++).setCellValue("");
|
r.createCell(ci++).setCellValue("");
|
||||||
} else {
|
} else {
|
||||||
@@ -349,6 +347,7 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
|||||||
double pMb = cst.getPdfSize() / 1024.0 / 1024.0;
|
double pMb = cst.getPdfSize() / 1024.0 / 1024.0;
|
||||||
r.createCell(ci++).setCellValue(String.format("%.2f", pMb));
|
r.createCell(ci++).setCellValue(String.format("%.2f", pMb));
|
||||||
}
|
}
|
||||||
|
r.createCell(ci++).setCellValue(cst.getPortfolioUrl() == null ? "" : cst.getPortfolioUrl());
|
||||||
r.createCell(ci++).setCellValue(cst.getCreatedAt() == null ? "" : cst.getCreatedAt().toString());
|
r.createCell(ci++).setCellValue(cst.getCreatedAt() == null ? "" : cst.getCreatedAt().toString());
|
||||||
r.createCell(ci++).setCellValue(cst.getUpdatedAt() == null ? "" : cst.getUpdatedAt().toString());
|
r.createCell(ci++).setCellValue(cst.getUpdatedAt() == null ? "" : cst.getUpdatedAt().toString());
|
||||||
}
|
}
|
||||||
@@ -387,6 +386,7 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
|||||||
dto.setVideoDuration(existing.getVideoDuration());
|
dto.setVideoDuration(existing.getVideoDuration());
|
||||||
dto.setPdfSize(existing.getPdfSize());
|
dto.setPdfSize(existing.getPdfSize());
|
||||||
dto.setVideoSize(existing.getVideoSize());
|
dto.setVideoSize(existing.getVideoSize());
|
||||||
|
dto.setPortfolioUrl(existing.getPortfolioUrl());
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,7 +480,7 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int exportContestantFiles(Integer minContestantNumber, Integer maxContestantNumber) throws Exception {
|
public byte[] exportContestantFilesAsZip(Integer minContestantNumber, Integer maxContestantNumber) throws Exception {
|
||||||
if (minContestantNumber == null || maxContestantNumber == null) {
|
if (minContestantNumber == null || maxContestantNumber == null) {
|
||||||
throw new BusinessException("minContestantNumber and maxContestantNumber are required.");
|
throw new BusinessException("minContestantNumber and maxContestantNumber are required.");
|
||||||
}
|
}
|
||||||
@@ -488,7 +488,7 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
|||||||
throw new BusinessException("minContestantNumber cannot be greater than maxContestantNumber.");
|
throw new BusinessException("minContestantNumber cannot be greater than maxContestantNumber.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 根据contestantNumber范围查询参赛者
|
// 1. 根据 contestantNumber 范围查询参赛者
|
||||||
QueryWrapper<Contestant> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Contestant> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.lambda()
|
queryWrapper.lambda()
|
||||||
.ge(Contestant::getContestantNumber, minContestantNumber)
|
.ge(Contestant::getContestantNumber, minContestantNumber)
|
||||||
@@ -498,90 +498,126 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
|||||||
|
|
||||||
if (contestants.isEmpty()) {
|
if (contestants.isEmpty()) {
|
||||||
log.info("No contestants found in range [{}, {}]", minContestantNumber, maxContestantNumber);
|
log.info("No contestants found in range [{}, {}]", minContestantNumber, maxContestantNumber);
|
||||||
return 0;
|
return new byte[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 创建基础目录
|
// 2. 在内存中构建 ZIP
|
||||||
String baseDir = uploadDir + "/contestants";
|
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
Path basePath = Paths.get(baseDir).toAbsolutePath();
|
java.util.zip.ZipOutputStream zos = new java.util.zip.ZipOutputStream(baos)) {
|
||||||
Files.createDirectories(basePath);
|
|
||||||
log.info("Base directory created: {}", basePath);
|
|
||||||
|
|
||||||
int exportedCount = 0;
|
for (Contestant contestant : contestants) {
|
||||||
|
Integer contestantNumber = contestant.getContestantNumber();
|
||||||
// 3. 遍历每个参赛者,下载文件
|
if (contestantNumber == null) {
|
||||||
for (Contestant contestant : contestants) {
|
log.warn("Contestant {} has no contestantNumber, skipping", contestant.getId());
|
||||||
Integer contestantNumber = contestant.getContestantNumber();
|
continue;
|
||||||
if (contestantNumber == null) {
|
|
||||||
log.warn("Contestant {} has no contestantNumber, skipping", contestant.getId());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建参赛者文件夹
|
|
||||||
String contestantDir = baseDir + "/" + contestantNumber;
|
|
||||||
Path contestantPath = Paths.get(contestantDir);
|
|
||||||
Files.createDirectories(contestantPath);
|
|
||||||
|
|
||||||
// 下载PDF文件
|
|
||||||
String pdfPath = contestant.getPdfPath();
|
|
||||||
if (StringUtils.isNotBlank(pdfPath)) {
|
|
||||||
try {
|
|
||||||
String fileName = pdfPath.contains("/") ?
|
|
||||||
pdfPath.substring(pdfPath.lastIndexOf("/") + 1) : "design.pdf";
|
|
||||||
downloadFileFromMinio(pdfPath, contestantPath.toString(), "design.pdf");
|
|
||||||
log.info("Downloaded PDF for contestant {}", fileName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Failed to download PDF for contestant {}: {}", contestantNumber, e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 下载视频文件
|
String dirPrefix = contestantNumber + "/";
|
||||||
String videoPath = contestant.getVideoPath();
|
|
||||||
if (StringUtils.isNotBlank(videoPath)) {
|
// 添加 PDF 文件
|
||||||
try {
|
String pdfPath = contestant.getPdfPath();
|
||||||
// 根据路径判断视频格式
|
if (StringUtils.isNotBlank(pdfPath)) {
|
||||||
|
addMinioFileToZip(zos, pdfPath, dirPrefix + "design.pdf");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加视频文件
|
||||||
|
String videoPath = contestant.getVideoPath();
|
||||||
|
if (StringUtils.isNotBlank(videoPath)) {
|
||||||
String fileName = videoPath.contains("/") ?
|
String fileName = videoPath.contains("/") ?
|
||||||
videoPath.substring(videoPath.lastIndexOf("/") + 1) : "video.mp4";
|
videoPath.substring(videoPath.lastIndexOf("/") + 1) : "video.mp4";
|
||||||
downloadFileFromMinio(videoPath, contestantPath.toString(), fileName);
|
addMinioFileToZip(zos, videoPath, dirPrefix + fileName);
|
||||||
log.info("Downloaded video for contestant {}", contestantNumber);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Failed to download video for contestant {}: {}", contestantNumber, e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加参赛者信息 txt 文件
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("=== Contestant Information ===\n\n");
|
||||||
|
sb.append("ID: ").append(nullSafe(contestant.getId())).append("\n");
|
||||||
|
sb.append("Email: ").append(nullSafe(contestant.getEmail())).append("\n");
|
||||||
|
sb.append("Contestant Number: ").append(contestantNumber).append("\n");
|
||||||
|
sb.append("First Name: ").append(nullSafe(contestant.getFirstName())).append("\n");
|
||||||
|
sb.append("Last Name: ").append(nullSafe(contestant.getLastName())).append("\n");
|
||||||
|
sb.append("Gender: ").append(nullSafe(contestant.getGender())).append("\n");
|
||||||
|
sb.append("Occupation: ").append(nullSafe(contestant.getOccupation())).append("\n");
|
||||||
|
sb.append("Age: ").append(contestant.getAge() != null ? contestant.getAge() : "N/A").append("\n");
|
||||||
|
sb.append("Country/Region/City: ").append(nullSafe(contestant.getCountryRegionCity())).append("\n");
|
||||||
|
sb.append("Phone Number: ").append(nullSafe(contestant.getPhoneNumber())).append("\n");
|
||||||
|
sb.append("Design Title: ").append(nullSafe(contestant.getDesignTitle())).append("\n");
|
||||||
|
sb.append("Design Description: ").append(nullSafe(contestant.getDesignDescription())).append("\n");
|
||||||
|
sb.append("PDF Path: ").append(nullSafe(pdfPath)).append("\n");
|
||||||
|
sb.append("PDF Size (bytes): ").append(contestant.getPdfSize() != null ? contestant.getPdfSize() : "N/A").append("\n");
|
||||||
|
sb.append("Video Path: ").append(nullSafe(videoPath)).append("\n");
|
||||||
|
sb.append("Video Duration (seconds): ").append(contestant.getVideoDuration() != null ? contestant.getVideoDuration() : "N/A").append("\n");
|
||||||
|
sb.append("Video Size (bytes): ").append(contestant.getVideoSize() != null ? contestant.getVideoSize() : "N/A").append("\n");
|
||||||
|
sb.append("Portfolio URL: ").append(nullSafe(contestant.getPortfolioUrl())).append("\n");
|
||||||
|
sb.append("Created At: ").append(contestant.getCreatedAt() != null ? contestant.getCreatedAt() : "N/A").append("\n");
|
||||||
|
sb.append("Updated At: ").append(contestant.getUpdatedAt() != null ? contestant.getUpdatedAt() : "N/A").append("\n");
|
||||||
|
|
||||||
|
ZipEntry infoEntry = new ZipEntry(dirPrefix + "contestant_info.txt");
|
||||||
|
zos.putNextEntry(infoEntry);
|
||||||
|
zos.write(sb.toString().getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||||
|
zos.closeEntry();
|
||||||
|
log.info("Added contestant {} info to zip", contestantNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
exportedCount++;
|
zos.finish();
|
||||||
|
log.info("ZIP built for {} contestants, size: {} bytes", contestants.size(), baos.size());
|
||||||
|
return baos.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("Exported {} contestants' files to {}", exportedCount, basePath);
|
|
||||||
return exportedCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从MinIO下载文件到本地
|
* 将 MinIO 文件流式写入 ZIP,不落盘
|
||||||
* @param minioPath MinIO路径 (格式: bucketName/objectPath)
|
* @param zos ZIP 输出流
|
||||||
* @param localDir 本地目录
|
* @param minioPath MinIO 路径(格式: bucketName/objectPath)
|
||||||
* @param fileName 本地文件名
|
* @param entryName ZIP 条目名称
|
||||||
*/
|
*/
|
||||||
private void downloadFileFromMinio(String minioPath, String localDir, String fileName) {
|
private void addMinioFileToZip(java.util.zip.ZipOutputStream zos, String minioPath, String entryName) {
|
||||||
if (StringUtils.isBlank(minioPath)) {
|
if (StringUtils.isBlank(minioPath)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从路径中提取bucket名称和对象名称
|
|
||||||
int index = minioPath.indexOf("/");
|
int index = minioPath.indexOf("/");
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
log.warn("Invalid MinIO path: {}", minioPath);
|
log.warn("Invalid MinIO path: {}", minioPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String bucketName = minioPath.substring(0, index);
|
String bucketName = minioPath.substring(0, index);
|
||||||
String objectName = minioPath.substring(index + 1);
|
String objectName = minioPath.substring(index + 1);
|
||||||
|
|
||||||
// 构建本地文件完整路径
|
try (InputStream in = minioUtil.download(bucketName, objectName)) {
|
||||||
Path localFilePath = Paths.get(localDir, fileName);
|
ZipEntry entry = new ZipEntry(entryName);
|
||||||
|
zos.putNextEntry(entry);
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = in.read(buffer)) != -1) {
|
||||||
|
zos.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
zos.closeEntry();
|
||||||
|
log.info("Added {} to zip ({} bytes)", entryName, entry.getSize());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Failed to add {} to zip: {}", entryName, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 下载文件
|
@Override
|
||||||
minioUtil.downloadMinioObjectToLocal(bucketName, objectName, localFilePath.toString());
|
public ContestantCountVO getContestantCount() {
|
||||||
|
long count = contestantMapper.selectCount(null);
|
||||||
|
Integer maxContestantNumber = null;
|
||||||
|
QueryWrapper<Contestant> qMax = new QueryWrapper<>();
|
||||||
|
qMax.isNotNull("contestant_number");
|
||||||
|
qMax.orderByDesc("contestant_number");
|
||||||
|
qMax.last("LIMIT 1");
|
||||||
|
Contestant last = contestantMapper.selectOne(qMax);
|
||||||
|
if (last != null) {
|
||||||
|
maxContestantNumber = last.getContestantNumber();
|
||||||
|
}
|
||||||
|
return ContestantCountVO.builder()
|
||||||
|
.count(count)
|
||||||
|
.maxContestantNumber(maxContestantNumber)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String nullSafe(String value) {
|
||||||
|
return value != null ? value : "N/A";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import com.ai.da.common.enums.CollectionLevel1TypeEnum;
|
|||||||
import com.ai.da.common.response.PageBaseResponse;
|
import com.ai.da.common.response.PageBaseResponse;
|
||||||
import com.ai.da.common.response.PageResponse;
|
import com.ai.da.common.response.PageResponse;
|
||||||
import com.ai.da.common.response.Response;
|
import com.ai.da.common.response.Response;
|
||||||
import com.ai.da.common.security.jwt.JWTTokenHelper;
|
import com.ai.da.common.utils.TokenGenerateUtils;
|
||||||
import com.ai.da.common.utils.MinioUtil;
|
import com.ai.da.common.utils.MinioUtil;
|
||||||
import com.ai.da.mapper.primary.*;
|
import com.ai.da.mapper.primary.*;
|
||||||
import com.ai.da.mapper.primary.entity.*;
|
import com.ai.da.mapper.primary.entity.*;
|
||||||
@@ -70,7 +70,7 @@ public class LLMServiceImpl implements LLMService {
|
|||||||
@Resource
|
@Resource
|
||||||
private WorkspaceRelStyleMapper workspaceRelStyleMapper;
|
private WorkspaceRelStyleMapper workspaceRelStyleMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private JWTTokenHelper jwtTokenHelper;
|
private TokenGenerateUtils tokenGenerateUtils;
|
||||||
@Resource
|
@Resource
|
||||||
private DesignService designService;
|
private DesignService designService;
|
||||||
private final ExecutorService executor = Executors.newCachedThreadPool();
|
private final ExecutorService executor = Executors.newCachedThreadPool();
|
||||||
@@ -89,9 +89,9 @@ public class LLMServiceImpl implements LLMService {
|
|||||||
|
|
||||||
executor.submit(() -> {
|
executor.submit(() -> {
|
||||||
try {
|
try {
|
||||||
boolean validate = jwtTokenHelper.validateToken(token); //
|
boolean validate = tokenGenerateUtils.validateToken(token); //
|
||||||
if (validate) {
|
if (validate) {
|
||||||
AuthPrincipalVo principal = jwtTokenHelper.parserToUser(token);
|
AuthPrincipalVo principal = tokenGenerateUtils.parserToUser(token);
|
||||||
Long accountId = principal.getId();
|
Long accountId = principal.getId();
|
||||||
// String url = "http://18.167.251.121:10002/chat-stream";
|
// String url = "http://18.167.251.121:10002/chat-stream";
|
||||||
String url = "http://10.1.1.240:1013/chat-stream";
|
String url = "http://10.1.1.240:1013/chat-stream";
|
||||||
@@ -237,10 +237,10 @@ public class LLMServiceImpl implements LLMService {
|
|||||||
|
|
||||||
executor.submit(() -> {
|
executor.submit(() -> {
|
||||||
try {
|
try {
|
||||||
boolean validate = jwtTokenHelper.validateToken(token);
|
boolean validate = tokenGenerateUtils.validateToken(token);
|
||||||
// boolean validate = true;
|
// boolean validate = true;
|
||||||
if (validate) {
|
if (validate) {
|
||||||
AuthPrincipalVo principal = jwtTokenHelper.parserToUser(token);
|
AuthPrincipalVo principal = tokenGenerateUtils.parserToUser(token);
|
||||||
Long accountId = principal.getId();
|
Long accountId = principal.getId();
|
||||||
// String url = "http://18.167.251.121:10002/api/chat_stream";
|
// String url = "http://18.167.251.121:10002/api/chat_stream";
|
||||||
String url = "http://18.167.251.121:2011/api/chat_stream";
|
String url = "http://18.167.251.121:2011/api/chat_stream";
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import com.ai.da.model.enums.Module;
|
|||||||
import com.ai.da.model.vo.*;
|
import com.ai.da.model.vo.*;
|
||||||
import com.ai.da.python.PythonService;
|
import com.ai.da.python.PythonService;
|
||||||
import com.ai.da.service.*;
|
import com.ai.da.service.*;
|
||||||
|
import com.ai.da.seller.DesignUrlsDTO;
|
||||||
|
import com.ai.da.seller.PoseTransformationVideoDTO;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@@ -31,6 +33,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@@ -61,6 +64,8 @@ import java.time.ZoneId;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.ai.da.common.enums.LayersPriorityEnum.BODY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务实现类
|
* 服务实现类
|
||||||
*
|
*
|
||||||
@@ -71,6 +76,89 @@ import java.util.stream.Collectors;
|
|||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, UserLikeGroup> implements UserLikeGroupService {
|
public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, UserLikeGroup> implements UserLikeGroupService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据CollectionSort ID查询子记录,将TO_PRODUCT_IMAGE类型的URL和姿势转换视频信息写入DesignUrlsDTO
|
||||||
|
* @param collectionSortId CollectionSort ID
|
||||||
|
* @param designUrlsDTO DesignUrlsDTO,用于收集图片URL和视频信息
|
||||||
|
*/
|
||||||
|
private void getToProductImageUrlsByCollectionSortId(Long collectionSortId, DesignUrlsDTO designUrlsDTO) {
|
||||||
|
// 查询子记录中的TO_PRODUCT_IMAGE类型
|
||||||
|
QueryWrapper<CollectionSort> childCollectionQw = new QueryWrapper<>();
|
||||||
|
childCollectionQw.lambda().eq(CollectionSort::getParentId, collectionSortId);
|
||||||
|
childCollectionQw.lambda().in(CollectionSort::getRelationType, CollectionType.TO_PRODUCT_IMAGE.getValue(), CollectionType.RELIGHT.getValue(), CollectionType.POSE_TRANSFORM.getValue());
|
||||||
|
childCollectionQw.lambda().orderByAsc(CollectionSort::getSort);
|
||||||
|
List<CollectionSort> childSortList = collectionSortMapper.selectList(childCollectionQw);
|
||||||
|
|
||||||
|
for (CollectionSort userLikeSort : childSortList) {
|
||||||
|
if (userLikeSort.getRelationType().equals(CollectionType.POSE_TRANSFORM.getValue())){
|
||||||
|
PoseTransformation poseTransformation = poseTransformationMapper.selectById(userLikeSort.getRelationId());
|
||||||
|
if (poseTransformation != null) {
|
||||||
|
PoseTransformationVideoDTO videoDTO = new PoseTransformationVideoDTO();
|
||||||
|
videoDTO.setFirstFrameUrl(minioUtil.processMinioResource(poseTransformation.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
videoDTO.setGifUrl(minioUtil.processMinioResource(poseTransformation.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
videoDTO.setVideoUrl(minioUtil.processMinioResource(poseTransformation.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
designUrlsDTO.getVideos().add(videoDTO);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(userLikeSort.getRelationId());
|
||||||
|
if (toProductImageResult != null && !isGenerateTaskFailed(toProductImageResult.getStatus(), toProductImageResult.getCreateTime())) {
|
||||||
|
String url = toProductImageResult.getUrl();
|
||||||
|
designUrlsDTO.getToProductImageUrls().add(minioUtil.processMinioResource(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据designItemId获取TO_PRODUCT_IMAGE类型的URL列表和DesignItemDetail的path列表
|
||||||
|
* @param designItemId designItemId
|
||||||
|
* @return 包含TO_PRODUCT_IMAGE类型的URL列表和DesignItemDetail的path列表的对象
|
||||||
|
*/
|
||||||
|
public DesignUrlsDTO getToProductImageUrlsByDesignItemId(Long designItemId) {
|
||||||
|
DesignUrlsDTO designUrlsDTO = new DesignUrlsDTO();
|
||||||
|
designUrlsDTO.setDesignItemId(designItemId);
|
||||||
|
designUrlsDTO.setVideos(new ArrayList<>());
|
||||||
|
designUrlsDTO.setToProductImageUrls(new ArrayList<>());
|
||||||
|
designUrlsDTO.setClothes(new ArrayList<>());
|
||||||
|
|
||||||
|
// 根据designItemId查询UserLike
|
||||||
|
QueryWrapper<UserLike> userLikeQueryWrapper = new QueryWrapper<>();
|
||||||
|
userLikeQueryWrapper.lambda().eq(UserLike::getDesignItemId, designItemId);
|
||||||
|
UserLike userLike = userLikeMapper.selectOne(userLikeQueryWrapper);
|
||||||
|
|
||||||
|
if (userLike != null) {
|
||||||
|
// 根据UserLike的ID查询CollectionSort
|
||||||
|
QueryWrapper<CollectionSort> collectionSortQueryWrapper = new QueryWrapper<>();
|
||||||
|
collectionSortQueryWrapper.lambda().eq(CollectionSort::getRelationId, userLike.getId());
|
||||||
|
collectionSortQueryWrapper.lambda().eq(CollectionSort::getRelationType, CollectionType.DESIGN.getValue());
|
||||||
|
CollectionSort collectionSort = collectionSortMapper.selectOne(collectionSortQueryWrapper);
|
||||||
|
|
||||||
|
if (collectionSort != null) {
|
||||||
|
// 获取TO_PRODUCT_IMAGE类型的URL列表
|
||||||
|
getToProductImageUrlsByCollectionSortId(collectionSort.getId(), designUrlsDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询DesignItemDetail表,排除type为"Body"的数据
|
||||||
|
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
||||||
|
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemId);
|
||||||
|
designItemDetailQueryWrapper.lambda().ne(DesignItemDetail::getType, BODY.getType());
|
||||||
|
List<DesignItemDetail> designItemDetails = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
||||||
|
|
||||||
|
for (DesignItemDetail designItemDetail : designItemDetails) {
|
||||||
|
// 判断当前用户是否是DesignItemDetail的创建者
|
||||||
|
if (!Objects.equals(designItemDetail.getAccountId(), UserContext.getUserHolder().getId())){
|
||||||
|
throw new BusinessException("unknown.authentication.operation.type");
|
||||||
|
}
|
||||||
|
if (designItemDetail.getPath() != null) {
|
||||||
|
designUrlsDTO.getClothes().add(minioUtil.processMinioResource(designItemDetail.getPath(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return designUrlsDTO;
|
||||||
|
}
|
||||||
|
|
||||||
private final UserLikeGroupMapper userLikeGroupMapper;
|
private final UserLikeGroupMapper userLikeGroupMapper;
|
||||||
private final AccountMapper accountMapper;
|
private final AccountMapper accountMapper;
|
||||||
private final CollectionService collectionService;
|
private final CollectionService collectionService;
|
||||||
@@ -87,6 +175,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
private final PortfolioMapper portfolioMapper;
|
private final PortfolioMapper portfolioMapper;
|
||||||
private final TagsMapper tagsMapper;
|
private final TagsMapper tagsMapper;
|
||||||
private final DesignItemDetailService designItemDetailService;
|
private final DesignItemDetailService designItemDetailService;
|
||||||
|
private final DesignItemDetailMapper designItemDetailMapper;
|
||||||
private final CollectionElementMapper collectionElementMapper;
|
private final CollectionElementMapper collectionElementMapper;
|
||||||
private final AttributeRetrievalMapper attributeRetrievalMapper;
|
private final AttributeRetrievalMapper attributeRetrievalMapper;
|
||||||
private final ProductImageAttributeMapper productImageAttributeMapper;
|
private final ProductImageAttributeMapper productImageAttributeMapper;
|
||||||
|
|||||||
@@ -547,7 +547,7 @@ public class UploadServiceImpl implements UploadService {
|
|||||||
/**
|
/**
|
||||||
* 清理过期上传任务(每小时执行一次)
|
* 清理过期上传任务(每小时执行一次)
|
||||||
*/
|
*/
|
||||||
@Scheduled(fixedDelay = 3600000) // 1小时
|
// @Scheduled(fixedDelay = 3600000) // 1小时
|
||||||
public void cleanupExpiredUploads() {
|
public void cleanupExpiredUploads() {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
uploadTasks.entrySet().removeIf(entry -> {
|
uploadTasks.entrySet().removeIf(entry -> {
|
||||||
|
|||||||
@@ -1,184 +0,0 @@
|
|||||||
server.port=5567
|
|
||||||
|
|
||||||
spring.datasource.primary.driver-class-name=com.mysql.cj.jdbc.Driver
|
|
||||||
#spring.datasource.primary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
|
||||||
spring.datasource.primary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/aida_back?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
|
||||||
#spring.datasource.primary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/test_aida_3.1?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
|
||||||
spring.datasource.primary.username=aida_con
|
|
||||||
spring.datasource.primary.password=123456
|
|
||||||
|
|
||||||
spring.datasource.secondary.driver-class-name=com.mysql.cj.jdbc.Driver
|
|
||||||
spring.datasource.secondary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/attribute_retrieval_style?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
|
||||||
spring.datasource.secondary.username=aida_con
|
|
||||||
spring.datasource.secondary.password=123456
|
|
||||||
|
|
||||||
#security
|
|
||||||
spring.security.jwtSecret=JWTSECRET
|
|
||||||
spring.security.jwtTokenHeader=Authorization
|
|
||||||
spring.security.jwtTokenPrefix=Bearer-
|
|
||||||
## 24Сʱ
|
|
||||||
spring.security.jwtExpiration=8640000000
|
|
||||||
#spring security权限设置 认证了token还要认证权限 不然报错Full authentication is required to access this resource
|
|
||||||
spring.security.ignorePaths=/,/favicon.ico,/doc.html,/webjars/**,/swagger-resources,/v2/api-docs,\
|
|
||||||
/api/account/**,/api/element/**,/api/python/**,/api/design/**,/api/history/**,/api/library/**,/api/third/party/**,/api/generate/**,/api/workspace/**,/api/classification/**,\
|
|
||||||
/api/product/**,/api/ali-pay/**,/api/order-info/**,/api/paypal/**,/api/credits/**,/api/inquiry/**,/api/tasks/**,/api/python/prepareForSR,/api/alipay-hk/**,/api/portfolio/**,\
|
|
||||||
/api/stripe/**,/api/message/**,/api/tags/**,/notification/**,/api/affiliate/**,/api/project/**,/api/llm/**, /api/subscription_plan/**,/api/global-award/**
|
|
||||||
spring.security.authApi=/auth/login
|
|
||||||
|
|
||||||
|
|
||||||
rsa.private_key=MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
|
|
||||||
|
|
||||||
#mybatis
|
|
||||||
mybatis-plus.global-config.banner=false
|
|
||||||
mybatis-plus.mapper-locations=classpath:mapper/*/*.xml
|
|
||||||
mybatis-plus.global-config.db-config.logic-delete-field=isDeleted
|
|
||||||
mybatis-plus.global-config.db-config.logic-delete-value=1
|
|
||||||
mybatis-plus.global-config.db-config.logic-not-delete-value=0
|
|
||||||
|
|
||||||
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
|
|
||||||
|
|
||||||
file.mac.path=~/file/
|
|
||||||
file.linux.path=/workspace/home/aida/file/
|
|
||||||
#linux服务器域名(预览和下载用)
|
|
||||||
file.linuxDomain=https://www.aida.com.hk/download/
|
|
||||||
file.windows.path=D:\\upload\\
|
|
||||||
spring.servlet.multipart.max-file-size = 10MB
|
|
||||||
spring.servlet.multipart.max-request-size= 10MB
|
|
||||||
#访问python服务的ip(对应环境)
|
|
||||||
access.python.ip=http://18.167.251.121
|
|
||||||
access.python.port=9994
|
|
||||||
access.python.generate_sr_port=9994
|
|
||||||
access.python.address=http://18.167.251.121:9994
|
|
||||||
|
|
||||||
minio.endpoint=https://www.minio-api.aida.com.hk
|
|
||||||
minio.accessKey=admin
|
|
||||||
minio.secretKey=Aidlab123123!
|
|
||||||
minio.bucketName.clothing=aida-clothing
|
|
||||||
minio.bucketName.mannequins=aida-mannequins
|
|
||||||
minio.bucketName.results=aida-results
|
|
||||||
minio.bucketName.sysImage=aida-sys-image
|
|
||||||
minio.bucketName.users=aida-users
|
|
||||||
minio.bucketName.collectionElement=aida-collection-element
|
|
||||||
minio.bucketName.gradient=aida-gradient
|
|
||||||
minio.bucketName.modifiedSketch=aida-modified-sketch
|
|
||||||
minio.bucketName.slogan=aida-slogan
|
|
||||||
minio.bucketName.partialDesign=aida-partial-design
|
|
||||||
minio.bucketName.globalAward=global-award
|
|
||||||
redirect_url=http://18.167.251.121:7788
|
|
||||||
|
|
||||||
spring.rabbitmq.host=18.167.251.121
|
|
||||||
spring.rabbitmq.port=5672
|
|
||||||
spring.rabbitmq.username=rabbit
|
|
||||||
spring.rabbitmq.password=123456
|
|
||||||
spring.rabbitmq.virtual-host=/
|
|
||||||
|
|
||||||
spring.data.redis.host=172.31.11.32
|
|
||||||
#spring.data.redis.host=18.167.251.121
|
|
||||||
spring.data.redis.port=6379
|
|
||||||
spring.data.redis.database=1
|
|
||||||
spring.data.redis.password=Aidlab
|
|
||||||
spring.data.redis.lettuce.pool.max-active=8
|
|
||||||
spring.data.redis.lettuce.pool.max-idle=8
|
|
||||||
spring.data.redis.lettuce.pool.min-idle=0
|
|
||||||
spring.data.redis.lettuce.pool.max-wait=5
|
|
||||||
|
|
||||||
redis.key.orderForGenerate=OrderForGenerate
|
|
||||||
redis.key.generateCancelSet=GenerateCancelSet
|
|
||||||
redis.key.generateExceptionMap=Generate:Exception
|
|
||||||
redis.key.resultMap=ResultMap
|
|
||||||
redis.key.orderForSR=OrderForSR
|
|
||||||
redis.key.SRCancelSet=SRCancelSet
|
|
||||||
redis.key.SRExceptionMap=SRExceptionMap
|
|
||||||
redis.key.taskList=TaskList
|
|
||||||
redis.key.credits.pre-deduction=Credits:PreDeduction
|
|
||||||
redis.key.generateResult=Generate:Result
|
|
||||||
redis.key.toProductImageResultKey=ToProductImage:Result
|
|
||||||
redis.key.relightResultKey=Relight:Result
|
|
||||||
redis.key.newPosted=LastViewNewPostedTime
|
|
||||||
redis.key.maximumUserId=CodeCreate:MaximumUserId
|
|
||||||
|
|
||||||
aws.s3.accessKeyId=AKIAVD3OJIMF6UJFLSHZ
|
|
||||||
aws.s3.secretKey=LNIwFFB27/QedtZ+Q/viVUoX9F5x1DbuM8N0DkD8
|
|
||||||
aws.s3.regionName=ap-east-1
|
|
||||||
|
|
||||||
# RabbitMQ Exchange and Queue configurations
|
|
||||||
rabbitmq.queues.generate=generate-queue-dev
|
|
||||||
rabbitmq.queues.sr=SR-queue-dev
|
|
||||||
rabbitmq.queues.srResult=SuperResolution-dev
|
|
||||||
rabbitmq.queues.generateResult=GenerateImage-dev
|
|
||||||
rabbitmq.queues.toProductImageResult=ToProductImage-dev
|
|
||||||
rabbitmq.queues.relightResult=Relight-dev
|
|
||||||
rabbitmq.queues.poseTransform=PoseTransform-dev
|
|
||||||
rabbitmq.exchange.generate=generate-exchange
|
|
||||||
rabbitmq.queues.designBatch=DesignBatch-dev
|
|
||||||
rabbitmq.queues.relightBatch=BatchRelight-dev
|
|
||||||
rabbitmq.queues.toProductImageBatch=BatchToProductImage-dev
|
|
||||||
rabbitmq.queues.poseTransformBatch=BatchPoseTransform-dev
|
|
||||||
rabbitmq.queues.emailRetry=emailRetry-business
|
|
||||||
# 死信队列配置
|
|
||||||
rabbitmq.dead-letter.exchange=dlx.email-retry
|
|
||||||
rabbitmq.dead-letter.queue=dlx.email-retry.queue
|
|
||||||
rabbitmq.dead-letter.routing-key=dlx.email-retry.key
|
|
||||||
|
|
||||||
orderList.link=https://develop.aida.com.hk/home/homePage?order=
|
|
||||||
|
|
||||||
# 0 不发送邮件通知 1 发送邮件通知
|
|
||||||
stripe.webhook.fail.reminder=0
|
|
||||||
# kim test
|
|
||||||
#stripe.paymentMethodConfiguration=pmc_1LywTWH7nPZ8bkrN6FvdCUWG
|
|
||||||
# developer test
|
|
||||||
stripe.paymentMethodConfiguration=pmc_1QIKyq02n1TEydyNKVEYvhW7
|
|
||||||
#thymelea模板配置
|
|
||||||
#控制 Thymeleaf 是否启用模板缓存 生产环境用true,以提高性能
|
|
||||||
spring.thymeleaf.cache=false
|
|
||||||
|
|
||||||
#指定邮件服务器的地址。
|
|
||||||
spring.mail.host=mail.aida.com.hk
|
|
||||||
#指定邮件服务器的端口号。
|
|
||||||
spring.mail.port=465
|
|
||||||
#指定登录邮件服务器的用户名
|
|
||||||
spring.mail.username=info@aida.com.hk
|
|
||||||
#指定登录邮件服务器的密码 / 授权码
|
|
||||||
spring.mail.password=AIdlab@2025
|
|
||||||
spring.mail.default-encoding=UTF-8
|
|
||||||
|
|
||||||
# SSL 配置
|
|
||||||
#启用 SSL 加密
|
|
||||||
spring.mail.properties.mail.smtp.ssl.enable=true
|
|
||||||
#指定 SSL 连接的端口号。通常与 spring.mail.port 一致
|
|
||||||
spring.mail.properties.mail.smtp.socketFactory.port=465
|
|
||||||
|
|
||||||
ALIYUN_API_KEY=sk-dc3f88b7df844fc5a7d3616ebd8a589c
|
|
||||||
DOUBAO_API_KEY=853b3c55-f1dd-406e-a356-64123637f635
|
|
||||||
FREEPIK_API_KEY=FPSX94e5917d376a4facb87dabbaa0319c72
|
|
||||||
|
|
||||||
ollama.url=http://localhost:11434/api/chat
|
|
||||||
|
|
||||||
#google.client.id=29310152396-c44dcsoksjirhn7vbo29p8u8n0sg4qps.apps.googleusercontent.com
|
|
||||||
google.client.id=157095842121-kdd1fdf8m8nudvj9sprstb2k2prnf9e4.apps.googleusercontent.com
|
|
||||||
#google.client.secret=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
|
|
||||||
google.client.secret=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
|
|
||||||
google.redirect.uri=https://develop.api.aida.com.hk/api/third/party/auth/google_callback
|
|
||||||
design.callback.url=https://develop.api.aida.com.hk/api/third/party/receiveDesignResults
|
|
||||||
|
|
||||||
# ===== 分片上传配置 =====
|
|
||||||
|
|
||||||
# 临时文件目录
|
|
||||||
file.upload.temp.dir=temp/uploads
|
|
||||||
|
|
||||||
# 分片大小配置
|
|
||||||
# PDF分片大小:1MB
|
|
||||||
file.upload.chunk.size.pdf=1048576
|
|
||||||
# 视频分片大小:2MB
|
|
||||||
file.upload.chunk.size.video=2097152
|
|
||||||
|
|
||||||
# 文件大小限制
|
|
||||||
# PDF最大文件大小:20MB
|
|
||||||
file.upload.max.size.pdf=20971520
|
|
||||||
# 视频最大文件大小:100MB
|
|
||||||
file.upload.max.size.video=104857600
|
|
||||||
|
|
||||||
# 上传任务过期时间(小时)
|
|
||||||
file.upload.task.expiry.hours=24
|
|
||||||
|
|
||||||
global.award.link=https://aida-global-design-awards.com.hk/contestants?id=
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
server.port=5567
|
|
||||||
|
|
||||||
#datasource
|
|
||||||
spring.datasource.primary.driver-class-name=com.mysql.cj.jdbc.Driver
|
|
||||||
spring.datasource.primary.jdbcUrl=jdbc:mysql://18.167.251.121:3306/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
|
||||||
spring.datasource.primary.username=root
|
|
||||||
spring.datasource.primary.password=QWa998345
|
|
||||||
|
|
||||||
spring.datasource.secondary.driver-class-name=com.mysql.cj.jdbc.Driver
|
|
||||||
spring.datasource.secondary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/attribute_retrieval_style?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
|
||||||
spring.datasource.secondary.username=aida_con
|
|
||||||
spring.datasource.secondary.password=123456
|
|
||||||
|
|
||||||
#security
|
|
||||||
spring.security.jwtSecret=JWTSECRET
|
|
||||||
spring.security.jwtTokenHeader=Authorization
|
|
||||||
spring.security.jwtTokenPrefix=Bearer-
|
|
||||||
## 24Сʱ
|
|
||||||
#spring.security.jwtExpiration=8640000000
|
|
||||||
spring.security.jwtExpiration=604800000
|
|
||||||
#spring security权限设置 认证了token还要认证权限 不然报错Full authentication is required to access this resource
|
|
||||||
spring.security.ignorePaths=/,/favicon.ico,/doc.html,/webjars/**,/swagger-resources,/v2/api-docs,\
|
|
||||||
/api/account/**,/api/element/**,/api/python/**,/api/design/**,/api/history/**,/api/library/**,/api/third/party/**,/api/generate/**,/api/workspace/**,/api/classification/**,\
|
|
||||||
/api/product/**,/api/ali-pay/**,/api/order-info/**,/api/paypal/**,/api/credits/**,/api/inquiry/**,/api/tasks/**,/api/python/prepareForSR,/api/alipay-hk/**,/api/portfolio/**,\
|
|
||||||
/api/stripe/**,/api/message/**,/api/tags/**,/notification/**,/api/affiliate/**,/api/project/**,/api/llm/**, /api/subscription_plan/**,/api/global-award/**
|
|
||||||
spring.security.authApi=/auth/login
|
|
||||||
|
|
||||||
|
|
||||||
rsa.private_key=MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
|
|
||||||
|
|
||||||
#mybatis
|
|
||||||
mybatis-plus.global-config.banner=false
|
|
||||||
mybatis-plus.mapper-locations=classpath:mapper/*/*.xml
|
|
||||||
mybatis-plus.global-config.db-config.logic-delete-field=isDeleted
|
|
||||||
mybatis-plus.global-config.db-config.logic-delete-value=1
|
|
||||||
mybatis-plus.global-config.db-config.logic-not-delete-value=0
|
|
||||||
|
|
||||||
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
|
|
||||||
|
|
||||||
file.mac.path=~/file/
|
|
||||||
file.linux.path=/workspace/home/aida/file/
|
|
||||||
#linux服务器域名(预览和下载用)
|
|
||||||
file.linuxDomain=https://www.aida.com.hk/download/
|
|
||||||
file.windows.path=D:\\upload\\
|
|
||||||
spring.servlet.multipart.max-file-size = 10MB
|
|
||||||
spring.servlet.multipart.max-request-size= 10MB
|
|
||||||
#访问python服务的ip(对应环境)
|
|
||||||
access.python.ip=http://18.167.251.121
|
|
||||||
access.python.port=9990
|
|
||||||
access.python.generate_sr_port=9990
|
|
||||||
access.python.address=http://18.167.251.121:9990
|
|
||||||
|
|
||||||
minio.endpoint=https://www.minio-api.aida.com.hk
|
|
||||||
minio.accessKey=admin
|
|
||||||
minio.secretKey=Aidlab123123!
|
|
||||||
minio.bucketName.clothing=aida-clothing
|
|
||||||
minio.bucketName.mannequins=aida-mannequins
|
|
||||||
minio.bucketName.results=aida-results
|
|
||||||
minio.bucketName.sysImage=aida-sys-image
|
|
||||||
minio.bucketName.users=aida-users
|
|
||||||
minio.bucketName.collectionElement=aida-collection-element
|
|
||||||
minio.bucketName.gradient=aida-gradient
|
|
||||||
minio.bucketName.modifiedSketch=aida-modified-sketch
|
|
||||||
minio.bucketName.slogan=aida-slogan
|
|
||||||
minio.bucketName.partialDesign=aida-partial-design
|
|
||||||
minio.bucketName.globalAward=global-award
|
|
||||||
redirect_url=http://18.167.251.121:7788
|
|
||||||
|
|
||||||
spring.rabbitmq.host=18.167.251.121
|
|
||||||
spring.rabbitmq.port=5672
|
|
||||||
spring.rabbitmq.username=rabbit
|
|
||||||
spring.rabbitmq.password=123456
|
|
||||||
spring.rabbitmq.virtual-host=/
|
|
||||||
|
|
||||||
spring.data.redis.host=172.31.11.32
|
|
||||||
#spring.data.redis.host=18.167.251.121
|
|
||||||
spring.data.redis.port=6379
|
|
||||||
spring.data.redis.database=2
|
|
||||||
spring.data.redis.password=Aidlab
|
|
||||||
spring.data.redis.lettuce.pool.max-active=8
|
|
||||||
spring.data.redis.lettuce.pool.max-idle=8
|
|
||||||
spring.data.redis.lettuce.pool.min-idle=0
|
|
||||||
spring.data.redis.lettuce.pool.max-wait=5
|
|
||||||
|
|
||||||
redis.key.orderForGenerate=OrderForGenerate
|
|
||||||
redis.key.generateCancelSet=GenerateCancelSet
|
|
||||||
redis.key.generateExceptionMap=Generate:Exception
|
|
||||||
redis.key.resultMap=ResultMap
|
|
||||||
redis.key.orderForSR=OrderForSR
|
|
||||||
redis.key.SRCancelSet=SRCancelSet
|
|
||||||
redis.key.SRExceptionMap=SRExceptionMap
|
|
||||||
redis.key.taskList=TaskList
|
|
||||||
redis.key.credits.pre-deduction=Credits:PreDeduction
|
|
||||||
redis.key.generateResult=Generate:Result
|
|
||||||
redis.key.toProductImageResultKey=ToProductImage:Result
|
|
||||||
redis.key.relightResultKey=Relight:Result
|
|
||||||
redis.key.newPosted=LastViewNewPostedTime
|
|
||||||
redis.key.maximumUserId=CodeCreate:MaximumUserId
|
|
||||||
|
|
||||||
aws.s3.accessKeyId=AKIAVD3OJIMF6UJFLSHZ
|
|
||||||
aws.s3.secretKey=LNIwFFB27/QedtZ+Q/viVUoX9F5x1DbuM8N0DkD8
|
|
||||||
aws.s3.regionName=ap-east-1
|
|
||||||
|
|
||||||
# RabbitMQ Exchange and Queue configurations
|
|
||||||
rabbitmq.queues.generate=generate-queue-prod
|
|
||||||
rabbitmq.queues.sr=SR-queue-prod
|
|
||||||
rabbitmq.queues.srResult=SuperResolution-prod
|
|
||||||
rabbitmq.queues.generateResult=GenerateImage-prod
|
|
||||||
rabbitmq.queues.toProductImageResult=ToProductImage-prod
|
|
||||||
rabbitmq.queues.relightResult=Relight-prod
|
|
||||||
rabbitmq.queues.poseTransform=PoseTransform-prod
|
|
||||||
rabbitmq.exchange.generate=generate-exchange
|
|
||||||
rabbitmq.queues.designBatch=DesignBatch-dev
|
|
||||||
rabbitmq.queues.relightBatch=BatchRelight-dev
|
|
||||||
rabbitmq.queues.toProductImageBatch=BatchToProductImage-dev
|
|
||||||
rabbitmq.queues.poseTransformBatch=BatchPoseTransform-dev
|
|
||||||
rabbitmq.queues.emailRetry=emailRetry-business
|
|
||||||
# 死信队列配置
|
|
||||||
rabbitmq.dead-letter.exchange=dlx.email-retry
|
|
||||||
rabbitmq.dead-letter.queue=dlx.email-retry.queue
|
|
||||||
rabbitmq.dead-letter.routing-key=dlx.email-retry.key
|
|
||||||
|
|
||||||
orderList.link=https://aida.com.hk/home/homePage?order=
|
|
||||||
|
|
||||||
# 0 不发送邮件通知 1 发送邮件通知
|
|
||||||
stripe.webhook.fail.reminder=1
|
|
||||||
# kim live
|
|
||||||
stripe.paymentMethodConfiguration=pmc_1Qu6yJH7nPZ8bkrNULYnFFPf
|
|
||||||
# kim test
|
|
||||||
#stripe.paymentMethodConfiguration=pmc_1LywTWH7nPZ8bkrN6FvdCUWG
|
|
||||||
# developer test
|
|
||||||
#stripe.paymentMethodConfiguration=pmc_1QIKyq02n1TEydyNKVEYvhW7
|
|
||||||
#thymelea模板配置
|
|
||||||
#控制 Thymeleaf 是否启用模板缓存 生产环境用true,以提高性能
|
|
||||||
spring.thymeleaf.cache=false
|
|
||||||
|
|
||||||
#指定邮件服务器的地址。
|
|
||||||
spring.mail.host=mail.aida.com.hk
|
|
||||||
#指定邮件服务器的端口号。
|
|
||||||
spring.mail.port=465
|
|
||||||
#指定登录邮件服务器的用户名
|
|
||||||
spring.mail.username=info@aida.com.hk
|
|
||||||
#指定登录邮件服务器的密码 / 授权码
|
|
||||||
spring.mail.password=AIdlab@2025
|
|
||||||
spring.mail.default-encoding=UTF-8
|
|
||||||
|
|
||||||
# SSL 配置
|
|
||||||
#启用 SSL 加密
|
|
||||||
spring.mail.properties.mail.smtp.ssl.enable=true
|
|
||||||
#指定 SSL 连接的端口号。通常与 spring.mail.port 一致
|
|
||||||
spring.mail.properties.mail.smtp.socketFactory.port=465
|
|
||||||
|
|
||||||
ALIYUN_API_KEY=sk-dc3f88b7df844fc5a7d3616ebd8a589c
|
|
||||||
DOUBAO_API_KEY=853b3c55-f1dd-406e-a356-64123637f635
|
|
||||||
FREEPIK_API_KEY=FPSX94e5917d376a4facb87dabbaa0319c72
|
|
||||||
|
|
||||||
google.client.id=29310152396-nnsd3h533fld665oguu8ovrt1nukmt46.apps.googleusercontent.com
|
|
||||||
google.client.secret=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
|
|
||||||
google.redirect.uri=https://www.api.aida.com.hk/api/third/party/auth/google_callback
|
|
||||||
design.callback.url=https://api.aida.com.hk/api/third/party/receiveDesignResults
|
|
||||||
|
|
||||||
# ===== 分片上传配置 =====
|
|
||||||
|
|
||||||
# 临时文件目录
|
|
||||||
file.upload.temp.dir=temp/uploads
|
|
||||||
|
|
||||||
# 分片大小配置
|
|
||||||
# PDF分片大小:1MB
|
|
||||||
file.upload.chunk.size.pdf=1048576
|
|
||||||
# 视频分片大小:2MB
|
|
||||||
file.upload.chunk.size.video=2097152
|
|
||||||
|
|
||||||
# 文件大小限制
|
|
||||||
# PDF最大文件大小:20MB
|
|
||||||
file.upload.max.size.pdf=20971520
|
|
||||||
# 视频最大文件大小:100MB
|
|
||||||
file.upload.max.size.video=104857600
|
|
||||||
|
|
||||||
# 上传任务过期时间(小时)
|
|
||||||
file.upload.task.expiry.hours=24
|
|
||||||
|
|
||||||
global.award.link=https://aida-global-design-awards.com.hk/contestants?id=
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
server.port=5567
|
|
||||||
|
|
||||||
#datasource
|
|
||||||
spring.datasource.primary.driver-class-name=com.mysql.cj.jdbc.Driver
|
|
||||||
spring.datasource.primary.jdbcUrl=jdbc:mysql://18.167.251.121:3306/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
|
||||||
spring.datasource.primary.username=root
|
|
||||||
spring.datasource.primary.password=QWa998345
|
|
||||||
|
|
||||||
spring.datasource.secondary.driver-class-name=com.mysql.cj.jdbc.Driver
|
|
||||||
spring.datasource.secondary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/attribute_retrieval_new?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
|
||||||
spring.datasource.secondary.username=aida_con
|
|
||||||
spring.datasource.secondary.password=123456
|
|
||||||
|
|
||||||
#security
|
|
||||||
spring.security.jwtSecret=JWTSECRET
|
|
||||||
spring.security.jwtTokenHeader=Authorization
|
|
||||||
spring.security.jwtTokenPrefix=Bearer-
|
|
||||||
## 24Сʱ
|
|
||||||
spring.security.jwtExpiration=8640000000
|
|
||||||
#spring security权限设置 认证了token还要认证权限 不然报错Full authentication is required to access this resource
|
|
||||||
spring.security.ignorePaths=/,/favicon.ico,/doc.html,/webjars/**,/swagger-resources,/v2/api-docs,\
|
|
||||||
/api/account/**,/api/element/**,/api/python/**,/api/design/**,/api/history/**,/api/library/**,/api/third/party/**,/api/generate/**,/api/workspace/**,/api/classification/**,\
|
|
||||||
/api/product/**,/api/ali-pay/**,/api/order-info/**,/api/paypal/**,/api/credits/**,/api/inquiry/**,/api/tasks/**,/api/python/prepareForSR
|
|
||||||
spring.security.authApi=/auth/login
|
|
||||||
|
|
||||||
|
|
||||||
rsa.private_key=MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
|
|
||||||
|
|
||||||
#mybatis
|
|
||||||
mybatis-plus.global-config.banner=false
|
|
||||||
mybatis-plus.mapper-locations=classpath:mapper/*/*.xml
|
|
||||||
mybatis-plus.global-config.db-config.logic-delete-field=isDeleted
|
|
||||||
mybatis-plus.global-config.db-config.logic-delete-value=1
|
|
||||||
mybatis-plus.global-config.db-config.logic-not-delete-value=0
|
|
||||||
|
|
||||||
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
|
|
||||||
|
|
||||||
file.mac.path=~/file/
|
|
||||||
file.linux.path=/workspace/home/aida/file/
|
|
||||||
#linux服务器域名(预览和下载用)
|
|
||||||
file.linuxDomain=https://www.aida.com.hk/download/
|
|
||||||
file.windows.path=D:\\upload\\
|
|
||||||
spring.servlet.multipart.max-file-size = 10MB
|
|
||||||
spring.servlet.multipart.max-request-size= 10MB
|
|
||||||
#访问python服务的ip(对应环境)
|
|
||||||
#access.python.ip=http://43.198.80.117
|
|
||||||
access.python.ip=http://18.167.251.121
|
|
||||||
#access.python.ip=http://18.167.251.121:9991/
|
|
||||||
access.python.port=9992
|
|
||||||
access.python.sr=http://18.167.251.121:9994
|
|
||||||
|
|
||||||
minio.endpoint=https://www.minio.aida.com.hk:12024
|
|
||||||
minio.accessKey=admin
|
|
||||||
minio.secretKey=Aidlab123123!
|
|
||||||
minio.bucketName.clothing=aida-clothing
|
|
||||||
minio.bucketName.mannequins=aida-mannequins
|
|
||||||
minio.bucketName.results=aida-results
|
|
||||||
minio.bucketName.sysImage=aida-sys-image
|
|
||||||
minio.bucketName.users=aida-users
|
|
||||||
minio.bucketName.collectionElement=aida-collection-element
|
|
||||||
redirect_url=http://18.167.251.121:7788
|
|
||||||
|
|
||||||
spring.rabbitmq.host=18.167.251.121
|
|
||||||
spring.rabbitmq.port=5672
|
|
||||||
spring.rabbitmq.username=rabbit
|
|
||||||
spring.rabbitmq.password=123456
|
|
||||||
spring.rabbitmq.virtual-host=/
|
|
||||||
|
|
||||||
spring.redis.host=172.31.11.32
|
|
||||||
#spring.redis.host=18.167.251.121
|
|
||||||
spring.redis.port=6379
|
|
||||||
spring.redis.database=1
|
|
||||||
spring.redis.password=Aidlab
|
|
||||||
spring.redis.lettuce.pool.max-active=8
|
|
||||||
spring.redis.lettuce.pool.max-idle=8
|
|
||||||
spring.redis.lettuce.pool.min-idle=0
|
|
||||||
spring.redis.lettuce.pool.max-wait=5
|
|
||||||
|
|
||||||
redis.key.orderForGenerate=OrderForGenerate
|
|
||||||
redis.key.generateCancelSet=GenerateCancelSet
|
|
||||||
redis.key.generateExceptionMap=Generate:Exception
|
|
||||||
redis.key.resultMap=ResultMap
|
|
||||||
redis.key.orderForSR=OrderForSR
|
|
||||||
redis.key.SRCancelSet=SRCancelSet
|
|
||||||
redis.key.SRExceptionMap=SRExceptionMap
|
|
||||||
redis.key.taskList=TaskList
|
|
||||||
redis.key.credits.pre-deduction=Credits:PreDeduction
|
|
||||||
redis.key.generateResult=Generate:Result
|
|
||||||
|
|
||||||
aws.s3.accessKeyId=AKIAVD3OJIMF6UJFLSHZ
|
|
||||||
aws.s3.secretKey=LNIwFFB27/QedtZ+Q/viVUoX9F5x1DbuM8N0DkD8
|
|
||||||
aws.s3.regionName=ap-east-1
|
|
||||||
|
|
||||||
# RabbitMQ Exchange and Queue configurations
|
|
||||||
rabbitmq.queues.generate=generate-queue-test
|
|
||||||
rabbitmq.queues.sr=SR-queue-test
|
|
||||||
rabbitmq.queues.srResult=SuperResolution-test
|
|
||||||
rabbitmq.queues.generateResult=GenerateImage-test
|
|
||||||
rabbitmq.queues.toProductImageResult=ToProductImage-test
|
|
||||||
rabbitmq.queues.relightResult=Relight-test
|
|
||||||
rabbitmq.exchange.generate=generate-exchange
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#<23><><EFBFBD><EFBFBD>application-test<73>ļ<EFBFBD>(<28><><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>)
|
|
||||||
#spring.profiles.active=test
|
|
||||||
|
|
||||||
#<23><><EFBFBD><EFBFBD>application-prod<6F>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
|
||||||
#spring.profiles.active=prod
|
|
||||||
|
|
||||||
#<23><><EFBFBD><EFBFBD>application-dev<65>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
|
||||||
spring.profiles.active=dev
|
|
||||||
114
src/main/resources/application.yml
Normal file
114
src/main/resources/application.yml
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
# ============================================================
|
||||||
|
# aida-back - 本地配置(不区分环境)
|
||||||
|
# 公共配置(DB、Redis、RabbitMQ、MinIO、API Keys 等)由 Nacos 统一管理
|
||||||
|
# 此文件仅包含 back 服务私有的业务配置
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
server:
|
||||||
|
port: 10092
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: aida-back
|
||||||
|
|
||||||
|
|
||||||
|
# ---------- MinIO Buckets ----------
|
||||||
|
minio:
|
||||||
|
bucketName:
|
||||||
|
clothing: aida-clothing
|
||||||
|
mannequins: aida-mannequins
|
||||||
|
results: aida-results
|
||||||
|
sysImage: aida-sys-image
|
||||||
|
users: aida-users
|
||||||
|
collectionElement: aida-collection-element
|
||||||
|
gradient: aida-gradient
|
||||||
|
modifiedSketch: aida-modified-sketch
|
||||||
|
slogan: aida-slogan
|
||||||
|
partialDesign: aida-partial-design
|
||||||
|
globalAward: global-award
|
||||||
|
|
||||||
|
# ---------- Redis Keys ----------
|
||||||
|
redis:
|
||||||
|
key:
|
||||||
|
orderForGenerate: OrderForGenerate
|
||||||
|
generateCancelSet: GenerateCancelSet
|
||||||
|
generateExceptionMap: Generate:Exception
|
||||||
|
resultMap: ResultMap
|
||||||
|
orderForSR: OrderForSR
|
||||||
|
SRCancelSet: SRCancelSet
|
||||||
|
SRExceptionMap: SRExceptionMap
|
||||||
|
taskList: TaskList
|
||||||
|
credits:
|
||||||
|
pre-deduction: Credits:PreDeduction
|
||||||
|
generateResult: Generate:Result
|
||||||
|
toProductImageResultKey: ToProductImage:Result
|
||||||
|
relightResultKey: Relight:Result
|
||||||
|
newPosted: LastViewNewPostedTime
|
||||||
|
maximumUserId: CodeCreate:MaximumUserId
|
||||||
|
|
||||||
|
# ---------- RabbitMQ 队列 ----------
|
||||||
|
rabbitmq:
|
||||||
|
queues:
|
||||||
|
generate: generate-queue
|
||||||
|
sr: SR-queue
|
||||||
|
srResult: SuperResolution
|
||||||
|
generateResult: GenerateImage
|
||||||
|
toProductImageResult: ToProductImage
|
||||||
|
relightResult: Relight
|
||||||
|
poseTransform: PoseTransform
|
||||||
|
designBatch: DesignBatch
|
||||||
|
relightBatch: BatchRelight
|
||||||
|
toProductImageBatch: BatchToProductImage
|
||||||
|
poseTransformBatch: BatchPoseTransform
|
||||||
|
emailRetry: emailRetry-business
|
||||||
|
exchange:
|
||||||
|
generate: generate-exchange
|
||||||
|
dead-letter:
|
||||||
|
exchange: dlx.email-retry
|
||||||
|
queue: dlx.email-retry.queue
|
||||||
|
routing-key: dlx.email-retry.key
|
||||||
|
|
||||||
|
# ---------- 第三方服务 ----------
|
||||||
|
orderList:
|
||||||
|
link: https://develop.aida.com.hk/home/homePage?order=
|
||||||
|
|
||||||
|
stripe:
|
||||||
|
webhook:
|
||||||
|
fail:
|
||||||
|
reminder: 0
|
||||||
|
paymentMethodConfiguration: pmc_1QIKyq02n1TEydyNKVEYvhW7
|
||||||
|
|
||||||
|
google:
|
||||||
|
client:
|
||||||
|
id: 157095842121-kdd1fdf8m8nudvj9sprstb2k2prnf9e4.apps.googleusercontent.com
|
||||||
|
secret: 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
|
||||||
|
redirect:
|
||||||
|
uri: https://develop.api.aida.com.hk/api/third/party/auth/google_callback
|
||||||
|
|
||||||
|
redirect:
|
||||||
|
url: http://18.167.251.121:7788
|
||||||
|
|
||||||
|
global:
|
||||||
|
award:
|
||||||
|
link: https://aida-global-design-awards.com.hk/contestants?id=
|
||||||
|
|
||||||
|
# ---------- 文件上传 ----------
|
||||||
|
file:
|
||||||
|
upload:
|
||||||
|
temp:
|
||||||
|
dir: temp/uploads
|
||||||
|
chunk:
|
||||||
|
size:
|
||||||
|
pdf: 1048576
|
||||||
|
video: 2097152
|
||||||
|
max:
|
||||||
|
size:
|
||||||
|
pdf: 20971520
|
||||||
|
video: 104857600
|
||||||
|
task:
|
||||||
|
expiry:
|
||||||
|
hours: 24
|
||||||
|
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.aida: debug
|
||||||
34
src/main/resources/bootstrap.yml
Normal file
34
src/main/resources/bootstrap.yml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# ============================================================
|
||||||
|
# aida-back - Bootstrap
|
||||||
|
# 通过 NACOS_NAMESPACE 环境变量切换命名空间(dev / test / prod)
|
||||||
|
# 示例:docker run -e NACOS_NAMESPACE=prod ...
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
nacos:
|
||||||
|
namespace: dev
|
||||||
|
host: 18.167.251.121:28848
|
||||||
|
username: nacos
|
||||||
|
password: Aidlab123123!
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: aida-back
|
||||||
|
config:
|
||||||
|
import: optional:nacos:aida-public-${nacos.namespace}.yml
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
server-addr: ${nacos.host}
|
||||||
|
namespace: ${nacos.namespace}
|
||||||
|
username: ${nacos.username}
|
||||||
|
password: ${nacos.password}
|
||||||
|
# ip: 18.167.251.121
|
||||||
|
port: 10092
|
||||||
|
# ip-type: ipv4
|
||||||
|
# prefer-ip-address: true
|
||||||
|
config:
|
||||||
|
server-addr: ${nacos.host}
|
||||||
|
namespace: ${nacos.namespace}
|
||||||
|
file-extension: yaml
|
||||||
|
username: ${nacos.username}
|
||||||
|
password: ${nacos.password}
|
||||||
@@ -111,6 +111,7 @@ waistbandRight.cannot.be.empty=waistbandRight cannot be empty.
|
|||||||
handLeft.cannot.be.empty=handLeft cannot be empty.
|
handLeft.cannot.be.empty=handLeft cannot be empty.
|
||||||
handRight.cannot.be.empty=handRight cannot be empty.
|
handRight.cannot.be.empty=handRight cannot be empty.
|
||||||
id.cannot.be.empty=id cannot be empty.
|
id.cannot.be.empty=id cannot be empty.
|
||||||
|
url.cannot.be.empty=url cannot be empty.
|
||||||
type.cannot.be.empty=type cannot be empty.
|
type.cannot.be.empty=type cannot be empty.
|
||||||
color.cannot.be.empty=color cannot be empty.
|
color.cannot.be.empty=color cannot be empty.
|
||||||
generateDetailId.cannot.be.empty=generateDetailId cannot be empty.
|
generateDetailId.cannot.be.empty=generateDetailId cannot be empty.
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ waistbandRight.cannot.be.empty=waistbandRight不能为空。
|
|||||||
handLeft.cannot.be.empty=handLeft不能为空。
|
handLeft.cannot.be.empty=handLeft不能为空。
|
||||||
handRight.cannot.be.empty=handRight不能为空。
|
handRight.cannot.be.empty=handRight不能为空。
|
||||||
id.cannot.be.empty=id不能为空。
|
id.cannot.be.empty=id不能为空。
|
||||||
|
url.cannot.be.empty=url不能为空。
|
||||||
type.cannot.be.empty=type不能为空。
|
type.cannot.be.empty=type不能为空。
|
||||||
color.cannot.be.empty=color不能为空。
|
color.cannot.be.empty=color不能为空。
|
||||||
generateDetailId.cannot.be.empty=generateDetailId不能为空。
|
generateDetailId.cannot.be.empty=generateDetailId不能为空。
|
||||||
|
|||||||
Reference in New Issue
Block a user