Compare commits
104 Commits
dev/dev_sh
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ef60e00a05 | |||
| 7e7e6114a3 | |||
| b9be107fb3 | |||
| 08af386876 | |||
| 5f13d554d5 | |||
| f3fe41d334 | |||
| 7858fb1f15 | |||
| 3e4ccf47ba | |||
| d1c50cb92a | |||
| 26280f30c2 | |||
| 19a803578f | |||
| 934c212633 | |||
| 281d0423cc | |||
| 0a3081b3c9 | |||
| b4097162d8 | |||
| 7f7e3cc1ab | |||
| 7d7e214d11 | |||
| bbfc88d189 | |||
| ad35f22d79 | |||
| 93c34b3d2f | |||
| a112dc247f | |||
| ccd6446fe2 | |||
| f66e723b97 | |||
| 0778e51783 | |||
| 1fc3467828 | |||
| af2883edff | |||
| 000b20b066 | |||
| 56e430607d | |||
| 258d91de51 | |||
| 71ab0a9102 | |||
| 4884ac9ade | |||
| f1381dbda8 | |||
| 63ef05ac15 | |||
| f817517ab3 | |||
| 130768031b | |||
| cc14ee142c | |||
| 9fdc72c9ab | |||
| e6f94e595f | |||
| 6b43996f3f | |||
| 995dda476f | |||
| d0efd00e5e | |||
| d3dcb32139 | |||
|
|
8126eb7568 | ||
|
|
2aa6875385 | ||
|
|
e4e7875940 | ||
| c1b43dec32 | |||
| 2779d5f10e | |||
| a9485978b6 | |||
| 1212c21f9d | |||
| 9d43343cf2 | |||
| dbbf9631be | |||
| df1a3f47d9 | |||
| 7bc2b43ebe | |||
| 7e440afeaa | |||
| c90a727d80 | |||
| 2acfad086c | |||
| 8ab2413315 | |||
| 366a82f112 | |||
| 46744e3a29 | |||
| bea48f1aa9 | |||
| 3c79593ab0 | |||
| 278a09366b | |||
| d722d9c81d | |||
| b7e61cd9c8 | |||
| c07cbc958d | |||
| 70042e0fde | |||
| da790b3d11 | |||
| d01d476414 | |||
| 2a97d5fc79 | |||
| cc4a08feb3 | |||
| a51ee29fa0 | |||
| f172050162 | |||
| 4f410837d9 | |||
| 150929f721 | |||
| 2fd96d871c | |||
| 356b9fdfc6 | |||
| b1510a48ab | |||
| 188bf63104 | |||
| 1b8ab3a578 | |||
| 204105f525 | |||
| 069f0b894f | |||
| 0c15c7de69 | |||
| 69c9b23a95 | |||
| 5a84f3f1d4 | |||
| 7994e7d082 | |||
| fc7020c1d7 | |||
| 5d5dcff55a | |||
| 4eb5be2ba7 | |||
| 72a0171bfb | |||
| 1b9bcb2a27 | |||
| 291c83d596 | |||
| b45eed6191 | |||
| 2f84d3d765 | |||
| 3837546e7d | |||
| 4615792fce | |||
| 89843939b0 | |||
| f34f50db20 | |||
| 6496d88945 | |||
| 65703881da | |||
| 4ee5269b6f | |||
| c6a8375f67 | |||
| 598231f7c0 | |||
| 638d974932 | |||
| ec162bba0b |
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:5567'
|
||||||
|
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
|
||||||
174
.gitea/workflows/develop_build_manual.yaml
Normal file
174
.gitea/workflows/develop_build_manual.yaml
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
name: 手动 AiDA back-java 开发分支构建部署
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
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: /mnt/process/A6000_Server/AiDA_Workspace/Java_Server_workspace/Dev/
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
- name: 2.Set up JDK 21
|
||||||
|
uses: actions/setup-java@v5
|
||||||
|
with:
|
||||||
|
java-version: '21'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: 3.设置JAVA Maven 环境
|
||||||
|
run: |
|
||||||
|
# 适配root/普通用户
|
||||||
|
SUDO=""
|
||||||
|
[ "$(id -u)" != "0" ] && SUDO="sudo"
|
||||||
|
|
||||||
|
# 安装依赖
|
||||||
|
$SUDO apt update && $SUDO apt install -y wget tar --no-install-recommends
|
||||||
|
|
||||||
|
# 下载Maven
|
||||||
|
MAVEN_VERSION="3.9.11"
|
||||||
|
MAVEN_TAR="apache-maven-${MAVEN_VERSION}-bin.tar.gz"
|
||||||
|
MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/${MAVEN_TAR}"
|
||||||
|
wget --no-verbose -O /tmp/${MAVEN_TAR} ${MAVEN_URL}
|
||||||
|
|
||||||
|
# 解压+软链接
|
||||||
|
$SUDO tar -xzf /tmp/${MAVEN_TAR} -C /usr/local/
|
||||||
|
$SUDO ln -sf /usr/local/apache-maven-${MAVEN_VERSION} /usr/local/maven
|
||||||
|
|
||||||
|
# 配置PATH
|
||||||
|
echo "/usr/local/maven/bin" >> $GITHUB_PATH
|
||||||
|
export PATH="/usr/local/maven/bin:$PATH"
|
||||||
|
|
||||||
|
# 验证
|
||||||
|
mvn -v
|
||||||
|
|
||||||
|
- name: 4.构建jar包
|
||||||
|
run: |
|
||||||
|
echo "===== 开始构建JAR包 ====="
|
||||||
|
# 新增:打印当前构建分支(两种方式双重确认)
|
||||||
|
echo "当前工作目录分支:$(git branch --show-current)"
|
||||||
|
echo "Gitea检出分支:${{ github.ref_name }}"
|
||||||
|
echo "预期构建分支:dev/3.1_release_merge"
|
||||||
|
echo "========================"
|
||||||
|
mvn -B clean install -DskipTests -Pdev 2>&1
|
||||||
|
# 检查构建是否成功
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "JAR包构建失败!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- 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 ./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-version-aida-back
|
||||||
|
build: .
|
||||||
|
volumes:
|
||||||
|
# 数据挂载
|
||||||
|
- ./log:/log
|
||||||
|
ports:
|
||||||
|
- '10090:5567'
|
||||||
|
restart: always
|
||||||
|
EOF
|
||||||
|
# 验证docker-compose.yml生成
|
||||||
|
echo "docker-compose.yml内容:"
|
||||||
|
cat docker-compose.yml
|
||||||
|
|
||||||
|
- name: 7.安装SSH工具
|
||||||
|
run: |
|
||||||
|
$SUDO apt install -y sshpass openssh-client --no-install-recommends
|
||||||
|
# 配置SSH免密
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
ssh-keyscan -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: 8.同步文件到远程服务器
|
||||||
|
run: |
|
||||||
|
echo "===== 同步文件到远程服务器 ====="
|
||||||
|
# 使用scp同步文件
|
||||||
|
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||||
|
./target/*.jar ./Dockerfile ./docker-compose.yml \
|
||||||
|
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:${{ env.REMOTE_DEPLOY_PATH }} 2>&1
|
||||||
|
|
||||||
|
- name: 9.部署和运行服务
|
||||||
|
run: |
|
||||||
|
echo "===== 开始部署服务 ====="
|
||||||
|
# SSH执行部署命令
|
||||||
|
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||||
|
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} << 'EOF_SSH'
|
||||||
|
cd ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
echo "停止旧容器..."
|
||||||
|
docker compose down || true
|
||||||
|
echo "清理Docker资源..."
|
||||||
|
docker system prune -f
|
||||||
|
echo "构建镜像..."
|
||||||
|
docker compose build --no-cache
|
||||||
|
echo "启动服务..."
|
||||||
|
docker compose up -d
|
||||||
|
echo "验证容器状态..."
|
||||||
|
docker compose ps
|
||||||
|
echo "部署完成!"
|
||||||
|
EOF_SSH
|
||||||
|
|
||||||
|
- name: 10.发送构建结果邮件
|
||||||
|
if: always() # 无论上一步是否失败,都执行此步骤
|
||||||
|
uses: dawidd6/action-send-mail@v3
|
||||||
|
with:
|
||||||
|
|
||||||
|
from: ${{ secrets.MAIL_USERNAME }}
|
||||||
|
# --- 邮件配置 ---
|
||||||
|
server_address: smtp.gmail.com # 替换为你的SMTP服务器地址
|
||||||
|
server_port: 465 # 替换为你的SMTP端口 (通常是465或587)
|
||||||
|
username: ${{ secrets.MAIL_USERNAME }} # 存储在Secrets中的邮箱用户名
|
||||||
|
password: ${{ secrets.MAIL_PASSWORD }} # 存储在Secrets中的邮箱密码
|
||||||
|
subject: 'Gitea Actions 构建通知: ${{ job.status }} - AiDA back-java Develop'
|
||||||
|
# 收件人列表,可以根据需要更改
|
||||||
|
to: 'cgzhou@aidlab.hk,zchengrong@yeah.net' # 替换为实际收件人邮箱
|
||||||
|
|
||||||
|
# --- 邮件正文内容 ---
|
||||||
|
body: |
|
||||||
|
项目: AiDA back-java Develop
|
||||||
|
分支: dev/3.1_release_merge
|
||||||
|
|
||||||
|
🎉 构建结果: ${{ job.status }}
|
||||||
|
|
||||||
|
📅 构建时间: ${{ steps.build_start_time.outputs.current_time }}
|
||||||
|
|
||||||
|
🔗 构建链接: ${{ gitea.server_url }}/${{ gitea.repository.owner.name }}/${{ gitea.repository.name }}/actions/runs/${{ gitea.run_id }}
|
||||||
|
|
||||||
|
# 确保邮件内容为纯文本,或者你可以设置为 html: true 并调整 body
|
||||||
|
content_type: text/plain
|
||||||
174
.gitea/workflows/prod_build_manual.yaml
Normal file
174
.gitea/workflows/prod_build_manual.yaml
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
name: 手动 AiDA back-java 生产分支构建部署
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
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/ProdVersion/prod-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: release/3.1
|
||||||
|
|
||||||
|
- name: 2.Set up JDK 21
|
||||||
|
uses: actions/setup-java@v5
|
||||||
|
with:
|
||||||
|
java-version: '21'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: 3.设置JAVA Maven 环境
|
||||||
|
run: |
|
||||||
|
# 适配root/普通用户
|
||||||
|
SUDO=""
|
||||||
|
[ "$(id -u)" != "0" ] && SUDO="sudo"
|
||||||
|
|
||||||
|
# 安装依赖
|
||||||
|
$SUDO apt update && $SUDO apt install -y wget tar --no-install-recommends
|
||||||
|
|
||||||
|
# 下载Maven
|
||||||
|
MAVEN_VERSION="3.9.11"
|
||||||
|
MAVEN_TAR="apache-maven-${MAVEN_VERSION}-bin.tar.gz"
|
||||||
|
MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/${MAVEN_TAR}"
|
||||||
|
wget --no-verbose -O /tmp/${MAVEN_TAR} ${MAVEN_URL}
|
||||||
|
|
||||||
|
# 解压+软链接
|
||||||
|
$SUDO tar -xzf /tmp/${MAVEN_TAR} -C /usr/local/
|
||||||
|
$SUDO ln -sf /usr/local/apache-maven-${MAVEN_VERSION} /usr/local/maven
|
||||||
|
|
||||||
|
# 配置PATH
|
||||||
|
echo "/usr/local/maven/bin" >> $GITHUB_PATH
|
||||||
|
export PATH="/usr/local/maven/bin:$PATH"
|
||||||
|
|
||||||
|
# 验证
|
||||||
|
mvn -v
|
||||||
|
|
||||||
|
- name: 4.构建jar包
|
||||||
|
run: |
|
||||||
|
echo "===== 开始构建JAR包 ====="
|
||||||
|
# 新增:打印当前构建分支(两种方式双重确认)
|
||||||
|
echo "当前工作目录分支:$(git branch --show-current)"
|
||||||
|
echo "Gitea检出分支:${{ github.ref_name }}"
|
||||||
|
echo "预期构建分支:dev/3.1_release_merge"
|
||||||
|
echo "========================"
|
||||||
|
mvn -B clean install -DskipTests -Pdev 2>&1
|
||||||
|
# 检查构建是否成功
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "JAR包构建失败!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- 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 ./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: prod-version-aida-back
|
||||||
|
build: .
|
||||||
|
volumes:
|
||||||
|
# 数据挂载
|
||||||
|
- ./log:/log
|
||||||
|
- ./temp:/temp
|
||||||
|
- ./uploads:/temp/uploads
|
||||||
|
ports:
|
||||||
|
- '10010:5567'
|
||||||
|
restart: always
|
||||||
|
EOF
|
||||||
|
# 验证docker-compose.yml生成
|
||||||
|
echo "docker-compose.yml内容:"
|
||||||
|
cat docker-compose.yml
|
||||||
|
|
||||||
|
- name: 7.安装SSH工具
|
||||||
|
run: |
|
||||||
|
$SUDO apt install -y sshpass openssh-client --no-install-recommends
|
||||||
|
# 配置SSH免密
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
ssh-keyscan -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: 8.同步文件到远程服务器
|
||||||
|
run: |
|
||||||
|
echo "===== 同步文件到远程服务器 ====="
|
||||||
|
# 使用scp同步文件
|
||||||
|
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||||
|
./target/*.jar ./Dockerfile ./docker-compose.yml \
|
||||||
|
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:${{ env.REMOTE_DEPLOY_PATH }} 2>&1
|
||||||
|
|
||||||
|
- name: 9.部署和运行服务
|
||||||
|
run: |
|
||||||
|
echo "===== 开始部署服务 ====="
|
||||||
|
# SSH执行部署命令
|
||||||
|
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||||
|
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} << 'EOF_SSH'
|
||||||
|
cd ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
echo "停止旧容器..."
|
||||||
|
docker compose down || true
|
||||||
|
echo "构建镜像..."
|
||||||
|
docker compose build --no-cache
|
||||||
|
echo "启动服务..."
|
||||||
|
docker compose up -d
|
||||||
|
echo "验证容器状态..."
|
||||||
|
docker compose ps
|
||||||
|
echo "部署完成!"
|
||||||
|
EOF_SSH
|
||||||
|
|
||||||
|
- name: 10.发送构建结果邮件
|
||||||
|
if: always() # 无论上一步是否失败,都执行此步骤
|
||||||
|
uses: dawidd6/action-send-mail@v3
|
||||||
|
with:
|
||||||
|
|
||||||
|
from: ${{ secrets.MAIL_USERNAME }}
|
||||||
|
# --- 邮件配置 ---
|
||||||
|
server_address: smtp.gmail.com # 替换为你的SMTP服务器地址
|
||||||
|
server_port: 465 # 替换为你的SMTP端口 (通常是465或587)
|
||||||
|
username: ${{ secrets.MAIL_USERNAME }} # 存储在Secrets中的邮箱用户名
|
||||||
|
password: ${{ secrets.MAIL_PASSWORD }} # 存储在Secrets中的邮箱密码
|
||||||
|
subject: 'Gitea Actions 构建通知: ${{ job.status }} - AiDA back-java Develop'
|
||||||
|
# 收件人列表,可以根据需要更改
|
||||||
|
to: 'xupei3360@163.com,txli@aidlab.hk,cgzhou@aidlab.hk,zchengrong@yeah.net' # 替换为实际收件人邮箱
|
||||||
|
|
||||||
|
# --- 邮件正文内容 ---
|
||||||
|
body: |
|
||||||
|
项目: AiDA back-java Prod
|
||||||
|
分支: release/3.1
|
||||||
|
|
||||||
|
🎉 构建结果: ${{ job.status }}
|
||||||
|
|
||||||
|
📅 构建时间: ${{ steps.build_start_time.outputs.current_time }}
|
||||||
|
|
||||||
|
🔗 构建链接: ${{ gitea.server_url }}/${{ gitea.repository.owner.name }}/${{ gitea.repository.name }}/actions/runs/${{ gitea.run_id }}
|
||||||
|
|
||||||
|
# 确保邮件内容为纯文本,或者你可以设置为 html: true 并调整 body
|
||||||
|
content_type: text/plain
|
||||||
177
.gitea/workflows/prod_build_schedule.yaml
Normal file
177
.gitea/workflows/prod_build_schedule.yaml
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
name: 定时 AiDA back-java 生产分支构建部署
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# cron为UTC时区,构建时间=部署时间-8小时 {*分 (-8)时 *日 *月 *周} ---
|
||||||
|
# 示例: 1月1日22点22分触发构建 cron写作 - '22 14 1 1 *'
|
||||||
|
- cron: '00 14 13 3 *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
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/ProdVersion/prod-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: release/3.1
|
||||||
|
|
||||||
|
- name: 2.Set up JDK 21
|
||||||
|
uses: actions/setup-java@v5
|
||||||
|
with:
|
||||||
|
java-version: '21'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: 3.设置JAVA Maven 环境
|
||||||
|
run: |
|
||||||
|
# 适配root/普通用户
|
||||||
|
SUDO=""
|
||||||
|
[ "$(id -u)" != "0" ] && SUDO="sudo"
|
||||||
|
|
||||||
|
# 安装依赖
|
||||||
|
$SUDO apt update && $SUDO apt install -y wget tar --no-install-recommends
|
||||||
|
|
||||||
|
# 下载Maven
|
||||||
|
MAVEN_VERSION="3.9.11"
|
||||||
|
MAVEN_TAR="apache-maven-${MAVEN_VERSION}-bin.tar.gz"
|
||||||
|
MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/${MAVEN_TAR}"
|
||||||
|
wget --no-verbose -O /tmp/${MAVEN_TAR} ${MAVEN_URL}
|
||||||
|
|
||||||
|
# 解压+软链接
|
||||||
|
$SUDO tar -xzf /tmp/${MAVEN_TAR} -C /usr/local/
|
||||||
|
$SUDO ln -sf /usr/local/apache-maven-${MAVEN_VERSION} /usr/local/maven
|
||||||
|
|
||||||
|
# 配置PATH
|
||||||
|
echo "/usr/local/maven/bin" >> $GITHUB_PATH
|
||||||
|
export PATH="/usr/local/maven/bin:$PATH"
|
||||||
|
|
||||||
|
# 验证
|
||||||
|
mvn -v
|
||||||
|
|
||||||
|
- name: 4.构建jar包
|
||||||
|
run: |
|
||||||
|
echo "===== 开始构建JAR包 ====="
|
||||||
|
# 新增:打印当前构建分支(两种方式双重确认)
|
||||||
|
echo "当前工作目录分支:$(git branch --show-current)"
|
||||||
|
echo "Gitea检出分支:${{ github.ref_name }}"
|
||||||
|
echo "预期构建分支:dev/3.1_release_merge"
|
||||||
|
echo "========================"
|
||||||
|
mvn -B clean install -DskipTests -Pdev 2>&1
|
||||||
|
# 检查构建是否成功
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "JAR包构建失败!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- 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 ./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: prod-version-aida-back
|
||||||
|
build: .
|
||||||
|
volumes:
|
||||||
|
# 数据挂载
|
||||||
|
- ./log:/log
|
||||||
|
ports:
|
||||||
|
- '10010:5567'
|
||||||
|
restart: always
|
||||||
|
EOF
|
||||||
|
# 验证docker-compose.yml生成
|
||||||
|
echo "docker-compose.yml内容:"
|
||||||
|
cat docker-compose.yml
|
||||||
|
|
||||||
|
- name: 7.安装SSH工具
|
||||||
|
run: |
|
||||||
|
$SUDO apt install -y sshpass openssh-client --no-install-recommends
|
||||||
|
# 配置SSH免密
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
ssh-keyscan -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: 8.同步文件到远程服务器
|
||||||
|
run: |
|
||||||
|
echo "===== 同步文件到远程服务器 ====="
|
||||||
|
# 使用scp同步文件
|
||||||
|
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||||
|
./target/*.jar ./Dockerfile ./docker-compose.yml \
|
||||||
|
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:${{ env.REMOTE_DEPLOY_PATH }} 2>&1
|
||||||
|
|
||||||
|
- name: 9.部署和运行服务
|
||||||
|
run: |
|
||||||
|
echo "===== 开始部署服务 ====="
|
||||||
|
# SSH执行部署命令
|
||||||
|
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||||
|
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} << 'EOF_SSH'
|
||||||
|
cd ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
echo "停止旧容器..."
|
||||||
|
docker compose down || true
|
||||||
|
echo "清理Docker资源..."
|
||||||
|
docker system prune -f
|
||||||
|
echo "构建镜像..."
|
||||||
|
docker compose build --no-cache
|
||||||
|
echo "启动服务..."
|
||||||
|
docker compose up -d
|
||||||
|
echo "验证容器状态..."
|
||||||
|
docker compose ps
|
||||||
|
echo "部署完成!"
|
||||||
|
EOF_SSH
|
||||||
|
|
||||||
|
- name: 10.发送构建结果邮件
|
||||||
|
if: always() # 无论上一步是否失败,都执行此步骤
|
||||||
|
uses: dawidd6/action-send-mail@v3
|
||||||
|
with:
|
||||||
|
|
||||||
|
from: ${{ secrets.MAIL_USERNAME }}
|
||||||
|
# --- 邮件配置 ---
|
||||||
|
server_address: smtp.gmail.com # 替换为你的SMTP服务器地址
|
||||||
|
server_port: 465 # 替换为你的SMTP端口 (通常是465或587)
|
||||||
|
username: ${{ secrets.MAIL_USERNAME }} # 存储在Secrets中的邮箱用户名
|
||||||
|
password: ${{ secrets.MAIL_PASSWORD }} # 存储在Secrets中的邮箱密码
|
||||||
|
subject: 'Gitea Actions 构建通知: ${{ job.status }} - AiDA back-java Develop'
|
||||||
|
# 收件人列表,可以根据需要更改
|
||||||
|
to: 'xupei3360@163.com,txli@aidlab.hk,cgzhou@aidlab.hk,zchengrong@yeah.net' # 替换为实际收件人邮箱
|
||||||
|
|
||||||
|
# --- 邮件正文内容 ---
|
||||||
|
body: |
|
||||||
|
项目: AiDA back-java Prod
|
||||||
|
分支: release/3.1
|
||||||
|
|
||||||
|
🎉 构建结果: ${{ job.status }}
|
||||||
|
|
||||||
|
📅 构建时间: ${{ steps.build_start_time.outputs.current_time }}
|
||||||
|
|
||||||
|
🔗 构建链接: ${{ gitea.server_url }}/${{ gitea.repository.owner.name }}/${{ gitea.repository.name }}/actions/runs/${{ gitea.run_id }}
|
||||||
|
|
||||||
|
# 确保邮件内容为纯文本,或者你可以设置为 html: true 并调整 body
|
||||||
|
content_type: text/plain
|
||||||
176
.gitea/workflows/research_build_manual.yaml
Normal file
176
.gitea/workflows/research_build_manual.yaml
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
name: 手动 AiDA back-java 开发分支构建部署
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
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: /mnt/process/A6000_Server/AiDA_Workspace/Java_Server_workspace/Dev/
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
- name: 2.Set up JDK 21
|
||||||
|
uses: actions/setup-java@v5
|
||||||
|
with:
|
||||||
|
java-version: '21'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: 3.设置JAVA Maven 环境
|
||||||
|
run: |
|
||||||
|
# 适配root/普通用户
|
||||||
|
SUDO=""
|
||||||
|
[ "$(id -u)" != "0" ] && SUDO="sudo"
|
||||||
|
|
||||||
|
# 安装依赖
|
||||||
|
$SUDO apt update && $SUDO apt install -y wget tar --no-install-recommends
|
||||||
|
|
||||||
|
# 下载Maven
|
||||||
|
MAVEN_VERSION="3.9.11"
|
||||||
|
MAVEN_TAR="apache-maven-${MAVEN_VERSION}-bin.tar.gz"
|
||||||
|
MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/${MAVEN_TAR}"
|
||||||
|
wget --no-verbose -O /tmp/${MAVEN_TAR} ${MAVEN_URL}
|
||||||
|
|
||||||
|
# 解压+软链接
|
||||||
|
$SUDO tar -xzf /tmp/${MAVEN_TAR} -C /usr/local/
|
||||||
|
$SUDO ln -sf /usr/local/apache-maven-${MAVEN_VERSION} /usr/local/maven
|
||||||
|
|
||||||
|
# 配置PATH
|
||||||
|
echo "/usr/local/maven/bin" >> $GITHUB_PATH
|
||||||
|
export PATH="/usr/local/maven/bin:$PATH"
|
||||||
|
|
||||||
|
# 验证
|
||||||
|
mvn -v
|
||||||
|
|
||||||
|
- name: 4.构建jar包
|
||||||
|
run: |
|
||||||
|
echo "===== 开始构建JAR包 ====="
|
||||||
|
# 新增:打印当前构建分支(两种方式双重确认)
|
||||||
|
echo "当前工作目录分支:$(git branch --show-current)"
|
||||||
|
echo "Gitea检出分支:${{ github.ref_name }}"
|
||||||
|
echo "预期构建分支:dev/3.1_release_merge"
|
||||||
|
echo "========================"
|
||||||
|
mvn -B clean install -DskipTests -Pdev 2>&1
|
||||||
|
# 检查构建是否成功
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "JAR包构建失败!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- 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 ./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-version-aida-back
|
||||||
|
build: .
|
||||||
|
volumes:
|
||||||
|
# 数据挂载
|
||||||
|
- ./log:/log
|
||||||
|
ports:
|
||||||
|
- '1608:5567'
|
||||||
|
restart: always
|
||||||
|
EOF
|
||||||
|
# 验证docker-compose.yml生成
|
||||||
|
echo "docker-compose.yml内容:"
|
||||||
|
cat docker-compose.yml
|
||||||
|
|
||||||
|
|
||||||
|
- name: 7.安装SSH工具
|
||||||
|
run: |
|
||||||
|
$SUDO apt install -y sshpass openssh-client --no-install-recommends
|
||||||
|
# 配置SSH免密
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.SEARCH_SSH_KEY }}" > ~/.ssh/id_rsa
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
ssh-keyscan -H ${{ secrets.SEARCH_SERVER_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: 8.同步文件到远程服务器
|
||||||
|
run: |
|
||||||
|
echo "===== 同步文件到远程服务器 ====="
|
||||||
|
# 使用scp同步文件
|
||||||
|
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||||
|
./target/*.jar ./Dockerfile ./docker-compose.yml \
|
||||||
|
${{ secrets.SEARCH_SERVER_USER }}@${{ secrets.SEARCH_SERVER_HOST }}:${{ env.REMOTE_DEPLOY_PATH }} 2>&1
|
||||||
|
|
||||||
|
|
||||||
|
- name: 9.部署和运行服务
|
||||||
|
run: |
|
||||||
|
echo "===== 开始部署服务 ====="
|
||||||
|
# SSH执行部署命令
|
||||||
|
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||||
|
${{ secrets.SEARCH_SERVER_USER }}@${{ secrets.SEARCH_SERVER_HOST }} << 'EOF_SSH'
|
||||||
|
cd ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
echo "停止旧容器..."
|
||||||
|
docker compose down || true
|
||||||
|
echo "清理Docker资源..."
|
||||||
|
docker system prune -f
|
||||||
|
echo "构建镜像..."
|
||||||
|
docker compose build --no-cache
|
||||||
|
echo "启动服务..."
|
||||||
|
docker compose up -d
|
||||||
|
echo "验证容器状态..."
|
||||||
|
docker compose ps
|
||||||
|
echo "部署完成!"
|
||||||
|
EOF_SSH
|
||||||
|
|
||||||
|
- name: 10.发送构建结果邮件
|
||||||
|
if: always() # 无论上一步是否失败,都执行此步骤
|
||||||
|
uses: dawidd6/action-send-mail@v3
|
||||||
|
with:
|
||||||
|
|
||||||
|
from: ${{ secrets.MAIL_USERNAME }}
|
||||||
|
# --- 邮件配置 ---
|
||||||
|
server_address: smtp.gmail.com # 替换为你的SMTP服务器地址
|
||||||
|
server_port: 465 # 替换为你的SMTP端口 (通常是465或587)
|
||||||
|
username: ${{ secrets.MAIL_USERNAME }} # 存储在Secrets中的邮箱用户名
|
||||||
|
password: ${{ secrets.MAIL_PASSWORD }} # 存储在Secrets中的邮箱密码
|
||||||
|
subject: 'Gitea Actions 构建通知: ${{ job.status }} - AiDA back-java Develop'
|
||||||
|
# 收件人列表,可以根据需要更改
|
||||||
|
to: 'cgzhou@aidlab.hk,zchengrong@yeah.net' # 替换为实际收件人邮箱
|
||||||
|
|
||||||
|
# --- 邮件正文内容 ---
|
||||||
|
body: |
|
||||||
|
项目: AiDA back-java Develop
|
||||||
|
分支: dev/3.1_release_merge
|
||||||
|
|
||||||
|
🎉 构建结果: ${{ job.status }}
|
||||||
|
|
||||||
|
📅 构建时间: ${{ steps.build_start_time.outputs.current_time }}
|
||||||
|
|
||||||
|
🔗 构建链接: ${{ gitea.server_url }}/${{ gitea.repository.owner.name }}/${{ gitea.repository.name }}/actions/runs/${{ gitea.run_id }}
|
||||||
|
|
||||||
|
# 确保邮件内容为纯文本,或者你可以设置为 html: true 并调整 body
|
||||||
|
content_type: text/plain
|
||||||
48
.gitignore
vendored
48
.gitignore
vendored
@@ -1,50 +1,2 @@
|
|||||||
sql/*.sql
|
sql/*.sql
|
||||||
|
|
||||||
HELP.md
|
|
||||||
target/
|
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
|
||||||
!**/src/main/**
|
|
||||||
!**/src/test/**
|
|
||||||
|
|
||||||
### STS ###
|
|
||||||
.apt_generated
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
.sts4-cache
|
|
||||||
.log
|
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
|
||||||
.idea
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
.mvn
|
|
||||||
mvnw*
|
|
||||||
|
|
||||||
### NetBeans ###
|
|
||||||
/nbproject/private/
|
|
||||||
/nbbuild/
|
|
||||||
/dist/
|
|
||||||
/nbdist/
|
|
||||||
/.nb-gradle/
|
|
||||||
build/
|
|
||||||
|
|
||||||
### VS Code ###
|
|
||||||
.vscode/
|
|
||||||
|
|
||||||
### generated files ###
|
|
||||||
bin/
|
|
||||||
gen/
|
|
||||||
|
|
||||||
### MAC ###
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
### Other ###
|
|
||||||
logs/
|
|
||||||
log
|
|
||||||
temp/
|
|
||||||
|
|
||||||
docker-compose.yml
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
FROM openjdk:8
|
|
||||||
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"]
|
|
||||||
@@ -1,3 +1,2 @@
|
|||||||
# Aida 1.2
|
# Aida 1.2
|
||||||
Version of aida 1.3
|
Version of aida 1.2
|
||||||
修改预先登录接口、逻辑
|
|
||||||
|
|||||||
186
aida.iml
186
aida.iml
@@ -1,8 +1,192 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module version="4">
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
<component name="FacetManager">
|
<component name="FacetManager">
|
||||||
<facet type="Spring" name="Spring">
|
<facet type="Spring" name="Spring">
|
||||||
<configuration />
|
<configuration />
|
||||||
</facet>
|
</facet>
|
||||||
|
<facet type="web" name="Web">
|
||||||
|
<configuration>
|
||||||
|
<webroots />
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||||
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.12.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.12.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.29" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.29" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.29" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.10" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.29" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:2.3.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: jakarta.activation:jakarta.activation-api:1.2.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.5.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.5.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.5.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.5.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.5.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.junit.vintage:junit-vintage-engine:5.5.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.5.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:3.1.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.13.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.1.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.10.4" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.4" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.6.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-redis:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:2.2.3.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:2.2.3.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.2.3.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-oxm:5.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.lettuce:lettuce-core:5.2.1.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.43.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.43.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.43.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.43.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.43.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.43.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.3.1.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-configuration-processor:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-security:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-config:5.2.1.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-core:5.2.1.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-web:5.2.1.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-jwt:1.1.1.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.64" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.64" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.18" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.5.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus:3.5.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.5.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.5.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.5.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:4.4" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.10" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.7" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.3.61" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-common:1.3.61" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains:annotations:13.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.4.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.2.2.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.29" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.1.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.8.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.alibaba:fastjson:2.0.6.graal" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.alibaba.fastjson2:fastjson2-extension:2.0.6.graal" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.alibaba.fastjson2:fastjson2:2.0.6.graal" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.jsonwebtoken:jjwt:0.9.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.14.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.17.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.4.0-b180830.0359" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:4.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-core:4.0.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: org.eclipse.angus:angus-activation:1.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: javax.activation:activation:1.1.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.github.whvcse:easy-captcha:1.6.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.guava:guava:31.1-jre" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:3.12.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.11.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-boot-starter:3.0.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-boot-autoconfigure:3.0.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring:3.0.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-annotations:3.0.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.22" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.swagger.core.v3:swagger-annotations:2.1.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-core:3.0.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.javassist:javassist:3.25.0-GA" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.github.classgraph:classgraph:4.8.83" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-webflux:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: org.mapstruct:mapstruct:1.3.1.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-webmvc:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-core:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-oas:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.swagger.core.v3:swagger-models:2.1.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-bean-validators:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.22" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.swagger:swagger-core:1.5.22" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.9" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.10.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-boot-starter:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-data-rest:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:2.0.0.RELEASE" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-ui:3.0.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.tencentcloudapi:tencentcloud-sdk-java-ses:3.1.572" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.tencentcloudapi:tencentcloud-sdk-java-common:3.1.572" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.squareup.okhttp:okhttp:2.7.5" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.squareup.okhttp:logging-interceptor:2.7.5" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.ini4j:ini4j:0.5.4" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
-----BEGIN PUBLIC KEY-----
|
|
||||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAymkBAWixxUi9IAeMWgsq
|
|
||||||
K92AzFbe0qzzYPdkoh15ymL2A5MkYH7asnhFwclgdiFmd9a0TbZP+t/SzWW8UUzN
|
|
||||||
1pXoEp48R+eguGTt5xkJwb10+H6quVXF/Ezzid5yzVW3dcYRp8qUlFr0XBpvkK9l
|
|
||||||
FpPzh2+mwVEAsgBMXq/K50ZiX2dlkPZ7ffkVPWaK2ESIo3YgfM6dmiiza0hPWJ35
|
|
||||||
UgTH5rwJ7vN3IdOJTlkQOvrIrj2ocPcrudeEwqybIbCGhgRBwQSBsXQOO4U//rE4
|
|
||||||
VU+0LF/3uQgXkvVY1+a1JLiTncZYKGEQ/NtxM+dGtYWV2gPhQRyJ7Z77OX0XCbcn
|
|
||||||
zwIDAQAB
|
|
||||||
-----END PUBLIC KEY-----
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
-----BEGIN PRIVATE KEY-----
|
|
||||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDD+NUduhLJcb2Z
|
|
||||||
ryLwtIHdmjfh6Wn73E9umHmdPf6yF7IbDoTDBmIAfaPU/oiLgrka3fKGCkn/yHvW
|
|
||||||
QcL+Ry96/Uu+iIN9SbG5vPVvLtLfx+5++IE8p3RxcSDQggqFuJ+osebXeVIrOcTZ
|
|
||||||
s7nXCqGenTcagv2eJESiq712fcBvY1wVgilT6ERVQy+zdvwAOiS6wXF/51AueP+E
|
|
||||||
rNDHuPLkGH6JhLtO4LffeYgM/Th7eCl/WWLkiVMSoeJt7vWFe4bYV/IYW1qI2aQX
|
|
||||||
H1DYmvwgDfDv8jRORD9D191YBqq1l3Tw7VSjFrpydFvSK46dbXKBj3oA5ZiJ+Ttj
|
|
||||||
ZCtBRiOdAgMBAAECggEAUKl4Fs9C8lV1o+85Y3f4yBy1CbCIZhltPGlYDUe6MNWe
|
|
||||||
ApL8REW5Sthr+bx2uW2qAQv/yfosMTL0/eB9gSoNugLODXOlI4mUtI25O/U66M8j
|
|
||||||
NHHWx/9o51SYHBqaeCXg2Y+4I1KVZqNVigH26TNACMhPKQNnnpLxCT/FMSNbdLzo
|
|
||||||
wfFMyjN7R3Hc8ZB1C2zx+fLJm1DNZeOJOHAkW1LprlotRv6eq3lOwZaDDUTB5xhT
|
|
||||||
0Erev3djC/R08Fne1y09ukar8z0tX3Fm9SzHJDFVoh1HOYPWayCiAxOhip+JnFct
|
|
||||||
rtK5jjuB8DAP4Q1k12yOWUFwb6NOG9Hf/G6XExRPBQKBgQD1P2SnKD1IlNSrvVJn
|
|
||||||
2HzKnBVllVo50fbv7SpnP8H1B5vt2Qo/mgOGtzbeXyK4mcLFaWg9++BrsjTXwZFi
|
|
||||||
wmKeJgNI822DPhF5qQhK7Cc+WMwesufGrTnmRUOEFYehz9ffZBvMa1s/ObIEyLcr
|
|
||||||
tYitT74+nFdRPtr+8PN06QMEcwKBgQDMkGFWhSO7p7VMuV0H0uC1fj3GGtVvM+Ps
|
|
||||||
a9ASs0HBhQaOpberkKY9vgry6HoJ8CGvbrxlmc3JoYPRwKN3oQRYLvGSF96HAg9i
|
|
||||||
643FmVAWiVzHpjYX9fMJyCzXiOw6Qet8Zp3Ewaw9BBG0200Fj6/zGc8XEqNjIv5Q
|
|
||||||
DQ9MosRDrwKBgQCU5i5IRugeXy5YLxQPNKNfqDBdgrZLEK2qsgXithUencYQPIw6
|
|
||||||
XVnyut43WO+NwN0+WmcN6xUwjfwDWuTYX0jc2Bt6eUFuQ4r8oKIGSybwdZ1IrjqG
|
|
||||||
p7nVkwwQ77lvhu98FB3EmRHHa1IoEW0Uvp0DDL1m6ikhjNYNn2FRA//u/QKBgGbY
|
|
||||||
a+eo1ldBMPha9Te6wLjeuEYCNa5L41p4tcrBDt0xeSN8k4QRHFNMWYrYcIrQjM77
|
|
||||||
mIJoOjsWFgT9mfHKJToEl/VAROORmJS+Iq/mrYo3E0tY+DdBsygG2Oyf7Uw42iDY
|
|
||||||
IpfKW0Lt6c0IuIeEPwy0vBY4i6aK8Frkxf1ck9oHAoGBAKFQg/c36J6tjnttpmes
|
|
||||||
R/zijp1ROE+z+dMmm3icDhCDvvR6MnHa2Y9ittNWdEUosZk9FsFn62YNtJJV2SIN
|
|
||||||
DDn0ASLtBkeCd8yad5uzUb7Umci9V7TP5c0NE3DK95FmciLGOuRbFyq1Z8edHnaS
|
|
||||||
zgLnf4yb25eCMLEG0Z2ugN3C
|
|
||||||
-----END PRIVATE KEY-----
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
-----BEGIN PUBLIC KEY-----
|
|
||||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw/jVHboSyXG9ma8i8LSB
|
|
||||||
3Zo34elp+9xPbph5nT3+sheyGw6EwwZiAH2j1P6Ii4K5Gt3yhgpJ/8h71kHC/kcv
|
|
||||||
ev1LvoiDfUmxubz1by7S38fufviBPKd0cXEg0IIKhbifqLHm13lSKznE2bO51wqh
|
|
||||||
np03GoL9niREoqu9dn3Ab2NcFYIpU+hEVUMvs3b8ADokusFxf+dQLnj/hKzQx7jy
|
|
||||||
5Bh+iYS7TuC333mIDP04e3gpf1li5IlTEqHibe71hXuG2FfyGFtaiNmkFx9Q2Jr8
|
|
||||||
IA3w7/I0TkQ/Q9fdWAaqtZd08O1Uoxa6cnRb0iuOnW1ygY96AOWYifk7Y2QrQUYj
|
|
||||||
nQIDAQAB
|
|
||||||
-----END PUBLIC KEY-----
|
|
||||||
198
pom.xml
198
pom.xml
@@ -28,19 +28,7 @@
|
|||||||
<jaxb-core>4.0.0</jaxb-core>
|
<jaxb-core>4.0.0</jaxb-core>
|
||||||
<activation>1.1.1</activation>
|
<activation>1.1.1</activation>
|
||||||
<easy-captcha>1.6.2</easy-captcha>
|
<easy-captcha>1.6.2</easy-captcha>
|
||||||
<aws.java.sdk.version>2.20.43</aws.java.sdk.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
|
||||||
<artifactId>bom</artifactId>
|
|
||||||
<version>${aws.java.sdk.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@@ -88,12 +76,6 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-logging</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
@@ -156,160 +138,6 @@
|
|||||||
<artifactId>tencentcloud-sdk-java-ses</artifactId>
|
<artifactId>tencentcloud-sdk-java-ses</artifactId>
|
||||||
<version>3.1.572</version>
|
<version>3.1.572</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--minio-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.minio</groupId>
|
|
||||||
<artifactId>minio</artifactId>
|
|
||||||
<version>8.0.3</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-fileupload</groupId>
|
|
||||||
<artifactId>commons-fileupload</artifactId>
|
|
||||||
<version>1.4</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.microsoft.sqlserver</groupId>
|
|
||||||
<artifactId>mssql-jdbc</artifactId>
|
|
||||||
<version>9.2.1.jre8</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- RabbitMQ -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- redis 连接池 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-pool2</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--支付宝 SDK-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alipay.sdk</groupId>
|
|
||||||
<artifactId>alipay-sdk-java</artifactId>
|
|
||||||
<version>4.22.57.ALL</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--PayPal SDK-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.paypal.sdk</groupId>
|
|
||||||
<artifactId>checkout-sdk</artifactId>
|
|
||||||
<version>1.0.5</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.paypal.sdk</groupId>
|
|
||||||
<artifactId>rest-api-sdk</artifactId>
|
|
||||||
<version>LATEST</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.json</groupId>
|
|
||||||
<artifactId>json</artifactId>
|
|
||||||
<version>20230618</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
|
||||||
<artifactId>log4j-api</artifactId>
|
|
||||||
<version>2.17.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi</artifactId>
|
|
||||||
<version>5.2.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi-ooxml</artifactId>
|
|
||||||
<version>5.2.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-io</groupId>
|
|
||||||
<artifactId>commons-io</artifactId>
|
|
||||||
<version>2.11.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
|
||||||
<artifactId>log4j-api</artifactId>
|
|
||||||
<version>2.17.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.stripe</groupId>
|
|
||||||
<artifactId>stripe-java</artifactId>
|
|
||||||
<version>26.2.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- aws s3 -->
|
|
||||||
<!-- S3 dependency -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
|
||||||
<artifactId>s3</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
|
||||||
<artifactId>s3-transfer-manager</artifactId>
|
|
||||||
<version>2.17.103-PREVIEW</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
|
||||||
<artifactId>kms</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
|
||||||
<artifactId>s3control</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.gson</groupId>
|
|
||||||
<artifactId>gson</artifactId>
|
|
||||||
<version>2.10.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.itextpdf</groupId>
|
|
||||||
<artifactId>itextpdf</artifactId>
|
|
||||||
<version>5.5.13.2</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.auth</groupId>
|
|
||||||
<artifactId>google-auth-library-oauth2-http</artifactId>
|
|
||||||
<version>1.8.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.api-client</groupId>
|
|
||||||
<artifactId>google-api-client</artifactId>
|
|
||||||
<version>1.32.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.oauth-client</groupId>
|
|
||||||
<artifactId>google-oauth-client</artifactId>
|
|
||||||
<version>1.32.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.http-client</groupId>
|
|
||||||
<artifactId>google-http-client-jackson2</artifactId>
|
|
||||||
<version>1.41.5</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -329,30 +157,4 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<!-- 本地开发环境 -->
|
|
||||||
<id>dev</id>
|
|
||||||
<properties>
|
|
||||||
<profiles.active>dev</profiles.active>
|
|
||||||
</properties>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>true</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<!-- 测试环境 -->
|
|
||||||
<id>test</id>
|
|
||||||
<properties>
|
|
||||||
<profiles.active>test</profiles.active>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<!-- 生产环境 -->
|
|
||||||
<id>prod</id>
|
|
||||||
<properties>
|
|
||||||
<profiles.active>prod</profiles.active>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -3,11 +3,9 @@ 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.scheduling.annotation.EnableScheduling;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableScheduling
|
|
||||||
public class AiDaApplication {
|
public class AiDaApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -1,321 +0,0 @@
|
|||||||
package com.ai.da.common.RabbitMQ;
|
|
||||||
|
|
||||||
import com.ai.da.common.config.exception.BusinessException;
|
|
||||||
import com.ai.da.common.constant.CommonConstant;
|
|
||||||
import com.ai.da.common.utils.RedisUtil;
|
|
||||||
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
|
||||||
import com.ai.da.model.vo.GenerateResultVO;
|
|
||||||
import com.ai.da.service.GenerateService;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.rabbitmq.client.Channel;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.tomcat.jni.Time;
|
|
||||||
import org.springframework.amqp.core.Message;
|
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class GenerateConsumer {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private GenerateService generateService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RabbitMQProperties rabbitMQProperties;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private RedisUtil redisUtil;
|
|
||||||
|
|
||||||
@Value("${redis.key.orderForGenerate}")
|
|
||||||
private String consumptionOrderKey;
|
|
||||||
|
|
||||||
@Value("${redis.key.generateCancelSet}")
|
|
||||||
private String cancelSetKey;
|
|
||||||
|
|
||||||
@Value("${redis.key.generateExceptionMap}")
|
|
||||||
private String exceptionMapKey;
|
|
||||||
|
|
||||||
@Value("${redis.key.generateResult}")
|
|
||||||
private String generateResultKey;
|
|
||||||
@Value("${redis.key.toProductImageResultKey}")
|
|
||||||
private String toProductImageResultKey;
|
|
||||||
@Value("${redis.key.relightResultKey}")
|
|
||||||
private String relightResultKey;
|
|
||||||
|
|
||||||
public void generate(Message msg, Channel channel, String consumerName) {
|
|
||||||
log.info("============start listening==========");
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
|
|
||||||
GenerateThroughImageTextDTO generateThroughImageTextDTO = JSONObject.parseObject(msg.getBody(), GenerateThroughImageTextDTO.class);
|
|
||||||
String uniqueId = generateThroughImageTextDTO.getUniqueId();
|
|
||||||
log.info("From " + consumerName + " : " + uniqueId);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 2、判断当前消息是否在取消列表中
|
|
||||||
Boolean isMember = redisUtil.isElementExistsInSet(cancelSetKey, uniqueId);
|
|
||||||
if (isMember) {
|
|
||||||
try {
|
|
||||||
// 2.1 手动确认该消息
|
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
log.error("手动确认,不返回队列重新消费");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
generateService.generateThroughImageText(generateThroughImageTextDTO);
|
|
||||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
|
||||||
redisUtil.removeFromZSet(consumptionOrderKey, uniqueId);
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
// channel.basicNack() 为不确认deliveryTag对应的消息,第二个参数是否应用于多消息,第三个参数是否requeue
|
|
||||||
try {
|
|
||||||
// 第二个参数,是否批量确认消息,当传false时,只确认当前 deliveryTag对应的消息;当传true时,会确认当前及之前所有未确认的消息。
|
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
|
||||||
redisUtil.removeFromZSet(consumptionOrderKey, uniqueId);
|
|
||||||
String key = generateResultKey + ":" + uniqueId;
|
|
||||||
GenerateResultVO generateResultVO = new GenerateResultVO(generateThroughImageTextDTO.getUniqueId(), null, null, "Fail");
|
|
||||||
redisUtil.addToString(key, new Gson().toJson(generateResultVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
|
||||||
} catch (IOException exception) {
|
|
||||||
log.error("手动确认,取消返回队列,不再重新消费");
|
|
||||||
}
|
|
||||||
// 将入参和错误信息存入数据库
|
|
||||||
String exceptionMessage = JSONObject.toJSONString(generateThroughImageTextDTO) +
|
|
||||||
" Exception message : " + e.getMessage();
|
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
|
||||||
exceptionInfo.put(String.valueOf(uniqueId), exceptionMessage);
|
|
||||||
// 存redis
|
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
|
||||||
}
|
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
|
|
||||||
log.info(" task_id: " + uniqueId + "----------" + consumerName + " 执行时长:" + (end - start) + "毫秒");
|
|
||||||
log.info("=============end listening===========");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void processGenerateResult(Message msg, Channel channel) {
|
|
||||||
log.info("============ProcessGenerateResult listening==========");
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
|
|
||||||
Map<String, String> generateResult = JSONObject.parseObject(msg.getBody(), Map.class);
|
|
||||||
log.info("generate response : {}", generateResult);
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.info("tasks_id : {} start ", generateResult.get("tasks_id"));
|
|
||||||
if (generateResult.get("status").equals("SUCCESS")) {
|
|
||||||
String url = generateResult.get("image_url");
|
|
||||||
String taskId = generateResult.get("tasks_id");
|
|
||||||
String category = generateResult.get("category");
|
|
||||||
generateService.processGenerateResult(taskId, url, category);
|
|
||||||
} else {
|
|
||||||
// 修改redis中的数据状态为exception
|
|
||||||
String key = generateResultKey + ":" + generateResult.get("tasks_id");
|
|
||||||
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.get("tasks_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
|
||||||
// 将异常信息存到exception中
|
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
|
||||||
exceptionInfo.put(generateResult.get("tasks_id"), generateResult.get("data"));
|
|
||||||
// 存redis
|
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
try {
|
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
|
||||||
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.get("tasks_id"));
|
|
||||||
} catch (IOException exception) {
|
|
||||||
log.error("手动确认,取消返回队列,不再重新消费");
|
|
||||||
}
|
|
||||||
// 将入参和错误信息存入数据库
|
|
||||||
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
|
||||||
" Exception message : " + e.getMessage();
|
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
|
||||||
exceptionInfo.put(String.valueOf(generateResult.get("tasks_id")), exceptionMessage);
|
|
||||||
// 存redis
|
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
log.info("tasks_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("tasks_id"), generateResult.get("message"), (end - start));
|
|
||||||
log.info("============ProcessGenerateResult End listening==========");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void processToProductImageResult(Message msg, Channel channel) {
|
|
||||||
log.info("============processToProductImageResult listening==========");
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
|
|
||||||
Map<String, String> generateResult = JSONObject.parseObject(msg.getBody(), Map.class);
|
|
||||||
log.info("toProductImage response : {}", generateResult);
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.info("tasks_id : {} start ", generateResult.get("tasks_id"));
|
|
||||||
if (generateResult.get("status").equals("SUCCESS")) {
|
|
||||||
String url = generateResult.get("image_url");
|
|
||||||
String taskId = generateResult.get("tasks_id");
|
|
||||||
String category = generateResult.get("category");
|
|
||||||
generateService.processToProductImageResult(taskId, url, category);
|
|
||||||
} else {
|
|
||||||
// 修改redis中的数据状态为exception
|
|
||||||
String key = toProductImageResultKey + ":" + generateResult.get("tasks_id");
|
|
||||||
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.get("tasks_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
|
||||||
// 将异常信息存到exception中
|
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
|
||||||
exceptionInfo.put(generateResult.get("tasks_id"), generateResult.get("data"));
|
|
||||||
// 存redis
|
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
try {
|
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
|
||||||
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.get("tasks_id"));
|
|
||||||
} catch (IOException exception) {
|
|
||||||
log.error("手动确认,取消返回队列,不再重新消费");
|
|
||||||
}
|
|
||||||
// 将入参和错误信息存入数据库
|
|
||||||
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
|
||||||
" Exception message : " + e.getMessage();
|
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
|
||||||
exceptionInfo.put(String.valueOf(generateResult.get("tasks_id")), exceptionMessage);
|
|
||||||
// 存redis
|
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
log.info("tasks_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("tasks_id"), generateResult.get("message"), (end - start));
|
|
||||||
log.info("============ProcessToProductImageResult End listening==========");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processRelightResult(Message msg, Channel channel) {
|
|
||||||
log.info("============processRelightResult listening==========");
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
|
|
||||||
Map<String, String> generateResult = JSONObject.parseObject(msg.getBody(), Map.class);
|
|
||||||
log.info("toProductImage response : {}", generateResult);
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.info("tasks_id : {} start ", generateResult.get("tasks_id"));
|
|
||||||
if (generateResult.get("status").equals("SUCCESS")) {
|
|
||||||
String url = generateResult.get("image_url");
|
|
||||||
String taskId = generateResult.get("tasks_id");
|
|
||||||
String category = generateResult.get("category");
|
|
||||||
generateService.processRelightResult(taskId, url, category);
|
|
||||||
} else {
|
|
||||||
// 修改redis中的数据状态为exception
|
|
||||||
String key = relightResultKey + ":" + generateResult.get("tasks_id");
|
|
||||||
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.get("tasks_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
|
||||||
// 将异常信息存到exception中
|
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
|
||||||
exceptionInfo.put(generateResult.get("tasks_id"), generateResult.get("data"));
|
|
||||||
// 存redis
|
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
try {
|
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
|
||||||
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.get("tasks_id"));
|
|
||||||
} catch (IOException exception) {
|
|
||||||
log.error("手动确认,取消返回队列,不再重新消费");
|
|
||||||
}
|
|
||||||
// 将入参和错误信息存入数据库
|
|
||||||
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
|
||||||
" Exception message : " + e.getMessage();
|
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
|
||||||
exceptionInfo.put(String.valueOf(generateResult.get("tasks_id")), exceptionMessage);
|
|
||||||
// 存redis
|
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
log.info("tasks_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("tasks_id"), generateResult.get("message"), (end - start));
|
|
||||||
log.info("============ProcessRelightResult End listening==========");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void generateConsumer1(Message msg, Channel channel) {
|
|
||||||
generate(msg, channel, "consumer 1");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void generateConsumer2(Message msg, Channel channel) {
|
|
||||||
generate(msg, channel, "consumer 2");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void generateConsumer3(Message msg, Channel channel) {
|
|
||||||
generate(msg, channel, "consumer 3");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void generateConsumer4(Message msg, Channel channel) {
|
|
||||||
generate(msg, channel, "consumer 4");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void generateConsumer5(Message msg, Channel channel) {
|
|
||||||
generate(msg, channel, "consumer 5");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void generateConsumer6(Message msg, Channel channel) {
|
|
||||||
generate(msg, channel, "consumer 6");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void generateConsumer7(Message msg, Channel channel) {
|
|
||||||
generate(msg, channel, "consumer 7");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void generateConsumer8(Message msg, Channel channel) {
|
|
||||||
generate(msg, channel, "consumer 8");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void generateConsumer9(Message msg, Channel channel) {
|
|
||||||
generate(msg, channel, "consumer 9");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generateResult}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void getGenerateResult(Message msg, Channel channel) {
|
|
||||||
processGenerateResult(msg, channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.toProductImageResult}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void getToProductImageResult(Message msg, Channel channel) {
|
|
||||||
processToProductImageResult(msg, channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.relightResult}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void getRelightResult(Message msg, Channel channel) {
|
|
||||||
processRelightResult(msg, channel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package com.ai.da.common.RabbitMQ;
|
|
||||||
|
|
||||||
import org.springframework.amqp.core.Queue;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class MQConfig {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RabbitMQProperties rabbitMQProperties;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Queue generateQueue() {
|
|
||||||
return new Queue(rabbitMQProperties.getQueues().getGenerate());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Queue SRQueue() {
|
|
||||||
return new Queue(rabbitMQProperties.getQueues().getSr());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Queue SRResultQueue() {
|
|
||||||
return new Queue(rabbitMQProperties.getQueues().getSrResult());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Queue generateResultQueue() {
|
|
||||||
return new Queue(rabbitMQProperties.getQueues().getGenerateResult());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Queue toProductImageResultQueue() {
|
|
||||||
return new Queue(rabbitMQProperties.getQueues().getToProductImageResult());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Queue relightResultQueue() {
|
|
||||||
return new Queue(rabbitMQProperties.getQueues().getRelightResult());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package com.ai.da.common.RabbitMQ;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.amqp.core.AmqpTemplate;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class MQPublisher {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RabbitMQProperties rabbitMQProperties;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AmqpTemplate amqpTemplate;
|
|
||||||
|
|
||||||
public void sendGenerateMessage(String mm) {
|
|
||||||
log.info("send message: " + mm);
|
|
||||||
amqpTemplate.convertAndSend(rabbitMQProperties.getQueues().getGenerate(), mm);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendSRMessage(String mm) {
|
|
||||||
log.info("send message: " + mm);
|
|
||||||
amqpTemplate.convertAndSend(rabbitMQProperties.getQueues().getSr(), mm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.ai.da.common.RabbitMQ;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@ConfigurationProperties(prefix = "rabbitmq")
|
|
||||||
@Data
|
|
||||||
public class RabbitMQProperties {
|
|
||||||
|
|
||||||
private Queues queues;
|
|
||||||
private Exchange exchange;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Queues {
|
|
||||||
private String generate;
|
|
||||||
private String sr;
|
|
||||||
private String srResult;
|
|
||||||
private String generateResult;
|
|
||||||
private String toProductImageResult;
|
|
||||||
private String relightResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Exchange {
|
|
||||||
private String generate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,237 +0,0 @@
|
|||||||
package com.ai.da.common.RabbitMQ;
|
|
||||||
|
|
||||||
import com.ai.da.common.config.exception.BusinessException;
|
|
||||||
import com.ai.da.common.utils.RedisUtil;
|
|
||||||
import com.ai.da.model.dto.SuperResolutionDTO;
|
|
||||||
import com.ai.da.model.dto.TaskDTO;
|
|
||||||
import com.ai.da.service.SuperResolutionService;
|
|
||||||
import com.ai.da.service.TaskListService;
|
|
||||||
import com.alibaba.fastjson.JSONException;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.rabbitmq.client.Channel;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.amqp.core.Message;
|
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class SRConsumer {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RabbitMQProperties rabbitMQProperties;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private RedisUtil redisUtil;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private TaskListService taskListService;
|
|
||||||
|
|
||||||
@Value("${redis.key.orderForSR}")
|
|
||||||
private String consumptionOrderKey;
|
|
||||||
|
|
||||||
@Value("${redis.key.SRCancelSet}")
|
|
||||||
private String cancelSetKey;
|
|
||||||
|
|
||||||
@Value("${redis.key.SRExceptionMap}")
|
|
||||||
private String exceptionMapKey;
|
|
||||||
|
|
||||||
@Value("${redis.key.taskList}")
|
|
||||||
private String taskListKey;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private SuperResolutionService superResolutionService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求超分处理
|
|
||||||
*/
|
|
||||||
public void superResolution(Message msg, Channel channel, String consumerName) {
|
|
||||||
log.info("============SR start listening==========");
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
|
|
||||||
SuperResolutionDTO superResolutionDTO;
|
|
||||||
String uniqueId = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
superResolutionDTO = JSONObject.parseObject(msg.getBody(), SuperResolutionDTO.class);
|
|
||||||
uniqueId = superResolutionDTO.getUniqueId();
|
|
||||||
log.info("From " + consumerName + " : " + uniqueId);
|
|
||||||
superResolutionService.updateSROutput(uniqueId, "Executing", null);
|
|
||||||
taskListService.updateTaskStatusOrOutputRedis(uniqueId, "Executing", null);
|
|
||||||
/*try {
|
|
||||||
Thread.sleep(2 * 60 * 1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}*/
|
|
||||||
// 2、判断当前消息是否在取消列表中
|
|
||||||
Boolean isMember = redisUtil.isElementExistsInSet(cancelSetKey, uniqueId);
|
|
||||||
if (isMember) {
|
|
||||||
try {
|
|
||||||
// 2.1 手动确认该消息
|
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
log.error("手动确认,不返回队列重新消费");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 请求python端进行超分
|
|
||||||
superResolutionService.SR(superResolutionDTO);
|
|
||||||
}
|
|
||||||
} catch (BusinessException e) {
|
|
||||||
log.error(e.getMsg());
|
|
||||||
superResolutionDTO = JSONObject.parseObject(msg.getBody(), SuperResolutionDTO.class);
|
|
||||||
// channel.basicNack() 为不确认deliveryTag对应的消息,第二个参数是否应用于多消息,第三个参数是否requeue
|
|
||||||
setErrorMessage(msg, channel, e.getMsg(), superResolutionDTO);
|
|
||||||
try {
|
|
||||||
// 2.1 手动确认该消息
|
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
log.error("手动确认,不返回队列重新消费, error message : " + e.getMessage());
|
|
||||||
}
|
|
||||||
} catch (JSONException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
setErrorMessage(msg, channel, e.getMessage(), null);
|
|
||||||
try {
|
|
||||||
// 2.1 手动确认该消息
|
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
log.error("手动确认,不返回队列重新消费, error message : " + e.getMessage());
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
superResolutionDTO = JSONObject.parseObject(msg.getBody(), SuperResolutionDTO.class);
|
|
||||||
setErrorMessage(msg, channel, e.getMessage(), superResolutionDTO);
|
|
||||||
try {
|
|
||||||
// 2.1 手动确认该消息
|
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
log.error("手动确认,不返回队列重新消费, error message : " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
|
|
||||||
log.info(" task_id: " + uniqueId + "----------" + consumerName + " 执行时长:" + (end - start) + "毫秒");
|
|
||||||
log.info("=============SR end listening===========");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取超分结果
|
|
||||||
*/
|
|
||||||
public void getSRResult(Message msg, Channel channel, String consumerName) {
|
|
||||||
log.info("============SRResult start listening==========");
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
|
|
||||||
JSONObject result = null;
|
|
||||||
String taskId = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
result = JSONObject.parseObject(msg.getBody(), JSONObject.class);
|
|
||||||
log.info("SR response : {}", result);
|
|
||||||
taskId = result.get("tasks_id").toString();
|
|
||||||
} catch (JSONException e) {
|
|
||||||
log.error("SRResult 返回数据格式不合规范");
|
|
||||||
log.error(e.getMessage());
|
|
||||||
setErrorMessage(msg, channel, e.getMessage(), null);
|
|
||||||
try {
|
|
||||||
// 第二个参数,是否批量确认消息,当传false时,只确认当前 deliveryTag对应的消息;当传true时,会确认当前及之前所有未确认的消息。
|
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
} catch (IOException exception) {
|
|
||||||
log.error("手动确认,取消返回队列,不再重新消费");
|
|
||||||
}
|
|
||||||
} catch (Exception e){
|
|
||||||
log.error(e.getMessage());
|
|
||||||
setErrorMessage(msg, channel, e.getMessage(), null);
|
|
||||||
try {
|
|
||||||
// 第二个参数,是否批量确认消息,当传false时,只确认当前 deliveryTag对应的消息;当传true时,会确认当前及之前所有未确认的消息。
|
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
} catch (IOException exception) {
|
|
||||||
log.error("手动确认,取消返回队列,不再重新消费");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 2、判断状态是否成功
|
|
||||||
if ("SUCCESS".equals(result.get("status").toString())) {
|
|
||||||
String output = result.get("data").toString();
|
|
||||||
superResolutionService.setSRResult(taskId, output, "success");
|
|
||||||
taskListService.updateTaskStatusOrOutputRedis(taskId, "success", output);
|
|
||||||
} else {
|
|
||||||
superResolutionService.setSRResult(taskId, null, "fail");
|
|
||||||
taskListService.updateTaskStatusOrOutputRedis(taskId, "fail", null);
|
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
|
||||||
// 获取输入信息
|
|
||||||
String task = redisUtil.getFromString(taskListKey + taskId + taskId.substring(taskId.lastIndexOf("-") + 1));
|
|
||||||
Gson gson = new Gson();
|
|
||||||
Type type = new TypeToken<TaskDTO<SuperResolutionDTO>>() {
|
|
||||||
}.getType();
|
|
||||||
TaskDTO<SuperResolutionDTO> taskDTO = gson.fromJson(task, type);
|
|
||||||
// 将输入信息和报错信息均存入redis todo 加判空
|
|
||||||
exceptionInfo.put(taskId, "Input ==> " + taskDTO.getInputParam() + "Fail Message ==> " + result.get("message").toString());
|
|
||||||
// 将报错信息存入redis
|
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
// channel.basicNack() 为不确认deliveryTag对应的消息,第二个参数是否应用于多消息,第三个参数是否requeue
|
|
||||||
try {
|
|
||||||
// 第二个参数,是否批量确认消息,当传false时,只确认当前 deliveryTag对应的消息;当传true时,会确认当前及之前所有未确认的消息。
|
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
} catch (IOException exception) {
|
|
||||||
log.error("手动确认,取消返回队列,不再重新消费");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
|
|
||||||
log.info(" task_id: " + taskId + "----------" + consumerName + " 执行时长:" + (end - start) + "毫秒");
|
|
||||||
log.info("=============SRResult end listening===========");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setErrorMessage(Message msg, Channel channel, String message, SuperResolutionDTO superResolutionDTO) {
|
|
||||||
String uniqueId;
|
|
||||||
try {
|
|
||||||
// 第二个参数,是否批量确认消息,当传false时,只确认当前 deliveryTag对应的消息;当传true时,会确认当前及之前所有未确认的消息。
|
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
uniqueId = superResolutionDTO.getUniqueId();
|
|
||||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
|
||||||
redisUtil.removeFromZSet(consumptionOrderKey, uniqueId);
|
|
||||||
} catch (Exception exception) {
|
|
||||||
log.error("手动确认,取消返回队列,不再重新消费");
|
|
||||||
throw new BusinessException("发生错误,手动确认消息");
|
|
||||||
}
|
|
||||||
// 将入参和错误信息存入redis
|
|
||||||
String exceptionMessage = JSONObject.toJSONString(superResolutionDTO) +
|
|
||||||
" Exception message : " + message;
|
|
||||||
// " Exception message : " + e.getMessage();
|
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
|
||||||
uniqueId = superResolutionDTO.getUniqueId();
|
|
||||||
exceptionInfo.put(String.valueOf(uniqueId), exceptionMessage);
|
|
||||||
// 存redis
|
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
|
||||||
taskListService.updateTaskStatusOrOutputRedis(uniqueId, "fail", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.sr}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void SRConsumer1(Message msg, Channel channel) {
|
|
||||||
superResolution(msg, channel, "consumer 1");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.srResult}")
|
|
||||||
@RabbitHandler
|
|
||||||
public void SRResultConsumer1(Message msg, Channel channel) {
|
|
||||||
getSRResult(msg, channel, "consumer 1");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package com.ai.da.common.config;
|
|
||||||
|
|
||||||
import com.alipay.api.*;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.PropertySource;
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
//加载配置文件
|
|
||||||
@PropertySource("classpath:alipay-sandbox.properties")
|
|
||||||
public class AlipayClientConfig {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private Environment config;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public AlipayClient alipayClient() throws AlipayApiException {
|
|
||||||
|
|
||||||
AlipayConfig alipayConfig = new AlipayConfig();
|
|
||||||
|
|
||||||
//设置网关地址
|
|
||||||
alipayConfig.setServerUrl(config.getProperty("alipay.gateway-url"));
|
|
||||||
//设置应用Id
|
|
||||||
alipayConfig.setAppId(config.getProperty("alipay.app-id"));
|
|
||||||
//设置应用私钥
|
|
||||||
alipayConfig.setPrivateKey(config.getProperty("alipay.merchant-private-key"));
|
|
||||||
//设置请求格式,固定值json
|
|
||||||
alipayConfig.setFormat(AlipayConstants.FORMAT_JSON);
|
|
||||||
//设置字符集
|
|
||||||
alipayConfig.setCharset(AlipayConstants.CHARSET_UTF8);
|
|
||||||
//设置支付宝公钥
|
|
||||||
alipayConfig.setAlipayPublicKey(config.getProperty("alipay.alipay-public-key"));
|
|
||||||
//设置签名类型
|
|
||||||
alipayConfig.setSignType(AlipayConstants.SIGN_TYPE_RSA2);
|
|
||||||
//构造client
|
|
||||||
AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig);
|
|
||||||
|
|
||||||
return alipayClient;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,393 +0,0 @@
|
|||||||
package com.ai.da.common.config;
|
|
||||||
|
|
||||||
import com.ai.da.mapper.primary.entity.CustomerData;
|
|
||||||
import com.ai.da.mapper.primary.entity.TransactionData;
|
|
||||||
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class CRMReportInterface {
|
|
||||||
|
|
||||||
// JDBC 驱动器名称以及数据库 URL
|
|
||||||
static final String JDBC_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
|
|
||||||
static final String DB_URL = "jdbc:sqlserver://118.142.0.178:1550;databaseName=Hayman_prod";
|
|
||||||
|
|
||||||
// 数据库凭据
|
|
||||||
static final String USER = "user01";
|
|
||||||
static final String PASS = "haySIS-2302";
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Connection conn = null;
|
|
||||||
Statement stmt = null;
|
|
||||||
try {
|
|
||||||
// 注册 JDBC 驱动器
|
|
||||||
Class.forName(JDBC_DRIVER);
|
|
||||||
|
|
||||||
// 打开一个连接
|
|
||||||
System.out.println("连接数据库...");
|
|
||||||
conn = DriverManager.getConnection(DB_URL, USER, PASS);
|
|
||||||
|
|
||||||
// 执行查询步骤1: 生成 RW0095 报告以获取客户完整数据
|
|
||||||
System.out.println("执行步骤1:生成 RW0095 报告...");
|
|
||||||
// 执行相应的查询并获取数据
|
|
||||||
// List<CustomerData> customerData = retrieveCustomerData();
|
|
||||||
// 执行查询步骤2: 使用 MZG013 报告检查客户的销售历史
|
|
||||||
System.out.println("执行步骤2:使用 MZG013 报告检查客户的销售历史...");
|
|
||||||
// 执行相应的查询并获取数据
|
|
||||||
List<TransactionData> transactionData = retrieveTransactionData();
|
|
||||||
List<String> collect = transactionData.stream().map(TransactionData::getUserMember).collect(Collectors.toList());
|
|
||||||
List<CustomerData> customerData = retrieveCustomerData(collect);
|
|
||||||
for (TransactionData transactionDatum : transactionData) {
|
|
||||||
for (CustomerData customerDatum : customerData) {
|
|
||||||
if (customerDatum.getMbrCode().equals(transactionDatum.getUserMember())) {
|
|
||||||
customerDatum.setLastMonth(transactionDatum.getSumAmt());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 执行步骤3: 合并(vlookup)RW0095中的客户购买金额
|
|
||||||
System.out.println("执行步骤3:合并客户购买金额...");
|
|
||||||
// 执行相应的操作,如vlookup
|
|
||||||
|
|
||||||
// 执行步骤4: 按“发行店”筛选以分离不同文件并逐个发送给店铺
|
|
||||||
System.out.println("执行步骤4:按发行店筛选并发送文件给店铺...");
|
|
||||||
// 执行相应的操作,如过滤和导出
|
|
||||||
String filePath = "C:\\Users\\10233\\Desktop\\CRM.csv";
|
|
||||||
exportToCSV(customerData, filePath);
|
|
||||||
// 关闭连接
|
|
||||||
conn.close();
|
|
||||||
} catch (SQLException se) {
|
|
||||||
// 处理 JDBC 错误
|
|
||||||
se.printStackTrace();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// 处理 Class.forName 错误
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
// 关闭资源
|
|
||||||
try {
|
|
||||||
if (stmt != null) stmt.close();
|
|
||||||
} catch (SQLException se2) {
|
|
||||||
} // 什么都不做
|
|
||||||
try {
|
|
||||||
if (conn != null) conn.close();
|
|
||||||
} catch (SQLException se) {
|
|
||||||
se.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("接口执行完成!");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void exportToCSV(List<CustomerData> customerDataList, String filePath) throws IOException {
|
|
||||||
FileWriter writer = new FileWriter(filePath);
|
|
||||||
|
|
||||||
// // 写入 CSV 文件的第一行,即字段名
|
|
||||||
// writer.append("User Member,Mbr Name,Sh Code,Sum Amt\n");
|
|
||||||
//
|
|
||||||
// // 遍历数据列表,并将每一行数据写入 CSV 文件
|
|
||||||
// for (TransactionData transaction : transactionDataList) {
|
|
||||||
// writer.append(transaction.getUserMember()).append(",");
|
|
||||||
// writer.append(transaction.getMbrName()).append(",");
|
|
||||||
// writer.append(transaction.getShCode()).append(",");
|
|
||||||
// writer.append(String.valueOf(transaction.getSumAmt())).append("\n");
|
|
||||||
// }
|
|
||||||
writer.append("mbrCode,mbrName,mbrMobile,mbrGroup,mbrStatus,joinDate,mbrIssue,birthMonth,mbrSex,offBonus,effBonus,sumBonus,lastMonth\n");
|
|
||||||
|
|
||||||
// 遍历 customerDataList,并将数据写入 CSV 文件
|
|
||||||
for (CustomerData customer : customerDataList) {
|
|
||||||
writer.append(customer.getMbrCode()).append(",");
|
|
||||||
writer.append(customer.getMbrName()).append(",");
|
|
||||||
writer.append(customer.getMbrMobile()).append(",");
|
|
||||||
writer.append(customer.getMbrGroup()).append(",");
|
|
||||||
writer.append(customer.getMbrStatus()).append(",");
|
|
||||||
writer.append(customer.getJoinDate().toString()).append(","); // 日期需要根据实际情况格式化
|
|
||||||
writer.append(customer.getMbrIssue()).append(",");
|
|
||||||
writer.append(Integer.toString(customer.getBirthMonth())).append(",");
|
|
||||||
writer.append(customer.getMbrSex()).append(",");
|
|
||||||
writer.append(Double.toString(customer.getOffBonus())).append(",");
|
|
||||||
writer.append(Double.toString(customer.getEffBonus())).append(",");
|
|
||||||
writer.append(Double.toString(customer.getSumBonus())).append(",");
|
|
||||||
writer.append(Double.toString(customer.getLastMonth())).append("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<CustomerData> retrieveCustomerData(List<String> collect) {
|
|
||||||
List<CustomerData> customerDataList = new ArrayList<>();
|
|
||||||
Connection conn = null;
|
|
||||||
Statement stmt = null;
|
|
||||||
try {
|
|
||||||
// 注册 JDBC 驱动器
|
|
||||||
Class.forName(JDBC_DRIVER);
|
|
||||||
|
|
||||||
// 打开一个连接
|
|
||||||
System.out.println("连接数据库...");
|
|
||||||
conn = DriverManager.getConnection(DB_URL, USER, PASS);
|
|
||||||
|
|
||||||
// 执行查询
|
|
||||||
System.out.println("创建声明...");
|
|
||||||
stmt = conn.createStatement();
|
|
||||||
String sql;
|
|
||||||
// 构建 IN 子句的字符串,用于添加到 SQL 查询中
|
|
||||||
StringBuilder inClause = new StringBuilder("(");
|
|
||||||
for (String code : collect) {
|
|
||||||
inClause.append("'").append(code).append("',");
|
|
||||||
}
|
|
||||||
inClause.deleteCharAt(inClause.length() - 1); // 删除最后一个逗号
|
|
||||||
inClause.append(")");
|
|
||||||
|
|
||||||
// 构建完整的 SQL 查询语句
|
|
||||||
sql = "SELECT * FROM V_RW0095B WHERE mbr_code IN " + inClause.toString();
|
|
||||||
ResultSet rs = stmt.executeQuery(sql);
|
|
||||||
|
|
||||||
|
|
||||||
// 处理结果集
|
|
||||||
while (rs.next()) {
|
|
||||||
// 将每行数据转换为 CustomerData 对象并添加到列表中
|
|
||||||
CustomerData customer = new CustomerData();
|
|
||||||
customer.setMbrCode(rs.getString("mbr_code"));
|
|
||||||
customer.setMbrName(rs.getString("mbr_name"));
|
|
||||||
customer.setMbrMobile(rs.getString("mbr_mobile"));
|
|
||||||
customer.setMbrGroup(rs.getString("mbr_group"));
|
|
||||||
customer.setMbrStatus(rs.getString("mbr_status"));
|
|
||||||
customer.setJoinDate(rs.getDate("join_date"));
|
|
||||||
customer.setMbrIssue(rs.getString("mbr_issue"));
|
|
||||||
customer.setBirthMonth(rs.getInt("birth_m"));
|
|
||||||
customer.setMbrSex(rs.getString("mbr_sex"));
|
|
||||||
customer.setOffBonus(rs.getDouble("off_bonus"));
|
|
||||||
customer.setEffBonus(rs.getDouble("eff_bonus"));
|
|
||||||
customer.setSumBonus(rs.getDouble("sum_bonus"));
|
|
||||||
customerDataList.add(customer);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 清理环境
|
|
||||||
rs.close();
|
|
||||||
stmt.close();
|
|
||||||
conn.close();
|
|
||||||
} catch (SQLException se) {
|
|
||||||
// 处理 JDBC 错误
|
|
||||||
se.printStackTrace();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// 处理 Class.forName 错误
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
// 关闭资源
|
|
||||||
try {
|
|
||||||
if (stmt != null) stmt.close();
|
|
||||||
} catch (SQLException se2) {
|
|
||||||
} // 什么都不做
|
|
||||||
try {
|
|
||||||
if (conn != null) conn.close();
|
|
||||||
} catch (SQLException se) {
|
|
||||||
se.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("查询执行完成!");
|
|
||||||
return customerDataList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<TransactionData> retrieveTransactionData() {
|
|
||||||
List<TransactionData> transactionDataList = new ArrayList<>();
|
|
||||||
Connection conn = null;
|
|
||||||
Statement stmt = null;
|
|
||||||
try {
|
|
||||||
// 注册 JDBC 驱动器
|
|
||||||
Class.forName(JDBC_DRIVER);
|
|
||||||
|
|
||||||
// 打开一个连接
|
|
||||||
System.out.println("连接数据库...");
|
|
||||||
conn = DriverManager.getConnection(DB_URL, USER, PASS);
|
|
||||||
|
|
||||||
// 执行查询
|
|
||||||
System.out.println("创建声明...");
|
|
||||||
stmt = conn.createStatement();
|
|
||||||
String sql;
|
|
||||||
sql = "SELECT user_member,mbr_name,sum(trx_bas_amt) sumAmtByMebBySh FROM V_MZG013\n" +
|
|
||||||
"WHERE trx_date >= DATEADD(day, -7, GETDATE())\n" +
|
|
||||||
"and user_member is not NULL\n" +
|
|
||||||
"GROUP BY user_member,mbr_name";
|
|
||||||
ResultSet rs = stmt.executeQuery(sql);
|
|
||||||
|
|
||||||
// 处理结果集
|
|
||||||
while (rs.next()) {
|
|
||||||
// 将每行数据转换为 TransactionData 对象并添加到列表中
|
|
||||||
TransactionData transaction = new TransactionData();
|
|
||||||
transaction.setUserMember(rs.getString("user_member"));
|
|
||||||
transaction.setMbrName(rs.getString("mbr_name"));
|
|
||||||
// transaction.setShCode(rs.getString("sh_code"));
|
|
||||||
transaction.setSumAmt(rs.getDouble("sumAmtByMebBySh"));
|
|
||||||
// transaction.setTrxNo(rs.getString("trx_no"));
|
|
||||||
// transaction.setTrxDate(rs.getTimestamp("trx_date"));
|
|
||||||
// transaction.setTrxType(rs.getString("trx_type"));
|
|
||||||
// transaction.setTrxStatus(rs.getString("trx_status"));
|
|
||||||
// transaction.setTrxTotQty(rs.getDouble("trx_tot_qty"));
|
|
||||||
// transaction.setCurrCode(rs.getString("curr_code"));
|
|
||||||
// transaction.setExchRate(rs.getDouble("exch_rate"));
|
|
||||||
// transaction.setDiscountPerc(rs.getDouble("discount_perc"));
|
|
||||||
// transaction.setTrxAccAmt(rs.getDouble("trx_acc_amt"));
|
|
||||||
// transaction.setTrxBasAmt(rs.getDouble("trx_bas_amt"));
|
|
||||||
// transaction.setOutstandAmt(rs.getDouble("outstand_amt"));
|
|
||||||
// transaction.setReceiveAmt(rs.getDouble("receive_amt"));
|
|
||||||
// transaction.setChangeAmt(rs.getDouble("change_amt"));
|
|
||||||
// transaction.setTrxTotBonus(rs.getDouble("trx_tot_bonus"));
|
|
||||||
// transaction.setDepositNo(rs.getString("deposit_no"));
|
|
||||||
// transaction.setDepositAmt(rs.getDouble("deposit_amt"));
|
|
||||||
// transaction.setDepositStatus(rs.getString("deposit_status"));
|
|
||||||
// transaction.setTrxAmtDesc(rs.getString("trx_amt_desc"));
|
|
||||||
// transaction.setRemark(rs.getString("remark"));
|
|
||||||
// transaction.setShCode(rs.getString("sh_code"));
|
|
||||||
// transaction.setWhCodeFrom(rs.getString("wh_code_from"));
|
|
||||||
// transaction.setWhCodeTo(rs.getString("wh_code_to"));
|
|
||||||
// transaction.setIssuedBy(rs.getString("issued_by"));
|
|
||||||
// transaction.setClientCode(rs.getString("client_code"));
|
|
||||||
// transaction.setClientName(rs.getString("client_name"));
|
|
||||||
// transaction.setSalesmanCode(rs.getString("salesman_code"));
|
|
||||||
// transaction.setCtypeCode(rs.getString("ctype_code"));
|
|
||||||
// transaction.setUpdatedOn(rs.getTimestamp("updated_on"));
|
|
||||||
// transaction.setDocType(rs.getString("doc_type"));
|
|
||||||
// transaction.setRefNo(rs.getString("ref_no"));
|
|
||||||
// transaction.setAdjType(rs.getString("adj_type"));
|
|
||||||
// transaction.setRefType(rs.getString("ref_type"));
|
|
||||||
// transaction.setOrderNo(rs.getString("order_no"));
|
|
||||||
// transaction.setRecoverF(rs.getString("recover_f"));
|
|
||||||
// transaction.setRecoverT(rs.getString("recover_t"));
|
|
||||||
// transaction.setRequestBy(rs.getString("request_by"));
|
|
||||||
// transaction.setError(rs.getString("error"));
|
|
||||||
// transaction.setAuthorizedDate(rs.getTimestamp("authorized_date"));
|
|
||||||
// transaction.setAuthorizedBy(rs.getString("authorized_by"));
|
|
||||||
// transaction.setChangeCurrCode(rs.getString("change_curr_code"));
|
|
||||||
// transaction.setChgRate(rs.getDouble("chg_rate"));
|
|
||||||
// transaction.setCashier(rs.getString("cashier"));
|
|
||||||
// transaction.setCashiNo(rs.getString("cashi_no"));
|
|
||||||
// transaction.setSalesmanCode2(rs.getString("salesman_code2"));
|
|
||||||
// transaction.setClassId(rs.getString("class_id"));
|
|
||||||
// transaction.setDisAmt(rs.getDouble("dis_amt"));
|
|
||||||
// transaction.setAcStatus(rs.getString("ac_status"));
|
|
||||||
// transaction.setReprint(rs.getString("reprint"));
|
|
||||||
// transaction.setAlt1(rs.getString("alt_1"));
|
|
||||||
// transaction.setAlt2(rs.getString("alt_2"));
|
|
||||||
// transaction.setAlt3(rs.getString("alt_3"));
|
|
||||||
// transaction.setAlt4(rs.getString("alt_4"));
|
|
||||||
// transaction.setAlt5(rs.getString("alt_5"));
|
|
||||||
// transaction.setAltD1(rs.getDate("alt_d1"));
|
|
||||||
// transaction.setAltD2(rs.getDate("alt_d2"));
|
|
||||||
// transaction.setAltD3(rs.getDate("alt_d3"));
|
|
||||||
// transaction.setAltD4(rs.getDate("alt_d4"));
|
|
||||||
// transaction.setAltD5(rs.getDate("alt_d5"));
|
|
||||||
// transaction.setSalesmanCode3(rs.getString("salesman_code3"));
|
|
||||||
// transaction.setContractNo(rs.getString("contract_no"));
|
|
||||||
// transaction.setExpireDate(rs.getTimestamp("expire_date"));
|
|
||||||
// transaction.setDepositNetAmt(rs.getDouble("deposit_netamt"));
|
|
||||||
// transaction.setClientRestriction(rs.getString("client_restriction"));
|
|
||||||
// transaction.setRefStatus(rs.getString("ref_status"));
|
|
||||||
// transaction.setMbrDis(rs.getDouble("mbr_dis"));
|
|
||||||
// transaction.setPmtDiscount(rs.getDouble("pmt_discount"));
|
|
||||||
// transaction.setPmtAmount(rs.getDouble("pmt_amount"));
|
|
||||||
// transaction.setPmtNo(rs.getString("pmt_no"));
|
|
||||||
// transaction.setRefCode(rs.getString("ref_code"));
|
|
||||||
// transaction.setDocApproved(rs.getString("doc_approved"));
|
|
||||||
// transaction.setRefractionNo(rs.getString("refraction_no"));
|
|
||||||
// transaction.setCcpTot(rs.getDouble("ccp_tot"));
|
|
||||||
// transaction.setCcpRed(rs.getDouble("ccp_red"));
|
|
||||||
// transaction.setCcpExpired(rs.getDouble("ccp_expired"));
|
|
||||||
// transaction.setPrintedTimes(rs.getInt("printed_times"));
|
|
||||||
// transaction.setPickupShop(rs.getString("pickup_shop"));
|
|
||||||
// transaction.setDeliveryDate(rs.getDate("delivery_date"));
|
|
||||||
// transaction.setDeliveryTime(rs.getString("delivery_time"));
|
|
||||||
// transaction.setWsCode(rs.getString("ws_code"));
|
|
||||||
// transaction.setClCode(rs.getString("cl_code"));
|
|
||||||
// transaction.setClDesc(rs.getString("cl_desc"));
|
|
||||||
// transaction.setRatio(rs.getString("ratio"));
|
|
||||||
// transaction.setUserMember(rs.getString("user_member"));
|
|
||||||
// transaction.setHflag(rs.getString("hflag"));
|
|
||||||
// transaction.setIssueShop(rs.getString("issue_shop"));
|
|
||||||
// transaction.setHoUpdBy(rs.getString("ho_upd_by"));
|
|
||||||
// transaction.setHoUpdOn(rs.getTimestamp("ho_upd_on"));
|
|
||||||
// transaction.setBonusExpired(rs.getDouble("bonus_expired"));
|
|
||||||
// transaction.setBonusRed(rs.getDouble("bonus_red"));
|
|
||||||
// transaction.setConfirmedOn(rs.getTimestamp("confirmed_on"));
|
|
||||||
// transaction.setConfirmedBy(rs.getString("confirmed_by"));
|
|
||||||
// transaction.setDocConfirmed(rs.getString("doc_confirmed"));
|
|
||||||
// transaction.setBrNo(rs.getString("br_no"));
|
|
||||||
// transaction.setChangeAmt2(rs.getDouble("change_amt2"));
|
|
||||||
// transaction.setSalesDate(rs.getDate("sales_date"));
|
|
||||||
// transaction.setMbrName(rs.getString("mbr_name"));
|
|
||||||
// transaction.setCanEntryDis(rs.getString("can_entry_dis"));
|
|
||||||
// transaction.setReactiveClient(rs.getString("reactive_client"));
|
|
||||||
// transaction.setReactiveMbr(rs.getString("reactive_mbr"));
|
|
||||||
// transaction.setShUpdBy(rs.getString("sh_upd_by"));
|
|
||||||
// transaction.setShUpdOn(rs.getTimestamp("sh_upd_on"));
|
|
||||||
// transaction.setTax1(rs.getDouble("tax1"));
|
|
||||||
// transaction.setTax2(rs.getDouble("tax2"));
|
|
||||||
// transaction.setTax3(rs.getDouble("tax3"));
|
|
||||||
// transaction.setTax4(rs.getDouble("tax4"));
|
|
||||||
// transaction.setTax5(rs.getDouble("tax5"));
|
|
||||||
// transaction.setAltChar1(rs.getString("alt_char1"));
|
|
||||||
// transaction.setAltChar2(rs.getString("alt_char2"));
|
|
||||||
// transaction.setAltChar3(rs.getString("alt_char3"));
|
|
||||||
// transaction.setAltChar4(rs.getString("alt_char4"));
|
|
||||||
// transaction.setAltChar5(rs.getString("alt_char5"));
|
|
||||||
// transaction.setAltNum1(rs.getDouble("alt_num1"));
|
|
||||||
// transaction.setAltNum2(rs.getDouble("alt_num2"));
|
|
||||||
// transaction.setAltNum3(rs.getDouble("alt_num3"));
|
|
||||||
// transaction.setAltNum4(rs.getDouble("alt_num4"));
|
|
||||||
// transaction.setAltNum5(rs.getDouble("alt_num5"));
|
|
||||||
// transaction.setNewClient(rs.getString("new_client"));
|
|
||||||
// transaction.setNewMbr(rs.getString("new_mbr"));
|
|
||||||
// transaction.setPmtExtraDiscount(rs.getDouble("pmt_extra_discount"));
|
|
||||||
// transaction.setPmtExtraAmount(rs.getDouble("pmt_extra_amount"));
|
|
||||||
// transaction.setManualDiscount(rs.getDouble("manual_discount"));
|
|
||||||
// transaction.setManualAmount(rs.getDouble("manual_amount"));
|
|
||||||
// transaction.setUsermbrDiscount(rs.getDouble("usermbr_discount"));
|
|
||||||
// transaction.setClientDiscount(rs.getDouble("client_discount"));
|
|
||||||
// transaction.setHoldVoid(rs.getString("hold_void"));
|
|
||||||
// transaction.setPayBasAmt(rs.getDouble("pay_bas_amt"));
|
|
||||||
// transaction.setPayDesc(rs.getString("pay_desc"));
|
|
||||||
// transaction.setPayCode(rs.getString("pay_code"));
|
|
||||||
// transaction.setCardNo(rs.getString("card_no"));
|
|
||||||
// transaction.setPayCurr(rs.getString("pay_curr"));
|
|
||||||
// transaction.setPayCurrAmt(rs.getDouble("pay_curr_amt"));
|
|
||||||
// transaction.setOnbehalfPaid(rs.getString("onbehalf_paid"));
|
|
||||||
// transaction.setOnbehalfLoc(rs.getString("onbehalf_loc"));
|
|
||||||
// transaction.setOldCardNo(rs.getString("old_card_no"));
|
|
||||||
// transaction.setTrxYear(rs.getInt("TRX_YEAR"));
|
|
||||||
// transaction.setTrxMonth(rs.getInt("TRX_MONTH"));
|
|
||||||
|
|
||||||
transactionDataList.add(transaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 清理环境
|
|
||||||
rs.close();
|
|
||||||
stmt.close();
|
|
||||||
conn.close();
|
|
||||||
} catch (SQLException | ClassNotFoundException e) {
|
|
||||||
// 处理异常
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
System.out.println("查询执行完成!");
|
|
||||||
return transactionDataList;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 示例:导出数据到CSV文件
|
|
||||||
private static void exportToCSV(ResultSet resultSet, String filePath) throws SQLException, IOException {
|
|
||||||
FileWriter writer = new FileWriter(filePath);
|
|
||||||
|
|
||||||
while (resultSet.next()) {
|
|
||||||
// 将结果写入CSV文件
|
|
||||||
// 这里需要根据实际情况将数据写入CSV文件
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -29,7 +29,6 @@ public class FileProperties {
|
|||||||
}
|
}
|
||||||
return linux;
|
return linux;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLinuxDomain(){
|
public String getLinuxDomain(){
|
||||||
String os = System.getProperty("os.name");
|
String os = System.getProperty("os.name");
|
||||||
if((!os.toLowerCase().startsWith("win") )&& (!os.toLowerCase().startsWith("mac"))) {
|
if((!os.toLowerCase().startsWith("win") )&& (!os.toLowerCase().startsWith("mac"))) {
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
package com.ai.da.common.config;
|
|
||||||
|
|
||||||
import io.minio.MinioClient;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Component
|
|
||||||
public class MinIoClientConfig {
|
|
||||||
@Value("${minio.endpoint}")
|
|
||||||
private String endpoint;
|
|
||||||
@Value("${minio.accessKey}")
|
|
||||||
private String accessKey;
|
|
||||||
@Value("${minio.secretKey}")
|
|
||||||
private String secretKey;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注入minio 客户端
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public MinioClient minioClient() {
|
|
||||||
|
|
||||||
return MinioClient.builder()
|
|
||||||
.endpoint(endpoint)
|
|
||||||
.credentials(accessKey, secretKey)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,385 +0,0 @@
|
|||||||
package com.ai.da.common.config;
|
|
||||||
|
|
||||||
import com.ai.da.common.utils.ExcelReader;
|
|
||||||
import com.ai.da.common.utils.MinioUtil;
|
|
||||||
import com.ai.da.common.utils.SendEmailUtil;
|
|
||||||
import com.ai.da.mapper.primary.*;
|
|
||||||
import com.ai.da.mapper.primary.entity.*;
|
|
||||||
import com.ai.da.mapper.secondary.AttributeRetrievalMapper;
|
|
||||||
import com.ai.da.model.enums.StyleEnum;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.DirectoryStream;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class MyTaskScheduler {
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void test() {
|
|
||||||
// clearMinio();
|
|
||||||
// addSystemFileStyle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private AccountMapper accountMapper;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private TrialOrderMapper trialOrderMapper;
|
|
||||||
|
|
||||||
// 定时任务,每十五天执行一次
|
|
||||||
// @Scheduled(cron = "0 0 0 ? * MON")
|
|
||||||
// @Scheduled(cron = "0 0 0 */15 * ?")
|
|
||||||
public void checkExpiry() {
|
|
||||||
// 检测正式用户是否快要过期
|
|
||||||
QueryWrapper<Account> qw = new QueryWrapper<>();
|
|
||||||
qw.lambda().eq(Account::getIsTrial, 0);
|
|
||||||
// qw.lambda().eq(Account::getId, 88);
|
|
||||||
List<Account> accountList = accountMapper.selectList(qw);
|
|
||||||
for (Account account : accountList) {
|
|
||||||
// 用户到期时间戳
|
|
||||||
Long timestamp = account.getValidEndTime(); // 替换为你的时间戳
|
|
||||||
|
|
||||||
if (null == timestamp) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// 获取当前时间戳
|
|
||||||
Long currentTimestamp = System.currentTimeMillis();
|
|
||||||
|
|
||||||
// 计算时间差(毫秒)
|
|
||||||
long timeDifference = currentTimestamp - timestamp;
|
|
||||||
|
|
||||||
if (timeDifference < 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 判断是否在30天以内(30天的毫秒数)
|
|
||||||
long thirtyDaysInMillis = 30L * 24 * 60 * 60 * 1000;
|
|
||||||
boolean within30Days = timeDifference <= thirtyDaysInMillis;
|
|
||||||
|
|
||||||
if (within30Days) {
|
|
||||||
// 发邮件
|
|
||||||
SendEmailUtil.sendWillBeExpiredEmail(account, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// @Scheduled(cron = "0 0 9 * * ?")
|
|
||||||
public void sendTrialOrderExcelToManagements() {
|
|
||||||
// 获取前一天日期
|
|
||||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
|
||||||
|
|
||||||
// 查询前一天的试用订单
|
|
||||||
QueryWrapper<TrialOrder> qw = new QueryWrapper<>();
|
|
||||||
qw.lambda().between(TrialOrder::getCreateTime, yesterday.atStartOfDay(), yesterday.atTime(23, 59, 59));
|
|
||||||
List<TrialOrder> trialOrders = trialOrderMapper.selectList(qw);
|
|
||||||
|
|
||||||
if (!trialOrders.isEmpty()) {
|
|
||||||
// 创建Excel工作簿
|
|
||||||
try (Workbook workbook = new XSSFWorkbook()) {
|
|
||||||
// 创建工作表
|
|
||||||
Sheet sheet = workbook.createSheet("Trial Orders");
|
|
||||||
// 创建标题行
|
|
||||||
Row headerRow = sheet.createRow(0);
|
|
||||||
headerRow.createCell(0).setCellValue("ID");
|
|
||||||
headerRow.createCell(1).setCellValue("Title");
|
|
||||||
headerRow.createCell(2).setCellValue("Surname");
|
|
||||||
headerRow.createCell(3).setCellValue("Given Name");
|
|
||||||
headerRow.createCell(4).setCellValue("Username");
|
|
||||||
headerRow.createCell(5).setCellValue("Email");
|
|
||||||
headerRow.createCell(6).setCellValue("Country");
|
|
||||||
headerRow.createCell(7).setCellValue("Occupation");
|
|
||||||
headerRow.createCell(8).setCellValue("Create Time");
|
|
||||||
headerRow.createCell(9).setCellValue("Update Time");
|
|
||||||
headerRow.createCell(10).setCellValue("Status");
|
|
||||||
|
|
||||||
// 填充数据
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
int rowNum = 1;
|
|
||||||
for (TrialOrder trialOrder : trialOrders) {
|
|
||||||
Row row = sheet.createRow(rowNum++);
|
|
||||||
row.createCell(0).setCellValue(trialOrder.getId());
|
|
||||||
row.createCell(1).setCellValue(trialOrder.getTitle());
|
|
||||||
row.createCell(2).setCellValue(trialOrder.getSurname());
|
|
||||||
row.createCell(3).setCellValue(trialOrder.getGivenName());
|
|
||||||
row.createCell(4).setCellValue(trialOrder.getUserName());
|
|
||||||
row.createCell(5).setCellValue(trialOrder.getEmail());
|
|
||||||
row.createCell(6).setCellValue(trialOrder.getCountry());
|
|
||||||
row.createCell(7).setCellValue(trialOrder.getOccupation());
|
|
||||||
row.createCell(8).setCellValue(trialOrder.getCreateTime().format(formatter));
|
|
||||||
row.createCell(9).setCellValue(trialOrder.getUpdateTime().format(formatter));
|
|
||||||
row.createCell(10).setCellValue(trialOrder.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 保存Excel文件
|
|
||||||
String fileName = "trialOrder-" + yesterday.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
|
|
||||||
try (FileOutputStream fileOut = new FileOutputStream(fileName)) {
|
|
||||||
workbook.write(fileOut);
|
|
||||||
SendEmailUtil.sendExcelEmail("1023316923@qq.com", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
|
||||||
SendEmailUtil.sendExcelEmail("calvinwong@aidlab.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
|
||||||
SendEmailUtil.sendExcelEmail("kaicpang.pang@connect.polyu.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
|
||||||
SendEmailUtil.sendExcelEmail("kimwong@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
SendEmailUtil.sendNoExcelEmail("1023316923@qq.com", null);
|
|
||||||
SendEmailUtil.sendNoExcelEmail("calvinwong@aidlab.hk", null);
|
|
||||||
SendEmailUtil.sendNoExcelEmail("kaicpang.pang@connect.polyu.hk", null);
|
|
||||||
SendEmailUtil.sendNoExcelEmail("kimwong@code-create.com.hk", null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private UserLikeGroupMapper userLikeGroupMapper;
|
|
||||||
@Resource
|
|
||||||
private UserLikeMapper userLikeMapper;
|
|
||||||
@Resource
|
|
||||||
private TDesignPythonOutfitMapper designPythonOutfitMapper;
|
|
||||||
@Resource
|
|
||||||
private TDesignPythonOutfitDetailMapper designPythonOutfitDetailMapper;
|
|
||||||
@Resource
|
|
||||||
private DesignItemMapper designItemMapper;
|
|
||||||
@Resource
|
|
||||||
private DesignItemDetailMapper designItemDetailMapper;
|
|
||||||
@Resource
|
|
||||||
private MinioUtil minioUtil;
|
|
||||||
public void clearMinio() {
|
|
||||||
// 获取当前所有history
|
|
||||||
QueryWrapper<UserLikeGroup> userLikeGroupQueryWrapper = new QueryWrapper<>();
|
|
||||||
List<UserLikeGroup> userLikeGroupList = userLikeGroupMapper.selectList(userLikeGroupQueryWrapper);
|
|
||||||
List<Long> userLikeGroupIdList = userLikeGroupList.stream().map(UserLikeGroup::getId).collect(Collectors.toList());
|
|
||||||
QueryWrapper<UserLike> userLikeQueryWrapper = new QueryWrapper<>();
|
|
||||||
userLikeQueryWrapper.lambda().in(UserLike::getUserLikeGroupId, userLikeGroupIdList);
|
|
||||||
// 所有喜欢的图片
|
|
||||||
List<UserLike> userLikes = userLikeMapper.selectList(userLikeQueryWrapper);
|
|
||||||
List<Long> designOutfitIdList = userLikes.stream().map(UserLike::getDesignOutfitId).collect(Collectors.toList());
|
|
||||||
QueryWrapper<TDesignPythonOutfit> designPythonOutfitQueryWrapper = new QueryWrapper<>();
|
|
||||||
designPythonOutfitQueryWrapper.lambda().notIn(TDesignPythonOutfit::getId, designOutfitIdList);
|
|
||||||
List<TDesignPythonOutfit> tDesignPythonOutfits = designPythonOutfitMapper.selectList(designPythonOutfitQueryWrapper);
|
|
||||||
// int i = 0;
|
|
||||||
// for (TDesignPythonOutfit tDesignPythonOutfit : tDesignPythonOutfits) {
|
|
||||||
// String designUrl = tDesignPythonOutfit.getDesignUrl();
|
|
||||||
// if (StringUtils.isNotBlank(designUrl)) {
|
|
||||||
// minioUtil.deleteObject(designUrl);
|
|
||||||
// i ++;
|
|
||||||
// }
|
|
||||||
// QueryWrapper<TDesignPythonOutfitDetail> designPythonOutfitDetailQueryWrapper = new QueryWrapper<>();
|
|
||||||
// designPythonOutfitDetailQueryWrapper.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, tDesignPythonOutfit.getId());
|
|
||||||
// List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(designPythonOutfitDetailQueryWrapper);
|
|
||||||
// for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
|
||||||
// if (!tDesignPythonOutfitDetail.getImageCategory().equals("body")) {
|
|
||||||
// if (StringUtils.isNotBlank(tDesignPythonOutfitDetail.getImageUrl())) {
|
|
||||||
// minioUtil.deleteObject(tDesignPythonOutfitDetail.getImageUrl());
|
|
||||||
// i ++;
|
|
||||||
// }
|
|
||||||
// if (StringUtils.isNotBlank(tDesignPythonOutfitDetail.getMaskUrl())) {
|
|
||||||
// minioUtil.deleteObject(tDesignPythonOutfitDetail.getMaskUrl());
|
|
||||||
// i ++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
System.out.println("i");
|
|
||||||
// List<Long> designItemIdList = userLikes.stream().map(UserLike::getDesignItemId).collect(Collectors.toList());
|
|
||||||
// QueryWrapper<DesignItem> designItemQueryWrapper = new QueryWrapper<>();
|
|
||||||
// designItemQueryWrapper.lambda().in(DesignItem::getId,designItemIdList);
|
|
||||||
// List<DesignItem> designItems = designItemMapper.selectList(designItemQueryWrapper);
|
|
||||||
// for (DesignItem designItem : designItems) {
|
|
||||||
// QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
|
||||||
// designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItem.getId());
|
|
||||||
// List<DesignItemDetail> designItemDetails = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
|
||||||
// for (DesignItemDetail designItemDetail : designItemDetails) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private AttributeRetrievalMapper attributeRetrievalMapper;
|
|
||||||
|
|
||||||
public void addSystemFileStyle() {
|
|
||||||
// ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// String[] filePaths = {
|
|
||||||
// "C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens bottom style output.xlsx",
|
|
||||||
// "C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens outer style output.xlsx",
|
|
||||||
// "C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens top style output.xlsx"
|
|
||||||
//// "/workspace/shb/Mens_bottom_style_output.xlsx",
|
|
||||||
//// "/workspace/shb/Mens_outer_style_output.xlsx",
|
|
||||||
//// "/workspace/shb/Mens_top_style_output.xlsx"
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// for (String filePath : filePaths) {
|
|
||||||
//// executorService.submit(() -> processExcelFile(filePath));
|
|
||||||
// processExcelFile(filePath);
|
|
||||||
// }
|
|
||||||
// }catch (Exception e) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// } finally {
|
|
||||||
// executorService.shutdown();
|
|
||||||
// try {
|
|
||||||
// if (!executorService.awaitTermination(60, TimeUnit.MINUTES)) {
|
|
||||||
// executorService.shutdownNow();
|
|
||||||
// }
|
|
||||||
// } catch (InterruptedException e) {
|
|
||||||
// executorService.shutdownNow();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
String[] filePaths = {
|
|
||||||
"C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens bottom style output.xlsx",
|
|
||||||
"C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens outer style output.xlsx",
|
|
||||||
"C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens top style output.xlsx"
|
|
||||||
// "/workspace/shb/Mens_bottom_style_output.xlsx",
|
|
||||||
// "/workspace/shb/Mens_outer_style_output.xlsx",
|
|
||||||
// "/workspace/shb/Mens_top_style_output.xlsx"
|
|
||||||
};
|
|
||||||
|
|
||||||
for (String filePath : filePaths) {
|
|
||||||
// executorService.submit(() -> processExcelFile(filePath));
|
|
||||||
processExcelFile(filePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processExcelFile(String filePath) {
|
|
||||||
System.out.println("线程开始");
|
|
||||||
try {
|
|
||||||
List<List<String>> excelData = ExcelReader.readExcel(filePath);
|
|
||||||
String tableName = getTableNameFromFilePath(filePath);
|
|
||||||
String prefix = getPrefixFromFilePath(filePath);
|
|
||||||
|
|
||||||
for (List<String> columnData : excelData) {
|
|
||||||
String style = columnData.get(0);
|
|
||||||
for (int i = 1; i < columnData.size(); i++) {
|
|
||||||
String fileName = columnData.get(i);
|
|
||||||
if (StringUtils.isBlank(fileName)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ("X".equals(style)) {
|
|
||||||
attributeRetrievalMapper.updateStyleByFileName("X", prefix + fileName, tableName);
|
|
||||||
System.out.println(fileName);
|
|
||||||
} else {
|
|
||||||
// if (style.equals("Y2K 风")) {
|
|
||||||
// StyleEnum.COUNTRY_STYLE
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }else if (style.equals("")) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
attributeRetrievalMapper.updateStyleByFileName(style, prefix + fileName, tableName);
|
|
||||||
System.out.println(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTableNameFromFilePath(String filePath) {
|
|
||||||
if (filePath.contains("Blouse")) {
|
|
||||||
return "female_top";
|
|
||||||
} else if (filePath.contains("Dress")) {
|
|
||||||
return "female_dress";
|
|
||||||
} else if (filePath.contains("Outerwear")) {
|
|
||||||
return "female_outwear";
|
|
||||||
} else if (filePath.contains("Skirt")) {
|
|
||||||
return "female_skirt";
|
|
||||||
} else if (filePath.contains("Trousers")) {
|
|
||||||
return "female_pants";
|
|
||||||
} else if (filePath.contains("bottom")) {
|
|
||||||
return "male_bottom";
|
|
||||||
} else if (filePath.contains("outer")) {
|
|
||||||
return "male_outwear";
|
|
||||||
} else if (filePath.contains("top")) {
|
|
||||||
return "male_top";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getPrefixFromFilePath(String filePath) {
|
|
||||||
if (filePath.contains("Blouse")) {
|
|
||||||
return "blouse/";
|
|
||||||
} else if (filePath.contains("Dress")) {
|
|
||||||
return "dress/";
|
|
||||||
} else if (filePath.contains("Outerwear")) {
|
|
||||||
return "outwear/";
|
|
||||||
} else if (filePath.contains("Skirt")) {
|
|
||||||
return "skirt/";
|
|
||||||
} else if (filePath.contains("Trousers")) {
|
|
||||||
return "trousers/";
|
|
||||||
} else if (filePath.contains("bottom")) {
|
|
||||||
return "bottom/";
|
|
||||||
} else if (filePath.contains("outer")) {
|
|
||||||
return "outer/";
|
|
||||||
} else if (filePath.contains("top")) {
|
|
||||||
return "top/";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// public static List<String> getFileNames(String directoryPath) {
|
|
||||||
// List<String> fileNames = new ArrayList<>();
|
|
||||||
// Path path = Paths.get(directoryPath);
|
|
||||||
//
|
|
||||||
// try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
|
|
||||||
// for (Path entry : stream) {
|
|
||||||
// if (Files.isRegularFile(entry)) {
|
|
||||||
// fileNames.add(entry.getFileName().toString());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// System.err.println("Error reading directory: " + e.getMessage());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return fileNames;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package com.ai.da.common.config;
|
|
||||||
|
|
||||||
import com.paypal.core.PayPalEnvironment;
|
|
||||||
import com.paypal.core.PayPalHttpClient;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.PropertySource;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@Slf4j
|
|
||||||
@PropertySource("classpath:payment.properties")
|
|
||||||
public class PayPalClient {
|
|
||||||
|
|
||||||
public PayPalHttpClient client(String mode, String clientId, String clientSecret) {
|
|
||||||
log.info("mode={}, clientId={}, clientSecret={}", mode, clientId, clientSecret);
|
|
||||||
PayPalEnvironment environment = mode.equals("live") ? new PayPalEnvironment.Live(clientId, clientSecret) : new PayPalEnvironment.Sandbox(clientId, clientSecret);
|
|
||||||
return new PayPalHttpClient(environment);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param jo
|
|
||||||
* @param pre
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
/*public String prettyPrint(JSONObject jo, String pre) {
|
|
||||||
Iterator<?> keys = jo.keys();
|
|
||||||
StringBuilder pretty = new StringBuilder();
|
|
||||||
while (keys.hasNext()) {
|
|
||||||
String key = (String) keys.next();
|
|
||||||
pretty.append(String.format("%s%s: ", pre, StringUtils.capitalize(key)));
|
|
||||||
if (jo.get(key) instanceof JSONObject) {
|
|
||||||
pretty.append(prettyPrint(jo.getJSONObject(key), pre + "\t"));
|
|
||||||
} else if (jo.get(key) instanceof JSONArray) {
|
|
||||||
int sno = 1;
|
|
||||||
for (Object jsonObject : jo.getJSONArray(key)) {
|
|
||||||
pretty.append(String.format("\n%s\t%d:\n", pre, sno++));
|
|
||||||
pretty.append(prettyPrint((JSONObject) jsonObject, pre + "\t\t"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pretty.append(String.format("%s\n", jo.getString(key)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pretty.toString();
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package com.ai.da.common.config;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
|
|
||||||
import com.baomidou.mybatisplus.core.config.GlobalConfig;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
|
||||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
|
||||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
|
||||||
import org.mybatis.spring.SqlSessionTemplate;
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@MapperScan(basePackages = "com.ai.da.mapper.primary", sqlSessionFactoryRef = "primarySqlSessionFactory")
|
|
||||||
public class PrimaryDataSourceConfig {
|
|
||||||
@Autowired
|
|
||||||
private MybatisPlusProperties mybatisPlusProperties;
|
|
||||||
|
|
||||||
@Primary
|
|
||||||
@Bean(name = "primaryDataSource")
|
|
||||||
@ConfigurationProperties(prefix = "spring.datasource.primary")
|
|
||||||
public DataSource dataSource() {
|
|
||||||
return DataSourceBuilder.create().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Primary
|
|
||||||
@Bean(name = "primarySqlSessionFactory")
|
|
||||||
public SqlSessionFactory sqlSessionFactory(
|
|
||||||
@Qualifier("primaryDataSource") DataSource dataSource,
|
|
||||||
ApplicationContext applicationContext,
|
|
||||||
@Qualifier("primaryMybatisPlusInterceptor") MybatisPlusInterceptor mybatisPlusInterceptor) throws Exception {
|
|
||||||
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
|
|
||||||
bean.setDataSource(dataSource);
|
|
||||||
bean.setMapperLocations(applicationContext.getResources("classpath:mapper/primary/*.xml"));
|
|
||||||
// 设置 MyBatis Plus 全局配置
|
|
||||||
GlobalConfig globalConfig = this.mybatisPlusProperties.getGlobalConfig();
|
|
||||||
if (globalConfig != null) {
|
|
||||||
bean.setGlobalConfig(globalConfig);
|
|
||||||
}
|
|
||||||
bean.setPlugins(mybatisPlusInterceptor);
|
|
||||||
return bean.getObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Primary
|
|
||||||
@Bean(name = "primarySqlSessionTemplate")
|
|
||||||
public SqlSessionTemplate sqlSessionTemplate(
|
|
||||||
@Qualifier("primarySqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
|
|
||||||
return new SqlSessionTemplate(sqlSessionFactory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package com.ai.da.common.config;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
|
||||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
|
||||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class RedisConfig {
|
|
||||||
@Bean(name = "redisTemplate")
|
|
||||||
public RedisTemplate<String, Object> getRedisTemplate(RedisConnectionFactory factory) {
|
|
||||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
|
||||||
redisTemplate.setConnectionFactory(factory);
|
|
||||||
|
|
||||||
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
|
||||||
|
|
||||||
redisTemplate.setKeySerializer(stringRedisSerializer); // key的序列化类型
|
|
||||||
|
|
||||||
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
|
||||||
// 方法过期,改为下面代码
|
|
||||||
// objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
|
||||||
objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance,
|
|
||||||
ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
|
||||||
jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
|
|
||||||
jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
|
|
||||||
|
|
||||||
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); // value的序列化类型
|
|
||||||
redisTemplate.setHashKeySerializer(stringRedisSerializer);
|
|
||||||
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
|
|
||||||
redisTemplate.afterPropertiesSet();
|
|
||||||
return redisTemplate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.ai.da.common.config;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
|
||||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
|
||||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
|
||||||
import org.mybatis.spring.SqlSessionTemplate;
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@MapperScan(basePackages = "com.ai.da.mapper.secondary", sqlSessionFactoryRef = "secondarySqlSessionFactory")
|
|
||||||
public class SecondaryDataSourceConfig {
|
|
||||||
|
|
||||||
@Bean(name = "secondaryDataSource")
|
|
||||||
@ConfigurationProperties(prefix = "spring.datasource.secondary")
|
|
||||||
public DataSource dataSource() {
|
|
||||||
return DataSourceBuilder.create().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean(name = "secondarySqlSessionFactory")
|
|
||||||
public SqlSessionFactory sqlSessionFactory(
|
|
||||||
@Qualifier("secondaryDataSource") DataSource dataSource,
|
|
||||||
ApplicationContext applicationContext,
|
|
||||||
@Qualifier("secondaryMybatisPlusInterceptor") MybatisPlusInterceptor mybatisPlusInterceptor) throws Exception {
|
|
||||||
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
|
|
||||||
// SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
|
|
||||||
bean.setDataSource(dataSource);
|
|
||||||
bean.setMapperLocations(applicationContext.getResources("classpath:mapper/secondary/*.xml"));
|
|
||||||
bean.setPlugins(mybatisPlusInterceptor);
|
|
||||||
return bean.getObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean(name = "secondarySqlSessionTemplate")
|
|
||||||
public SqlSessionTemplate sqlSessionTemplate(
|
|
||||||
@Qualifier("secondarySqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
|
|
||||||
return new SqlSessionTemplate(sqlSessionFactory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -5,22 +5,13 @@ 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.WebMvcConfigurerAdapter;
|
|
||||||
|
|
||||||
import javax.validation.Validation;
|
import javax.validation.Validation;
|
||||||
import javax.validation.Validator;
|
import javax.validation.Validator;
|
||||||
import javax.validation.ValidatorFactory;
|
import javax.validation.ValidatorFactory;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class WebConfig extends WebMvcConfigurerAdapter {
|
public class WebConfig {
|
||||||
|
|
||||||
static final String ORIGINS[] = new String[]{"GET", "POST", "PUT", "DELETE"};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
|
||||||
registry.addMapping("/**").allowedOrigins("*").allowCredentials(true).allowedMethods(ORIGINS).maxAge(3600);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Validator validator() {
|
public Validator validator() {
|
||||||
|
|||||||
@@ -1,19 +1,8 @@
|
|||||||
package com.ai.da.common.config.exception;
|
package com.ai.da.common.config.exception;
|
||||||
|
|
||||||
import com.ai.da.common.context.UserContext;
|
|
||||||
import com.ai.da.common.response.ResultEnum;
|
import com.ai.da.common.response.ResultEnum;
|
||||||
import com.ai.da.model.enums.Language;
|
|
||||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.PropertyResourceBundle;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: dangweijian
|
* @author: dangweijian
|
||||||
* @description: 业务异常
|
* @description: 业务异常
|
||||||
@@ -26,48 +15,14 @@ public class BusinessException extends RuntimeException {
|
|||||||
private String msg;
|
private String msg;
|
||||||
|
|
||||||
public BusinessException(ResultEnum resultEnum){
|
public BusinessException(ResultEnum resultEnum){
|
||||||
|
super(resultEnum.getMsg());
|
||||||
this.code = resultEnum.getCode();
|
this.code = resultEnum.getCode();
|
||||||
this.msg = getMessageFromResource(resultEnum.getMsg(), getUserLocale());
|
this.msg = resultEnum.getMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BusinessException(String msg) {
|
public BusinessException(String msg) {
|
||||||
|
super(msg);
|
||||||
this.code = ResultEnum.FAIL.getCode();
|
this.code = ResultEnum.FAIL.getCode();
|
||||||
this.msg = getMessageFromResource(msg, getUserLocale());
|
this.msg = msg;
|
||||||
}
|
|
||||||
|
|
||||||
public BusinessException(String msg, Integer code) {
|
|
||||||
this.code = code;
|
|
||||||
this.msg = getMessageFromResource(msg, getUserLocale());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BusinessException(Throwable cause) {
|
|
||||||
this.code = ResultEnum.FAIL.getCode();
|
|
||||||
this.msg = getMessageFromResource(cause.getMessage(), getUserLocale());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Locale getUserLocale() {
|
|
||||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
|
||||||
if (Objects.isNull(userInfo)) {
|
|
||||||
return new Locale("en");
|
|
||||||
}
|
|
||||||
return new Locale(Language.valueOf(userInfo.getLanguage()).getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getMessageFromResource(String msg) {
|
|
||||||
return getMessageFromResource(msg, getUserLocale());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getMessageFromResource(String msg, Locale userLocale) {
|
|
||||||
try (InputStream inputStream = BusinessException.class.getClassLoader().getResourceAsStream("messages_" + userLocale.getLanguage() + ".properties")) {
|
|
||||||
if (inputStream != null) {
|
|
||||||
ResourceBundle bundle = new PropertyResourceBundle(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
|
||||||
if (bundle.containsKey(msg)) {
|
|
||||||
return bundle.getString(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return msg; // 如果找不到对应的资源文件,返回原始的消息
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,6 @@ public class ExceptionCatch {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理参数校验异常
|
* 处理参数校验异常
|
||||||
*
|
|
||||||
* @param e
|
* @param e
|
||||||
* @return ResponseData
|
* @return ResponseData
|
||||||
*/
|
*/
|
||||||
@@ -64,22 +63,19 @@ public class ExceptionCatch {
|
|||||||
@ExceptionHandler(BindException.class)
|
@ExceptionHandler(BindException.class)
|
||||||
public Response<String> bindExceptionHandler(BindException e) {
|
public Response<String> bindExceptionHandler(BindException e) {
|
||||||
log.error("参数错误bind:{}", e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
|
log.error("参数错误bind:{}", e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
|
||||||
BusinessException businessException = new BusinessException(e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
|
return Response.fail(ResultEnum.FAIL.getCode(), e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
|
||||||
return Response.error(businessException.getCode(), businessException.getMsg());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理参数校验异常
|
* 处理参数校验异常
|
||||||
*
|
|
||||||
* @param e
|
* @param e
|
||||||
* @return ResponseData
|
* @return ResponseData
|
||||||
*/
|
*/
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||||
public Response<String> handleValidationException(MethodArgumentNotValidException e) {
|
public Response<String> methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) {
|
||||||
log.error("参数错误bind:{}", e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
|
log.error("参数错误bind:{}", e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
|
||||||
BusinessException businessException = new BusinessException(e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
|
return Response.fail(ResultEnum.FAIL.getCode(), e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
|
||||||
return Response.error(businessException.getCode(), businessException.getMsg());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始化,不可预知异常自定义错误编码
|
//初始化,不可预知异常自定义错误编码
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.ai.da.common.config;
|
package com.ai.da.common.config.mybatis.plus;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.DbType;
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
@@ -8,17 +8,11 @@ import org.springframework.context.annotation.Bean;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@MapperScan("com.ai.da.mapper")
|
||||||
public class MybatisPlusConfig {
|
public class MybatisPlusConfig {
|
||||||
|
|
||||||
@Bean(name = "primaryMybatisPlusInterceptor")
|
@Bean
|
||||||
public MybatisPlusInterceptor primaryMybatisPlusInterceptor() {
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
|
||||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
|
||||||
return interceptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean(name = "secondaryMybatisPlusInterceptor")
|
|
||||||
public MybatisPlusInterceptor secondaryMybatisPlusInterceptor() {
|
|
||||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||||
return interceptor;
|
return interceptor;
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.ai.da.common.constant;
|
|
||||||
|
|
||||||
public class AlipayHKConstant {
|
|
||||||
|
|
||||||
// 服务名
|
|
||||||
public static final String CREATE_ORDER = "create_order";
|
|
||||||
public static final String ORDER_DETAILS = "order_details";
|
|
||||||
public static final String TRANSACTION_DETAILS = "transaction_details";
|
|
||||||
public static final String GET_FILE = "get_file";
|
|
||||||
public static final String CREATE_AUTO_DEBIT = "create_auto_debit";
|
|
||||||
public static final String REFRESH_TRANSACTION_STATUS = "refresh_transaction_status";
|
|
||||||
public static final String REFUND_TRANSACTION = "refund_transaction";
|
|
||||||
|
|
||||||
// 订单状态
|
|
||||||
public static final String STATUS_NEW = "new";
|
|
||||||
public static final String STATUS_WAIT = "wait";
|
|
||||||
public static final String STATUS_PAID = "paid";
|
|
||||||
public static final String STATUS_EXPIRED = "expired";
|
|
||||||
public static final String STATUS_LIQUIDATED = "liquidated";
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package com.ai.da.common.constant;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CommonConstant {
|
|
||||||
// 单位 秒 10分钟过期
|
|
||||||
// public static final Long TASK_EXPIRE_TIME = 24 * 60 * 60L;
|
|
||||||
public static final Long TASK_EXPIRE_TIME = 10 * 60L;
|
|
||||||
// 单位 秒 两天过期
|
|
||||||
public static final Long CREDITS_EXPIRE_TIME = 2 * 24 * 60 * 60L;
|
|
||||||
// 单位 分钟
|
|
||||||
public static final Integer MINIO_IMAGE_EXPIRE_TIME = 24 * 60;
|
|
||||||
// 单位 秒 一天过期 in redis
|
|
||||||
public static final Long GENERATE_RESULT_EXPIRE_TIME = 24 * 60 * 60L;
|
|
||||||
|
|
||||||
public static class Numbers{
|
|
||||||
public static final Integer NUMBER_10 = 10;
|
|
||||||
public static final Integer NUMBER_1000 = 1000;
|
|
||||||
public static final Integer NUMBER_10080 = 10080;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String GENERATE_PATH = "/api/generate_image";
|
|
||||||
|
|
||||||
public static final String GENERATE_SINGLE_LOGO = "/api/generate_single_logo";
|
|
||||||
|
|
||||||
public static final String GENERATE_SLOGAN = "/api/slogan";
|
|
||||||
|
|
||||||
public static final String GENERATE_CANCEL = "/api/generate_cancel/";
|
|
||||||
|
|
||||||
public static final String GENERATE_LOGO_SINGLE_CANCEL = "/api/generate_single_logo_cancel/";
|
|
||||||
|
|
||||||
public static final String PYTHON_PORT_9996 = "9996";
|
|
||||||
|
|
||||||
public static final String PYTHON_PORT_9997 = "9997";
|
|
||||||
|
|
||||||
public static final List<String> AGES_EN = Arrays.asList("Below 20", "20-30", "30-40", "40+");
|
|
||||||
|
|
||||||
public static final List<String> AGES_CN = Arrays.asList("20岁以下", "20-30岁", "30-40岁", "40+岁");
|
|
||||||
public static final List<String> IF_HELPFUL_EN = Arrays.asList("Easy to learn and use", "Easy to get trend information",
|
|
||||||
"Lots of creative design proposals","The AIGC functions for moodboard is helpful","The AIGC functions for design sketches is helpful",
|
|
||||||
"Easy to select the right color","The Chatbot function is helpful","The print position function is helpful",
|
|
||||||
"The drawing function is helpful","The export function is useful","Easy to edit the design","Others");
|
|
||||||
|
|
||||||
public static final List<String> IF_HELPFUL_CN = Arrays.asList("易于学习和使用", "容易获取趋势信息",
|
|
||||||
"提供大量创意设计方案","AIGC功能对灵感板有帮助","AIGC功能对设计草图有帮助",
|
|
||||||
"容易选择合适的颜色","聊天机器人功能有帮助","打印位置功能有帮助",
|
|
||||||
"绘图功能有帮助","导出功能有用","设计编辑简单","其他");
|
|
||||||
|
|
||||||
public static final List<String> IF_IMPROVE_EN = Arrays.asList("Proposed designs are boring, need more interesting designs",
|
|
||||||
"Difficult to make changes on design","Only 2D output, no 3D results","Difficult to apply keywords for AIGC generation",
|
|
||||||
"Clothing is not in the right proportion","Not compatible with pattern making solutions","Improved user interface for better navigation",
|
|
||||||
"Lack of responsive customer support","Insufficient tutorial or guidance for new users","Limited personalization options for designs","Others");
|
|
||||||
|
|
||||||
public static final List<String> IF_IMPROVE_CN = Arrays.asList("提供的设计很无聊,需要更多有趣的设计",
|
|
||||||
"设计修改困难","只有2D输出,没有3D结果","难以选择合适的关键词应用于AIGC生成",
|
|
||||||
"服装比例不正确","与打版解决方案不兼容","改进用户界面以便更好导航",
|
|
||||||
"客户支持响应不及时","对新用户的教程或指导不足","设计个性化选项有限","其他");
|
|
||||||
|
|
||||||
public static final List<String> IS_SUBSCRIBE = Arrays.asList("yes", "no");
|
|
||||||
|
|
||||||
// public static final String DEFAULT_AVATAR = "aida-users/87/avatar/default.jpg";
|
|
||||||
public static final String DEFAULT_AVATAR = "aida-users/87/avatar/default.png";
|
|
||||||
|
|
||||||
/* 截止至2024/08/26,在Code-Create DB中pmr_users表中最大的用户id */
|
|
||||||
public static final Long MAXIMUM_USER_ID = 704L;
|
|
||||||
// public static final Long MAXIMUM_USER_ID = 225L;
|
|
||||||
|
|
||||||
// 激活更改邮箱 链接有效期 毫秒 3天
|
|
||||||
public static final Long CHANGE_MAILBOX_LINK_VALIDITY = 259200000L;
|
|
||||||
|
|
||||||
public static final String RCA_WORKSHOP_TAG = "#RCAworkshop_2024";
|
|
||||||
|
|
||||||
public static final String PORTFOLIO_DELETED_EN = "Portfolio has been deleted";
|
|
||||||
|
|
||||||
public static final String PORTFOLIO_DELETED_CN = "作品已删除";
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
package com.ai.da.common.constant;
|
|
||||||
|
|
||||||
public class PayPalCheckoutConstant {
|
|
||||||
|
|
||||||
public static final String CAPTURE = "CAPTURE";
|
|
||||||
/**
|
|
||||||
* 该标签将覆盖PayPal网站上PayPal帐户中的公司名称
|
|
||||||
*/
|
|
||||||
public static final String BRANDNAME = "AIDA";
|
|
||||||
/**
|
|
||||||
* LOGIN。当客户单击PayPal Checkout时,客户将被重定向到页面以登录PayPal并批准付款。
|
|
||||||
* BILLING。当客户单击PayPal Checkout时,客户将被重定向到一个页面,以输入信用卡或借记卡以及完成购买所需的其他相关账单信息
|
|
||||||
* NO_PREFERENCE。当客户单击“ PayPal Checkout”时,将根据其先前的交互方式将其重定向到页面以登录PayPal并批准付款,或重定向至页面以输入信用卡或借记卡以及完成购买所需的其他相关账单信息使用PayPal。
|
|
||||||
* 默认值:NO_PREFERENCE
|
|
||||||
*/
|
|
||||||
public static final String LANDINGPAGE = "NO_PREFERENCE";
|
|
||||||
/**
|
|
||||||
* CONTINUE。将客户重定向到PayPal付款页面后,将出现“ 继续”按钮。当结帐流程启动时最终金额未知时,请使用此选项,并且您想将客户重定向到商家页面而不处理付款。
|
|
||||||
* PAY_NOW。将客户重定向到PayPal付款页面后,出现“ 立即付款”按钮。当启动结帐时知道最终金额并且您要在客户单击“ 立即付款”时立即处理付款时,请使用此选项。
|
|
||||||
*/
|
|
||||||
public static final String USERACTION = "PAY_NOW";
|
|
||||||
/**
|
|
||||||
* GET_FROM_FILE。使用贝宝网站上客户提供的送货地址。
|
|
||||||
* NO_SHIPPING。从PayPal网站编辑送货地址。推荐用于数字商品
|
|
||||||
* SET_PROVIDED_ADDRESS。使用商家提供的地址。客户无法在PayPal网站上更改此地址
|
|
||||||
*/
|
|
||||||
// public static final String SHIPPINGPREFERENCE = "SET_PROVIDED_ADDRESS";
|
|
||||||
public static final String SHIPPINGPREFERENCE = "NO_SHIPPING";
|
|
||||||
/**
|
|
||||||
* 交易异常
|
|
||||||
*/
|
|
||||||
public static final String FAILURE = "failure";
|
|
||||||
/**
|
|
||||||
* 交易成功
|
|
||||||
*/
|
|
||||||
public static final String SUCCESS = "success";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ipn回调。支付成功
|
|
||||||
*/
|
|
||||||
public static final String PAYMENT_STATUS_COMPLETED = "Completed";
|
|
||||||
/**
|
|
||||||
* ipn回调。退款成功
|
|
||||||
*/
|
|
||||||
public static final String PAYMENT_STATUS_REFUNDED = "Refunded";
|
|
||||||
/**
|
|
||||||
* ipn回调。待定
|
|
||||||
*/
|
|
||||||
public static final String PAYMENT_STATUS_PENDING = "Pending";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ipn回调,付款因退款或其他类型的冲销而被冲销。资金已从您的帐户余额中删除,并退还给买方
|
|
||||||
*/
|
|
||||||
public static final String PAYMENT_STATUS_REVERSED = "Reversed";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ipn回调, 撤销已被取消。例如,您赢得了与客户的纠纷,并且撤回的交易资金已退还给您
|
|
||||||
*/
|
|
||||||
public static final String PAYMENT_STATUS_CANCELED_REVERSAL = "Canceled_Reversal";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ipn回调,付款被拒绝
|
|
||||||
*/
|
|
||||||
public static final String PAYMENT_STATUS_DENIED = "Denied";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ipn回调, 此授权已过期,无法捕获
|
|
||||||
*/
|
|
||||||
public static final String PAYMENT_STATUS_EXPIRED = "Expired";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ipn回调, 德国的ELV付款是通过Express Checkout进行的
|
|
||||||
*/
|
|
||||||
public static final String PAYMENT_STATUS_CREATED = "Created";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ipn回调, 付款失败。仅当付款是通过您客户的银行帐户进行的。
|
|
||||||
*/
|
|
||||||
public static final String PAYMENT_STATUS_FAILED = "Failed";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ipn回调,付款已被接受
|
|
||||||
*/
|
|
||||||
public static final String PAYMENT_STATUS_PROCESSED = "Processed";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ipn回调,此授权已失效
|
|
||||||
*/
|
|
||||||
public static final String PAYMENT_STATUS_VOIDED = "Voided";
|
|
||||||
|
|
||||||
//订单状态
|
|
||||||
/**
|
|
||||||
* 1、支付完成;捕获的付款的资金已记入收款人的PayPal帐户
|
|
||||||
* 2、退款完成;该交易的资金已记入客户的帐户
|
|
||||||
*/
|
|
||||||
public static final String STATE_COMPLETED = "COMPLETED";
|
|
||||||
/**
|
|
||||||
* 部分退款;少于所捕获付款金额的金额已部分退还给付款人。
|
|
||||||
*/
|
|
||||||
public static final String STATE_PARTIALLY_REFUNDED = "PARTIALLY_REFUNDED";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 1、支付待定;捕获的付款资金尚未记入收款人的PayPal帐户。有关更多信息请参见status.details。
|
|
||||||
* 2、退款待定;有关更多信息,请参见status_details.reason。
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* 支付待定:
|
|
||||||
* capture_status_details
|
|
||||||
* reason 枚举
|
|
||||||
* 捕获的付款状态为PENDING或DENIED的原因。可能的值为:
|
|
||||||
* BUYER_COMPLAINT。付款人与贝宝(PayPal)对此捕获的付款提出了争议。
|
|
||||||
* CHARGEBACK。响应于付款人与用于支付此已捕获付款的金融工具的发行人对此已捕获的付款提出异议,已收回的资金被撤回。
|
|
||||||
* ECHECK。由尚未结清的电子支票支付的付款人。
|
|
||||||
* INTERNATIONAL_WITHDRAWAL。访问您的在线帐户。在您的“帐户概览”中,接受并拒绝此笔付款。
|
|
||||||
* OTHER。无法提供其他特定原因。有关此笔付款的更多信息,请在线访问您的帐户或联系PayPal。
|
|
||||||
* PENDING_REVIEW。捕获的付款正在等待人工审核。
|
|
||||||
*(手动收取)RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION。收款人尚未为其帐户设置适当的接收首选项。有关如何接受或拒绝此付款的更多信息,请在线访问您的帐户。通常在某些情况下提供此原因,例如,当所捕获付款的货币与收款人的主要持有货币不同时。
|
|
||||||
* REFUNDED。收回的资金已退还。
|
|
||||||
* TRANSACTION_APPROVED_AWAITING_FUNDING。付款人必须将这笔付款的资金汇出。通常,此代码适用于手动EFT。
|
|
||||||
* UNILATERAL。收款人没有PayPal帐户。
|
|
||||||
* VERIFICATION_REQUIRED。收款人的PayPal帐户未通过验证。
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* 退款待定
|
|
||||||
* 退款具有“PENDING”或“FAILED”状态的原因。 可能的值为:
|
|
||||||
* ECHECK。客户的帐户通过尚未结清的eCheck进行注资。
|
|
||||||
*/
|
|
||||||
public static final String STATE_PENDING = "PENDING";
|
|
||||||
/**
|
|
||||||
* 退款;大于或等于此捕获的付款金额的金额已退还给付款人
|
|
||||||
*/
|
|
||||||
public static final String STATE_REFUNDED = "REFUNDED";
|
|
||||||
/**
|
|
||||||
* 支付拒绝
|
|
||||||
*/
|
|
||||||
public static final String STATE_DENIED = "DENIED";
|
|
||||||
/**
|
|
||||||
* 退款失败
|
|
||||||
*/
|
|
||||||
public static final String STATE_FAILED = "FAILED";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 争议状态
|
|
||||||
*/
|
|
||||||
public static final String BUYER_COMPLAINT = "BUYER_COMPLAINT";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 沙箱环境请求网关地址
|
|
||||||
*/
|
|
||||||
public static final String SANDBOX = "https://api.sandbox.paypal.com";
|
|
||||||
/**
|
|
||||||
* 生产环境请求网关地址
|
|
||||||
*/
|
|
||||||
public static final String LIVE = "https://api.paypal.com";
|
|
||||||
/**
|
|
||||||
* 添加物流信息请求路径
|
|
||||||
*/
|
|
||||||
public static final String ADD_TRACK_URL = "/v1/shipping/trackers-batch";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改物流信息请求路径
|
|
||||||
*/
|
|
||||||
public static final String UPDATE_TRACK_URL = "/v1/shipping/trackers/";
|
|
||||||
|
|
||||||
public final static String CMD_NOTIFY_VALIDATE = "_notify-validate";
|
|
||||||
|
|
||||||
public final static String PAYPAL_TOKEN_KEY = "PayPalAccessToken";
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -8,7 +8,6 @@ public class UserContext {
|
|||||||
public static AuthPrincipalVo getUserHolder() {
|
public static AuthPrincipalVo getUserHolder() {
|
||||||
return userHolder.get();
|
return userHolder.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void delete() {
|
public static void delete() {
|
||||||
userHolder.remove();
|
userHolder.remove();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
package com.ai.da.common.enums;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum AliPayTradeStateEnum {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付成功
|
|
||||||
*/
|
|
||||||
SUCCESS("TRADE_SUCCESS"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 未支付
|
|
||||||
*/
|
|
||||||
NOTPAY("WAIT_BUYER_PAY"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已关闭
|
|
||||||
*/
|
|
||||||
CLOSED("TRADE_CLOSED"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款成功
|
|
||||||
*/
|
|
||||||
REFUND_SUCCESS("REFUND_SUCCESS"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款失败
|
|
||||||
*/
|
|
||||||
REFUND_ERROR("REFUND_ERROR");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类型
|
|
||||||
*/
|
|
||||||
private final String type;
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.ai.da.common.enums;
|
package com.ai.da.common.enums;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,27 +27,7 @@ public enum CollectionLevel2TypeEnum {
|
|||||||
/**
|
/**
|
||||||
* 裤子
|
* 裤子
|
||||||
*/
|
*/
|
||||||
TROUSERS("Trousers"),
|
TROUSERS("Trousers");
|
||||||
/**
|
|
||||||
* 男装上装
|
|
||||||
*/
|
|
||||||
TOPS("Tops"),
|
|
||||||
/**
|
|
||||||
* 男装下装
|
|
||||||
*/
|
|
||||||
BOTTOMS("Bottoms"),
|
|
||||||
/**
|
|
||||||
* 印花-logo
|
|
||||||
*/
|
|
||||||
LOGO("Logo"),
|
|
||||||
/**
|
|
||||||
* 印花-slogan
|
|
||||||
*/
|
|
||||||
SLOGAN("Slogan"),
|
|
||||||
/**
|
|
||||||
* 印花-图案
|
|
||||||
*/
|
|
||||||
Pattern("Pattern");
|
|
||||||
|
|
||||||
private String realName;
|
private String realName;
|
||||||
|
|
||||||
@@ -64,8 +42,4 @@ public enum CollectionLevel2TypeEnum {
|
|||||||
public static CollectionLevel2TypeEnum of(String realName) {
|
public static CollectionLevel2TypeEnum of(String realName) {
|
||||||
return Stream.of(CollectionLevel2TypeEnum.values()).filter(v -> v.getRealName().equals(realName)).findFirst().orElse(null);
|
return Stream.of(CollectionLevel2TypeEnum.values()).filter(v -> v.getRealName().equals(realName)).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> printType() {
|
|
||||||
return Arrays.asList(LOGO.getRealName(), SLOGAN.getRealName(), Pattern.getRealName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.ai.da.common.enums;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum CreditsEventsEnum {
|
|
||||||
|
|
||||||
PRICE("price","6"),
|
|
||||||
// PRICE("price","0.1"),
|
|
||||||
|
|
||||||
BUY_CREDITS("Buy Credits","60"),
|
|
||||||
|
|
||||||
REFUND("Refund","60"),
|
|
||||||
// BUY_CREDITS("Buy Credits","10"),
|
|
||||||
|
|
||||||
// 每月更新
|
|
||||||
INIT_YEARLY("init_yearly", "6000"),
|
|
||||||
INIT_MONTHLY("init_monthly", "5000"),
|
|
||||||
INIT_TRIAL("init_trial", "100"),
|
|
||||||
INIT_WEEKLY("init_weekly","6000"),
|
|
||||||
|
|
||||||
// SUPER_RESOLUTION("Super Resolution","30"),
|
|
||||||
SUPER_RESOLUTION("Super Resolution","10"),
|
|
||||||
SLOGAN("Slogan","10"),
|
|
||||||
LOGO("Logo","5"),
|
|
||||||
PATTERN("Pattern","5"),
|
|
||||||
MOOD_BOARD("MoodBoard","5"),
|
|
||||||
SKETCH_BOARD("SketchBoard","5"),
|
|
||||||
TO_PRODUCT_IMAGE("ToProductImage","5"),
|
|
||||||
RELIGHT("Relight","5"),
|
|
||||||
QUESTIONNAIRE("Questionnaire","100"),
|
|
||||||
IMAGE_TO_SKETCH("ImageToSketch","5"),
|
|
||||||
|
|
||||||
OTHER("Other","5");
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对应事件需要消耗or获得的积分
|
|
||||||
*/
|
|
||||||
private String value;
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package com.ai.da.common.enums;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public enum CurrencyCodesEnum {
|
|
||||||
|
|
||||||
AUSTRALIAN_DOLLAR("AUD"),
|
|
||||||
BRAZILIAN_REAL("BRL"),
|
|
||||||
CANADIAN_DOLLAR("CAD"),
|
|
||||||
CHINESE_RENMENBI("CNY"),
|
|
||||||
CZECH_KORUNA("CZK"),
|
|
||||||
DANISH_KRONE("DKK"),
|
|
||||||
EURO("EUR"),
|
|
||||||
HONG_KONG_DOLLAR("HKD"),
|
|
||||||
HUNGARIAN_FORINT("HUF"),
|
|
||||||
ISRAELI_NEW_SHEKEL("ILS"),
|
|
||||||
JAPANESE_YEN("JPY"),
|
|
||||||
MALAYSIAN_RINGGIT("MYR"),
|
|
||||||
MEXICAN_PESO("MXN"),
|
|
||||||
NEW_TAIWAN_DOLLAR("TWD"),
|
|
||||||
NEW_ZEALAND_DOLLAR("NZD"),
|
|
||||||
NORWEGIAN_KRONE("NOK"),
|
|
||||||
PHILIPPINE_PESO("PHP"),
|
|
||||||
POLISH_ZLOTY("PLN"),
|
|
||||||
POUND_STERLING("GBP"),
|
|
||||||
RUSSIAN_RUBLE("RUB"),
|
|
||||||
SINGAPORE_DOLLAR("SGD"),
|
|
||||||
SWEDISH_KRONA("SEK"),
|
|
||||||
SWISS_FRANC("CHF"),
|
|
||||||
THAI_BAHT("THB"),
|
|
||||||
UNITED_STATES_DOLLAR("USD");
|
|
||||||
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
CurrencyCodesEnum(String code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,15 +20,15 @@ public enum CurrentDesignPictureTypeEnum {
|
|||||||
/**
|
/**
|
||||||
* USER_LIBRARY
|
* USER_LIBRARY
|
||||||
*/
|
*/
|
||||||
// USER_LIBRARY(2, "userLibrary"),
|
USER_LIBRARY(2,"userLibrary"),
|
||||||
/**
|
/**
|
||||||
* SYS_FILE
|
* SYS_FILE
|
||||||
*/
|
*/
|
||||||
SYS_FILE(2, "sysFile"),
|
SYS_FILE(3,"sysFile"),
|
||||||
/**
|
/**
|
||||||
* noPIN
|
* noPIN
|
||||||
*/
|
*/
|
||||||
NO_PIN(3, "noPIN");
|
NO_PIN(4,"noPIN");
|
||||||
|
|
||||||
private Integer code;
|
private Integer code;
|
||||||
private String desc;
|
private String desc;
|
||||||
@@ -41,7 +41,6 @@ public enum CurrentDesignPictureTypeEnum {
|
|||||||
public static CurrentDesignPictureTypeEnum of(String name){
|
public static CurrentDesignPictureTypeEnum of(String name){
|
||||||
return Stream.of(CurrentDesignPictureTypeEnum.values()).filter(v ->v.name().equals(name)).findFirst().orElse(null);
|
return Stream.of(CurrentDesignPictureTypeEnum.values()).filter(v ->v.name().equals(name)).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<CurrentDesignPictureTypeEnum> ofList(List<Integer> codes){
|
public static List<CurrentDesignPictureTypeEnum> ofList(List<Integer> codes){
|
||||||
return Stream.of(CurrentDesignPictureTypeEnum.values()).filter(v ->codes.contains(v.code)).collect(Collectors.toList());
|
return Stream.of(CurrentDesignPictureTypeEnum.values()).filter(v ->codes.contains(v.code)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ public enum CurrentDesignPrintPictureTypeEnum {
|
|||||||
this.code = code;
|
this.code = code;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<CurrentDesignPrintPictureTypeEnum> ofList(List<Integer> codes){
|
public static List<CurrentDesignPrintPictureTypeEnum> ofList(List<Integer> codes){
|
||||||
return Stream.of(CurrentDesignPrintPictureTypeEnum.values()).filter(v ->codes.contains(v.code)).collect(Collectors.toList());
|
return Stream.of(CurrentDesignPrintPictureTypeEnum.values()).filter(v ->codes.contains(v.code)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ public enum DesignTypeEnum {
|
|||||||
/**
|
/**
|
||||||
* Library
|
* Library
|
||||||
*/
|
*/
|
||||||
LIBRARY("Library"),
|
LIBRARY("Library");
|
||||||
GENERATE("Generate");
|
|
||||||
|
|
||||||
private String realName;
|
private String realName;
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
package com.ai.da.common.enums;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public enum GenerateModeEnum {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过文本生成
|
|
||||||
*/
|
|
||||||
TEXT(1, "text","txt2img"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过图片生成
|
|
||||||
*/
|
|
||||||
IMAGE(2, "image", "img2img"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过文本和图片生成
|
|
||||||
*/
|
|
||||||
TEXT_IMAGE(2, "text-image","img2img");
|
|
||||||
|
|
||||||
private Integer code;
|
|
||||||
private String value;
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
GenerateModeEnum(int code, String value) {
|
|
||||||
this.code = code;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
GenerateModeEnum(Integer code, String value, String type) {
|
|
||||||
this.code = code;
|
|
||||||
this.value = value;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getGenerateModeList(){
|
|
||||||
return Stream.of(TEXT,IMAGE,TEXT_IMAGE).map(GenerateModeEnum::getValue).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package com.ai.da.common.enums;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public enum LayersPriorityEnum {
|
|
||||||
|
|
||||||
EARRING_FRONT("earring_front","Earring",99),
|
|
||||||
BAG_FRONT("bag_front","Bag",98),
|
|
||||||
HAIRSTYLE_FRONT("hairstyle_front","Hairstyle",97),
|
|
||||||
OUTWEAR_FRONT("outwear_front","Outwear",20),
|
|
||||||
TOPS_FRONT("tops_front","Tops",19),
|
|
||||||
DRESS_FRONT("dress_front","Dress",18),
|
|
||||||
BLOUSE_FRONT("blouse_front","Blouse",17),
|
|
||||||
SKIRT_FRONT("skirt_front","Skirt",16),
|
|
||||||
TROUSERS_FRONT("trousers_front","Trousers",15),
|
|
||||||
BOTTOMS_FRONT("bottoms_front","Bottoms",14),
|
|
||||||
SHOES_RIGHT("shoes_right","Shoes",1),
|
|
||||||
SHOES_LEFT("shoes_left","Shoes",1),
|
|
||||||
BODY("body","Body",0),
|
|
||||||
BOTTOMS_BACK("bottoms_back","Bottoms",-14),
|
|
||||||
TROUSERS_BACK("trousers_back","Trousers",-15),
|
|
||||||
SKIRT_BACK("skirt_back","Skirt",-16),
|
|
||||||
BLOUSE_BACK("blouse_back","Blouse",-17),
|
|
||||||
DRESS_BACK("dress_back","Dress",-18),
|
|
||||||
TOPS_BACK("tops_back","Tops",-19),
|
|
||||||
OUTWEAR_BACK("outwear_back","Outwear",-20),
|
|
||||||
HAIRSTYLE_BACK("hairstyle_back","Hairstyle",-97),
|
|
||||||
BAG_BACK("bag_back","Bag",-98),
|
|
||||||
EARRING_BACK("earring_back","Earring",-99);
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private String realName;
|
|
||||||
@Getter
|
|
||||||
private String type;
|
|
||||||
@Getter
|
|
||||||
private Integer value;
|
|
||||||
|
|
||||||
|
|
||||||
LayersPriorityEnum(String realName, String type,Integer value) {
|
|
||||||
this.realName = realName;
|
|
||||||
this.type = type;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LayersPriorityEnum getValueByType(String type){
|
|
||||||
return Stream.of(LayersPriorityEnum.values()).filter(l -> l.getType().equals(type)).findFirst().orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LayersPriorityEnum getValueByLayerCategory(String layerCategory){
|
|
||||||
return Stream.of(LayersPriorityEnum.values()).filter(l -> l.getRealName().equals(layerCategory)).findFirst().orElse(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,8 +27,7 @@ public enum LibraryLevel1TypeEnum {
|
|||||||
/**
|
/**
|
||||||
* 模特
|
* 模特
|
||||||
*/
|
*/
|
||||||
MODELS("Models"),
|
MODELS("Models");
|
||||||
DESIGN_ELEMENTS("DesignElements");
|
|
||||||
|
|
||||||
private String realName;
|
private String realName;
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ public enum LibraryTopTypeEnum {
|
|||||||
public String getRealName() {
|
public String getRealName() {
|
||||||
return realName;
|
return realName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LibraryTopTypeEnum uploadOf(String realName){
|
public static LibraryTopTypeEnum uploadOf(String realName){
|
||||||
return Stream.of(LibraryTopTypeEnum.values())
|
return Stream.of(LibraryTopTypeEnum.values())
|
||||||
.filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
|
.filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.ai.da.common.enums;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public enum ModelNameEnum {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用模型0
|
|
||||||
*/
|
|
||||||
MODEL_0("0", "model_0");
|
|
||||||
|
|
||||||
|
|
||||||
private String code;
|
|
||||||
private String modelName;
|
|
||||||
|
|
||||||
|
|
||||||
ModelNameEnum(String code, String modelName) {
|
|
||||||
this.code = code;
|
|
||||||
this.modelName = modelName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,7 @@ import java.util.stream.Stream;
|
|||||||
* @description: 操作类型 登入 忘记密码
|
* @description: 操作类型 登入 忘记密码
|
||||||
* @create: 2022-8-10 17:33
|
* @create: 2022-8-10 17:33
|
||||||
**/
|
**/
|
||||||
public enum AuthenticationOperationTypeEnum {
|
public enum OperationTypeEnum {
|
||||||
/**
|
/**
|
||||||
*登入
|
*登入
|
||||||
*/
|
*/
|
||||||
@@ -23,13 +23,9 @@ public enum AuthenticationOperationTypeEnum {
|
|||||||
/**
|
/**
|
||||||
* 忘记密码
|
* 忘记密码
|
||||||
*/
|
*/
|
||||||
FORGET_PWD,
|
FORGET_PWD;
|
||||||
/**
|
|
||||||
* 更改邮箱
|
|
||||||
*/
|
|
||||||
CHANGE_MAILBOX;
|
|
||||||
|
|
||||||
public static AuthenticationOperationTypeEnum of(String name) {
|
public static OperationTypeEnum of(String name){
|
||||||
return Stream.of(AuthenticationOperationTypeEnum.values()).filter(v -> v.name().equals(name)).findFirst().orElse(null);
|
return Stream.of(OperationTypeEnum.values()).filter(v ->v.name().equals(name)).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package com.ai.da.common.enums;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum OrderStatusEnum {
|
|
||||||
/**
|
|
||||||
* 未支付
|
|
||||||
*/
|
|
||||||
NOT_PAY("未支付"),
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付成功
|
|
||||||
*/
|
|
||||||
SUCCESS("支付成功"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已关闭
|
|
||||||
*/
|
|
||||||
TIMEOUT_CLOSED("超时已关闭"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已取消
|
|
||||||
*/
|
|
||||||
CANCEL("用户已取消"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款中
|
|
||||||
*/
|
|
||||||
REFUND_PROCESSING("退款中"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已退款
|
|
||||||
*/
|
|
||||||
REFUND_SUCCESS("已退款"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款异常
|
|
||||||
*/
|
|
||||||
REFUND_ABNORMAL("退款异常"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* paypal订单状态为 APPROVED
|
|
||||||
*/
|
|
||||||
ORDER_PROCESSING("订单处理中");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类型
|
|
||||||
*/
|
|
||||||
private final String type;
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.ai.da.common.enums;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum PayPalOrderStatusEnum {
|
|
||||||
|
|
||||||
// The order was created with the specified context.
|
|
||||||
// 订单已创建并具有指定的上下文。
|
|
||||||
CREATED("CREATED"),
|
|
||||||
// The order was saved and persisted. The order status continues to be in progress until a capture is made with final_capture = true for all purchase units within the order.
|
|
||||||
// 订单已保存并持久化。订单状态仍处于进行中,直到对订单中的所有购买单元进行了 final_capture = true 的捕获为止
|
|
||||||
SAVED("SAVED"),
|
|
||||||
// The customer approved the payment through the PayPal wallet or another form of guest or unbranded payment. For example, a card, bank account, or so on.
|
|
||||||
// 客户通过PayPal钱包或其他形式的游客或非品牌支付批准了付款。例如,信用卡、银行账户等。
|
|
||||||
APPROVED("APPROVED"),
|
|
||||||
// All purchase units in the order are voided.
|
|
||||||
// 订单中的所有购买单元都已作废。
|
|
||||||
VOIDED("VOIDED"),
|
|
||||||
// The payment was authorized or the authorized payment was captured for the order.
|
|
||||||
// 订单的支付已被授权或已捕获授权的支付。
|
|
||||||
COMPLETED("COMPLETED"),
|
|
||||||
// The order requires an action from the payer (e.g. 3DS authentication). Redirect the payer to the "rel":"payer-action" HATEOAS link returned as part of the response prior to authorizing or capturing the order.
|
|
||||||
// 订单需要支付者执行某项操作(例如3DS身份验证)。在授权或捕获订单之前,请将支付者重定向到响应中返回的"rel":"payer-action" HATEOAS链接。
|
|
||||||
PAYER_ACTION_REQUIRED("PAYER_ACTION_REQUIRED");
|
|
||||||
|
|
||||||
private final String status;
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package com.ai.da.common.enums;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum PayTypeEnum {
|
|
||||||
/**
|
|
||||||
* 微信
|
|
||||||
*/
|
|
||||||
WXPAY("微信"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付宝
|
|
||||||
*/
|
|
||||||
ALIPAY("支付宝"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PayPal
|
|
||||||
*/
|
|
||||||
PAYPAL("PayPal"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 香港支付宝
|
|
||||||
*/
|
|
||||||
ALIPAY_HK("Alipay-HK"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stripe
|
|
||||||
*/
|
|
||||||
STRIPE("Stripe");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类型
|
|
||||||
*/
|
|
||||||
private final String type;
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanglei
|
* @author yanglei
|
||||||
* @description python调用java 操作数类型 generatePrint ->生成印花 designCollection ->设计collection generateSketch->设计草图
|
* @description python调用java 操作数类型 generatePrint ->生成印花 designCollection ->设计collection
|
||||||
* @create 2022-10-3 17:33
|
* @create 2022-10-3 17:33
|
||||||
**/
|
**/
|
||||||
public enum PythonToJavaApiOperationTypeEnum {
|
public enum PythonToJavaApiOperationTypeEnum {
|
||||||
@@ -19,12 +19,7 @@ public enum PythonToJavaApiOperationTypeEnum {
|
|||||||
/**
|
/**
|
||||||
* 设计collection
|
* 设计collection
|
||||||
*/
|
*/
|
||||||
DESIGN_COLLECTION("designCollection"),
|
DESIGN_COLLECTION("designCollection");
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成草图
|
|
||||||
*/
|
|
||||||
GENERATE_SKETCH("generateSketch");
|
|
||||||
|
|
||||||
private String realName;
|
private String realName;
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ public enum SwitchCategoryEnum {
|
|||||||
* 裤子
|
* 裤子
|
||||||
*/
|
*/
|
||||||
TROUSERS("Trousers"),
|
TROUSERS("Trousers"),
|
||||||
TOPS("Tops"),
|
|
||||||
BOTTOMS("Bottoms"),
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private String realName;
|
private String realName;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.ai.da.common.enums;
|
package com.ai.da.common.enums;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -58,7 +57,6 @@ public enum SysFileLevel2TypeEnum {
|
|||||||
public static SysFileLevel2TypeEnum uploadOf(String uploadPathName){
|
public static SysFileLevel2TypeEnum uploadOf(String uploadPathName){
|
||||||
return Stream.of(SysFileLevel2TypeEnum.values()).filter(v ->v.getUploadPathName().equals(uploadPathName)).findFirst().orElse(null);
|
return Stream.of(SysFileLevel2TypeEnum.values()).filter(v ->v.getUploadPathName().equals(uploadPathName)).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SysFileLevel2TypeEnum realNameOf(String realName){
|
public static SysFileLevel2TypeEnum realNameOf(String realName){
|
||||||
return Stream.of(SysFileLevel2TypeEnum.values()).filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
|
return Stream.of(SysFileLevel2TypeEnum.values()).filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
@@ -66,29 +64,10 @@ public enum SysFileLevel2TypeEnum {
|
|||||||
public static SysFileLevel2TypeEnum realNameOfPython(String realName){
|
public static SysFileLevel2TypeEnum realNameOfPython(String realName){
|
||||||
return Stream.of(BLOUSE,DRESS,OUTWEAR,SKIRT,TROUSERS).filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
|
return Stream.of(BLOUSE,DRESS,OUTWEAR,SKIRT,TROUSERS).filter(v ->v.getRealName().equals(realName)).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> ofPython(){
|
public static List<String> ofPython(){
|
||||||
return Stream.of(BLOUSE,DRESS,OUTWEAR,SKIRT,TROUSERS).map(SysFileLevel2TypeEnum::getRealName).collect(Collectors.toList());
|
return Stream.of(BLOUSE,DRESS,OUTWEAR,SKIRT,TROUSERS).map(SysFileLevel2TypeEnum::getRealName).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> ofPythonPath(){
|
public static List<String> ofPythonPath(){
|
||||||
return Stream.of(BLOUSE,DRESS,OUTWEAR,SKIRT,TROUSERS).map(SysFileLevel2TypeEnum::getUploadPathName).collect(Collectors.toList());
|
return Stream.of(BLOUSE,DRESS,OUTWEAR,SKIRT,TROUSERS).map(SysFileLevel2TypeEnum::getUploadPathName).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final List<String> ACCESSORIES_LIST = Arrays.asList(
|
|
||||||
SysFileLevel2TypeEnum.BAG.getRealName(),
|
|
||||||
SysFileLevel2TypeEnum.EARRINGS.getRealName(),
|
|
||||||
SysFileLevel2TypeEnum.HAIRSTYLE.getRealName(),
|
|
||||||
SysFileLevel2TypeEnum.SHOES.getRealName(),
|
|
||||||
SysFileLevel2TypeEnum.BODY.getRealName()
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final List<String> IMAGES_LIST = Arrays.asList(
|
|
||||||
SysFileLevel2TypeEnum.BLOUSE.getRealName(),
|
|
||||||
SysFileLevel2TypeEnum.DRESS.getRealName(),
|
|
||||||
SysFileLevel2TypeEnum.OUTWEAR.getRealName(),
|
|
||||||
SysFileLevel2TypeEnum.SKIRT.getRealName(),
|
|
||||||
SysFileLevel2TypeEnum.TROUSERS.getRealName()
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ public class TokenQuery {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JSONObject generateUser(Map<String, Object> param,String token) {
|
public static JSONObject generateUser(Map<String, Object> param,String token) {
|
||||||
HttpResponse httpResponse = HttpUtil.createPost(GENERATE_USER_DOMAIN + TokenApis.GENERATE_USER.getUrl())
|
HttpResponse httpResponse = HttpUtil.createPost(GENERATE_USER_DOMAIN + TokenApis.GENERATE_USER.getUrl())
|
||||||
.body(JSONObject.toJSONString(param!=null?param:new HashMap<>()))
|
.body(JSONObject.toJSONString(param!=null?param:new HashMap<>()))
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public class PageBaseResponse<T> {
|
|||||||
private List<T> content;
|
private List<T> content;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public PageBaseResponse(List<T> list, long page, long size, long total, long pages) {
|
public PageBaseResponse(List<T> list, long page, long size, long total, long pages) {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class PageResponse<T> extends Response<List<T>> {
|
|||||||
private List<T> content;
|
private List<T> content;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public PageResponse(Response<List<T>> response, long page, long size, long total, long pages) {
|
public PageResponse(Response<List<T>> response, long page, long size, long total, long pages) {
|
||||||
if(response != null) {
|
if(response != null) {
|
||||||
this.setData(response.getData());
|
this.setData(response.getData());
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ public class Response<T> implements Serializable {
|
|||||||
return success(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(), null);
|
return success(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static <T> Response<T> success(String msg) {
|
public static <T> Response<T> success(String msg){
|
||||||
// return success(ResultEnum.SUCCESS.getCode(), msg, null);
|
return success(ResultEnum.SUCCESS.getCode(), msg, null);
|
||||||
// }
|
}
|
||||||
|
|
||||||
public static <T> Response<T> success(T data){
|
public static <T> Response<T> success(T data){
|
||||||
return success(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(), data);
|
return success(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(), data);
|
||||||
@@ -48,6 +48,7 @@ public class Response<T> implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static <T> Response<T> fail(String msg) {
|
public static <T> Response<T> fail(String msg) {
|
||||||
return fail(ResultEnum.FAIL.getCode(), msg);
|
return fail(ResultEnum.FAIL.getCode(), msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,17 +15,14 @@ public enum ResultEnum {
|
|||||||
|
|
||||||
NO_LOGIN(false,-100,"User not logged in"),
|
NO_LOGIN(false,-100,"User not logged in"),
|
||||||
NO_PERMISSION(false,-200,"No access"),
|
NO_PERMISSION(false,-200,"No access"),
|
||||||
ACCOUNT_LOCK(false, -300, "Account frozen"),
|
ACCOUNT_LOCK(false,-300,"Account frozen");
|
||||||
|
|
||||||
PROMPT(false, 1, "Prompt"),
|
|
||||||
WARNING(false, 2, "Warning"),
|
|
||||||
|
|
||||||
;
|
|
||||||
private int code;
|
private int code;
|
||||||
private String msg;
|
private String msg;
|
||||||
private boolean isOK;
|
private boolean isOK;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ResultEnum(boolean isOK, int code, String msg){
|
ResultEnum(boolean isOK, int code, String msg){
|
||||||
this.isOK = isOK;
|
this.isOK = isOK;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
|
|||||||
@@ -7,14 +7,18 @@ import com.ai.da.common.security.jwt.JWTTokenHelper;
|
|||||||
import com.ai.da.common.utils.LocalCacheUtils;
|
import com.ai.da.common.utils.LocalCacheUtils;
|
||||||
import com.ai.da.common.utils.MultiReadHttpServletRequest;
|
import com.ai.da.common.utils.MultiReadHttpServletRequest;
|
||||||
import com.ai.da.common.utils.MultiReadHttpServletResponse;
|
import com.ai.da.common.utils.MultiReadHttpServletResponse;
|
||||||
import com.ai.da.common.utils.RequestInfoUtil;
|
|
||||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Required;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.lang.NonNull;
|
import org.springframework.lang.NonNull;
|
||||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.util.StopWatch;
|
import org.springframework.util.StopWatch;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.filter.OncePerRequestFilter;
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -24,6 +28,7 @@ import javax.servlet.ServletException;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -42,23 +47,16 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
|||||||
private SecurityProperties properties;
|
private SecurityProperties properties;
|
||||||
|
|
||||||
private static final List<String> FILTER_URL =
|
private static final List<String> FILTER_URL =
|
||||||
Arrays.asList("/favicon.ico", "/doc.html", "api/account/login", "api/account/preLogin", "api/account/sendEmail","api/account/noLoginRequired",
|
Arrays.asList("/favicon.ico","/doc.html","api/account/login","api/account/preLogin","api/account/sendEmail",
|
||||||
"/webjars/","/swagger-resources","/v2/api-docs","api/account/resetPwd",
|
"/webjars/","/swagger-resources","/v2/api-docs","api/account/resetPwd",
|
||||||
"/api/python/saveGeneratePicture", "/api/python/getLibraryByUserId",
|
"/api/python/saveGeneratePicture", "/api/python/getLibraryByUserId",
|
||||||
"/api/third/party/addUser","/api/third/party/addTrialUser", "/api/third/party/editUser", "/api/element/initDefaultSysFile",
|
"/api/third/party/addUser","/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"
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doFilterInternal(HttpServletRequest httpServletRequest, @NonNull HttpServletResponse httpServletResponse, @NonNull FilterChain filterChain) throws ServletException, IOException {
|
protected void doFilterInternal(HttpServletRequest httpServletRequest, @NonNull HttpServletResponse httpServletResponse, @NonNull FilterChain filterChain) throws ServletException, IOException {
|
||||||
String requestURI = httpServletRequest.getRequestURI();
|
String requestURI = httpServletRequest.getRequestURI();
|
||||||
|
|
||||||
if (calculateUrl(requestURI) || hasAuthorizationToken(httpServletRequest)) {
|
if(calculateUrl(requestURI)){
|
||||||
StopWatch stopWatch = new StopWatch();
|
StopWatch stopWatch = new StopWatch();
|
||||||
HttpServletRequest wrappedRequest = httpServletRequest;
|
HttpServletRequest wrappedRequest = httpServletRequest;
|
||||||
HttpServletResponse wrappedResponse = httpServletResponse;
|
HttpServletResponse wrappedResponse = httpServletResponse;
|
||||||
@@ -83,30 +81,17 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
|||||||
filterChain.doFilter(httpServletRequest, httpServletResponse);
|
filterChain.doFilter(httpServletRequest, httpServletResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean calculateUrl(String requestURI ){
|
private Boolean calculateUrl(String requestURI ){
|
||||||
String filterUrl = FILTER_URL.stream().filter(url ->requestURI.contains(url)).findFirst().orElse(null);
|
String filterUrl = FILTER_URL.stream().filter(url ->requestURI.contains(url)).findFirst().orElse(null);
|
||||||
return null == filterUrl ? Boolean.TRUE :Boolean.FALSE;
|
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) throws AuthenticationException {
|
private void extracted(HttpServletRequest request) throws AuthenticationException {
|
||||||
String jwtToken = request.getHeader(properties.getJwtTokenHeader());
|
String jwtToken = request.getHeader(properties.getJwtTokenHeader());
|
||||||
// log.debug("后台检查令牌:{}", jwtToken);
|
log.debug("后台检查令牌:{}", jwtToken);
|
||||||
|
|
||||||
if (StrUtil.isBlank(jwtToken)) {
|
if (StrUtil.isBlank(jwtToken)) {
|
||||||
String ipAddress = RequestInfoUtil.getIpAddress(request);
|
|
||||||
log.info("本次请求的ip为 : " + ipAddress);
|
|
||||||
throw new RuntimeException("请传入token!");
|
throw new RuntimeException("请传入token!");
|
||||||
}
|
}
|
||||||
if(jwtToken.equals("Bearer-eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiIyIiwic3ViIjoie1wiaWRcIjoyLFwidXNlcm5hbWVcIjpcImxpcnNcIn0iLCJpYXQiOjE2NjU3NDEwODcsImlzcyI6IkRXSiIsImF1dGhvcml0aWVzIjoiW10iLCJleHAiOjE2NzQzODEwODd9.ShM9R_NNFD7oo1OvxrEgg7PFeWinOuAKkuInUCMQupp66s64Hhv8tN0Wwr83nIN4rHPqtn95wmd4msWcvaFYJA")){
|
|
||||||
//写死 暂时放行
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 检查token
|
// 检查token
|
||||||
boolean validate = jwtTokenHelper.validateToken(jwtToken);
|
boolean validate = jwtTokenHelper.validateToken(jwtToken);
|
||||||
if(validate){
|
if(validate){
|
||||||
@@ -120,7 +105,10 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
|||||||
UserContext.setUserHolder(principal);
|
UserContext.setUserHolder(principal);
|
||||||
//校验token
|
//校验token
|
||||||
String cacheToken = LocalCacheUtils.getTokenCache(String.valueOf(principal.getId()));
|
String cacheToken = LocalCacheUtils.getTokenCache(String.valueOf(principal.getId()));
|
||||||
|
if(jwtToken.equals("Bearer-eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiIyIiwic3ViIjoie1wiaWRcIjoyLFwidXNlcm5hbWVcIjpcImxpcnNcIn0iLCJpYXQiOjE2NjU3NDEwODcsImlzcyI6IkRXSiIsImF1dGhvcml0aWVzIjoiW10iLCJleHAiOjE2NzQzODEwODd9.ShM9R_NNFD7oo1OvxrEgg7PFeWinOuAKkuInUCMQupp66s64Hhv8tN0Wwr83nIN4rHPqtn95wmd4msWcvaFYJA")){
|
||||||
|
//写死 暂时放行
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(StringUtils.isEmpty(cacheToken)){
|
if(StringUtils.isEmpty(cacheToken)){
|
||||||
throw new RuntimeException("TOKEN已过期,请重新登录!");
|
throw new RuntimeException("TOKEN已过期,请重新登录!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.ai.da.common.security.jwt;
|
|||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.ai.da.common.constant.CommonConstant;
|
|
||||||
import com.ai.da.common.security.config.SecurityProperties;
|
import com.ai.da.common.security.config.SecurityProperties;
|
||||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
@@ -31,7 +30,6 @@ public class JWTTokenHelper {
|
|||||||
|
|
||||||
private static final String ISSUER = "DWJ";
|
private static final String ISSUER = "DWJ";
|
||||||
private static final String AUTHORITIES = "authorities";
|
private static final String AUTHORITIES = "authorities";
|
||||||
private static final String CHANGE_MAILBOX = "changeMailbox";
|
|
||||||
|
|
||||||
public String createToken(AuthPrincipalVo principal){
|
public String createToken(AuthPrincipalVo principal){
|
||||||
String token = Jwts.builder()
|
String token = Jwts.builder()
|
||||||
@@ -67,21 +65,4 @@ public class JWTTokenHelper {
|
|||||||
token = token.replaceAll(securityProperties.getJwtTokenPrefix(),"");
|
token = token.replaceAll(securityProperties.getJwtTokenPrefix(),"");
|
||||||
return Jwts.parser().setSigningKey(securityProperties.getJwtSecret()).parseClaimsJws(token).getBody();
|
return Jwts.parser().setSigningKey(securityProperties.getJwtSecret()).parseClaimsJws(token).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String createToken(Long userId, String userEmail){
|
|
||||||
String token = Jwts.builder()
|
|
||||||
.setId(String.valueOf(userId))
|
|
||||||
.setSubject(userEmail + "_" + userId)
|
|
||||||
.setIssuedAt(new Date())
|
|
||||||
.setIssuer(ISSUER)
|
|
||||||
.claim(CHANGE_MAILBOX, JSON.toJSONString(new ArrayList<>()))//自定义属性 权限
|
|
||||||
.setExpiration(new Date(System.currentTimeMillis() + CommonConstant.CHANGE_MAILBOX_LINK_VALIDITY))
|
|
||||||
.signWith(SignatureAlgorithm.HS256, securityProperties.getJwtSecret())
|
|
||||||
.compact();
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String parseToEmailAndId(String token) {
|
|
||||||
return parser(token).getSubject();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
package com.ai.da.common.task;
|
|
||||||
|
|
||||||
import com.ai.da.mapper.primary.entity.Account;
|
|
||||||
import com.ai.da.service.AccountService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class AccountTask {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private AccountService accountService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 每周日晚上刷新 年付用户、月付用户的积分
|
|
||||||
*/
|
|
||||||
@Scheduled(cron = "59 59 23 ? * SUN")
|
|
||||||
// @Scheduled(cron = "59 59 23 * * ?")
|
|
||||||
public void refreshCreditsMonthly() {
|
|
||||||
log.info("每周日晚11:59:59刷新付费用户积分为 6000");
|
|
||||||
accountService.refreshCreditsWeekly();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
|
||||||
public void getPaidUser() {
|
|
||||||
// 获取code-create 表中 指定日期之后 订单状态为wc-processing的订单
|
|
||||||
accountService.extendValidityForCC();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 每天凌晨0点执行一次
|
|
||||||
// @Scheduled(cron = "0 0 0 * * ?")
|
|
||||||
public void cancelActivityBenefits() {
|
|
||||||
// 1、查询当前所有参与了活动且过期的用户
|
|
||||||
List<Account> accountList = accountService.getExpiredUserBySystemUser(4);
|
|
||||||
|
|
||||||
// 2、将到期用户置为游客
|
|
||||||
for (Account account : accountList) {
|
|
||||||
log.info("参与活动的用户{} : {} 于 {} 账号有效期到期,置为游客", account.getId(), account.getUserEmail(), account.getValidEndTime());
|
|
||||||
accountService.toVisitor(account);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 每天检测正式用户到期情况,每天凌晨0点执行
|
|
||||||
// @Scheduled(cron = "0 0 0 * * ?")
|
|
||||||
public void paidUserToVisitor() {
|
|
||||||
// 1、查询当前已过期正式用户或试用用户
|
|
||||||
List<Account> accountList = accountService.getExpiredUserBySystemUser(1);
|
|
||||||
accountList.addAll(accountService.getExpiredUserBySystemUser(2));
|
|
||||||
accountList.addAll(accountService.getExpiredUserBySystemUser(3));
|
|
||||||
|
|
||||||
// 2、将到期用户置为游客
|
|
||||||
for (Account account : accountList) {
|
|
||||||
log.info("用户{} : {} 于 {}账号有效期到期,置为游客", account.getId(), account.getUserEmail(), account.getValidEndTime());
|
|
||||||
accountService.toVisitor(account);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将Code-Create上注册的用户添加为AiDA的游客
|
|
||||||
*/
|
|
||||||
// @Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
|
||||||
public void registerUserToVisitor() {
|
|
||||||
accountService.registerUserToVisitor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package com.ai.da.common.task;
|
|
||||||
|
|
||||||
import com.ai.da.mapper.primary.entity.OrderInfo;
|
|
||||||
import com.ai.da.common.enums.PayTypeEnum;
|
|
||||||
import com.ai.da.service.AliPayService;
|
|
||||||
import com.ai.da.service.OrderInfoService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class AliPayTask {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private OrderInfoService orderInfoService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private AliPayService aliPayService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从第0秒开始每隔30秒执行1次,查询创建超过5分钟,并且未支付的订单
|
|
||||||
*/
|
|
||||||
// @Scheduled(cron = "0/30 * * * * ?")
|
|
||||||
public void orderConfirm(){
|
|
||||||
|
|
||||||
// log.info("Alipay orderConfirm 被执行......");
|
|
||||||
|
|
||||||
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(5, PayTypeEnum.ALIPAY.getType());
|
|
||||||
|
|
||||||
for (OrderInfo orderInfo : orderInfoList) {
|
|
||||||
String orderNo = orderInfo.getOrderNo();
|
|
||||||
log.warn("超时订单 ===> {}", orderNo);
|
|
||||||
|
|
||||||
//核实订单状态:调用支付宝查单接口
|
|
||||||
aliPayService.checkOrderStatus(orderNo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.ai.da.common.task;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class GenerateTask {
|
|
||||||
|
|
||||||
// @Scheduled(cron = "0 0 */1 * * ?")
|
|
||||||
public void generateScheduled(){
|
|
||||||
log.info("测试定时器:generate");
|
|
||||||
|
|
||||||
try{
|
|
||||||
|
|
||||||
}catch(Exception e){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,216 +0,0 @@
|
|||||||
//package com.ai.da.common.task;
|
|
||||||
//
|
|
||||||
//import com.ai.da.common.utils.CopyUtil;
|
|
||||||
//import com.ai.da.common.utils.ExcelReader;
|
|
||||||
//import com.ai.da.common.utils.MinioUtil;
|
|
||||||
//import com.ai.da.common.utils.SendEmailUtil;
|
|
||||||
//import com.ai.da.mapper.primary.*;
|
|
||||||
//import com.ai.da.mapper.primary.entity.*;
|
|
||||||
//import com.ai.da.mapper.secondary.AttributeRetrievalMapper;
|
|
||||||
//import com.ai.da.mapper.third.*;
|
|
||||||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
//import org.apache.commons.lang3.StringUtils;
|
|
||||||
//import org.apache.poi.ss.usermodel.Row;
|
|
||||||
//import org.apache.poi.ss.usermodel.Sheet;
|
|
||||||
//import org.apache.poi.ss.usermodel.Workbook;
|
|
||||||
//import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//import org.springframework.util.CollectionUtils;
|
|
||||||
//
|
|
||||||
//import javax.annotation.PostConstruct;
|
|
||||||
//import javax.annotation.Resource;
|
|
||||||
//import java.io.FileOutputStream;
|
|
||||||
//import java.io.IOException;
|
|
||||||
//import java.nio.file.Files;
|
|
||||||
//import java.nio.file.Paths;
|
|
||||||
//import java.time.LocalDate;
|
|
||||||
//import java.time.format.DateTimeFormatter;
|
|
||||||
//import java.util.List;
|
|
||||||
//import java.util.concurrent.ExecutorService;
|
|
||||||
//import java.util.concurrent.Executors;
|
|
||||||
//import java.util.concurrent.TimeUnit;
|
|
||||||
//import java.util.stream.Collectors;
|
|
||||||
//
|
|
||||||
//@Component
|
|
||||||
//public class MoveDataScheduler {
|
|
||||||
//
|
|
||||||
// @PostConstruct
|
|
||||||
// public void test() {
|
|
||||||
// moveData();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private UserLikeGroupMapper userLikeGroupMapper;
|
|
||||||
// @Resource
|
|
||||||
// private UserLikeGroupZSMapper userLikeGroupZSMapper;
|
|
||||||
// @Resource
|
|
||||||
// private UserLikeMapper userLikeMapper;
|
|
||||||
// @Resource
|
|
||||||
// private UserLikeZSMapper userLikeZSMapper;
|
|
||||||
// @Resource
|
|
||||||
// private CollectionElementMapper collectionElementMapper;
|
|
||||||
// @Resource
|
|
||||||
// private CollectionElementZSMapper collectionElementZSMapper;
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private CollectionMapper collectionMapper;
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private CollectionZSMapper collectionZSMapper;
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private DesignMapper designMapper;
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private DesignZSMapper designZSMapper;
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private DesignItemMapper designItemMapper;
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private DesignItemZSMapper designItemZSMapper;
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private TDesignPythonOutfitMapper designPythonOutfitMapper;
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private TDesignPythonOutfitZSMapper designPythonOutfitZSMapper;
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private TDesignPythonOutfitDetailMapper designPythonOutfitDetailMapper;
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private TDesignPythonOutfitDetailZSMapper designPythonOutfitDetailZSMapper;
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private DesignItemDetailMapper designItemDetailMapper;
|
|
||||||
// @Resource
|
|
||||||
// private DesignItemZSDetailMapper designItemDetailZSMapper;
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private DesignItemDetailPrintMapper designItemDetailPrintMapper;
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private DesignItemDetailPrintZSMapper designItemDetailPrintZSMapper;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// private void moveData() {
|
|
||||||
// // 查询用户所有history记录
|
|
||||||
// QueryWrapper<UserLikeGroup> userLikeGroupQueryWrapper = new QueryWrapper<>();
|
|
||||||
// userLikeGroupQueryWrapper.lambda().eq(UserLikeGroup::getAccountId, 11411);
|
|
||||||
// List<UserLikeGroup> userLikeGroupList = userLikeGroupMapper.selectList(userLikeGroupQueryWrapper);
|
|
||||||
//
|
|
||||||
// for (UserLikeGroup userLikeGroup : userLikeGroupList) {
|
|
||||||
//
|
|
||||||
// com.ai.da.mapper.third.entity.UserLikeGroup userLikeGroupZS = CopyUtil.copyObject(userLikeGroup, com.ai.da.mapper.third.entity.UserLikeGroup.class);
|
|
||||||
// userLikeGroupZS.setAccountId(11420L);
|
|
||||||
// userLikeGroupZS.setId(null);
|
|
||||||
// Collection collection = collectionMapper.selectById(userLikeGroup.getCollectionId());
|
|
||||||
// com.ai.da.mapper.third.entity.Collection collectionZS = CopyUtil.copyObject(collection, com.ai.da.mapper.third.entity.Collection.class);
|
|
||||||
// collectionZS.setAccountId(11420L);
|
|
||||||
// collectionZS.setId(null);
|
|
||||||
//
|
|
||||||
// if (collection.getMoodTemplateId() != null) {
|
|
||||||
// CollectionElement element = collectionElementMapper.selectById(collection.getMoodTemplateId());
|
|
||||||
// com.ai.da.mapper.third.entity.CollectionElement collectionElementZS = CopyUtil.copyObject(element, com.ai.da.mapper.third.entity.CollectionElement.class);
|
|
||||||
// collectionElementZS.setAccountId(11420L);
|
|
||||||
// collectionElementZS.setId(null);
|
|
||||||
// collectionElementZSMapper.insert(collectionElementZS);
|
|
||||||
// collectionZS.setMoodTemplateId(String.valueOf(collectionElementZS.getId()));
|
|
||||||
// }
|
|
||||||
// collectionZSMapper.insert(collectionZS);
|
|
||||||
// userLikeGroupZS.setCollectionId(collectionZS.getId());
|
|
||||||
// userLikeGroupZSMapper.insert(userLikeGroupZS);
|
|
||||||
//
|
|
||||||
// // 生成元素
|
|
||||||
// QueryWrapper<CollectionElement> collectionElementQueryWrapper = new QueryWrapper<>();
|
|
||||||
// collectionElementQueryWrapper.lambda().eq(CollectionElement::getCollectionId, userLikeGroup.getCollectionId());
|
|
||||||
// List<CollectionElement> collectionElements = collectionElementMapper.selectList(collectionElementQueryWrapper);
|
|
||||||
//
|
|
||||||
// for (CollectionElement collectionElement : collectionElements) {
|
|
||||||
// com.ai.da.mapper.third.entity.CollectionElement collectionElementZS = CopyUtil.copyObject(collectionElement, com.ai.da.mapper.third.entity.CollectionElement.class);
|
|
||||||
// collectionElementZS.setId(null);
|
|
||||||
// collectionElementZS.setAccountId(11420L);
|
|
||||||
// collectionElementZS.setCollectionId(collectionZS.getId());
|
|
||||||
// collectionElementZSMapper.insert(collectionElementZS);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 查询记录关联
|
|
||||||
// QueryWrapper<UserLike> userLikeQueryWrapper = new QueryWrapper<>();
|
|
||||||
// userLikeQueryWrapper.lambda().eq(UserLike::getUserLikeGroupId, userLikeGroup.getId());
|
|
||||||
// List<UserLike> userLikes = userLikeMapper.selectList(userLikeQueryWrapper);
|
|
||||||
// for (UserLike userLike : userLikes) {
|
|
||||||
// Design design = designMapper.selectById(userLike.getDesignId());
|
|
||||||
// com.ai.da.mapper.third.entity.Design designZS = CopyUtil.copyObject(design, com.ai.da.mapper.third.entity.Design.class);
|
|
||||||
// designZS.setId(null);
|
|
||||||
// designZS.setAccountId(11420L);
|
|
||||||
// designZS.setCollectionId(collectionZS.getId());
|
|
||||||
// designZSMapper.insert(designZS);
|
|
||||||
//
|
|
||||||
// com.ai.da.mapper.third.entity.UserLike userLikeZS = CopyUtil.copyObject(userLike, com.ai.da.mapper.third.entity.UserLike.class);
|
|
||||||
//// Design design = designMapper.selectById(userLike.getDesignId());
|
|
||||||
// userLikeZS.setId(null);
|
|
||||||
// DesignItem designItem = designItemMapper.selectById(userLike.getDesignItemId());
|
|
||||||
// com.ai.da.mapper.third.entity.DesignItem designItemZS = CopyUtil.copyObject(designItem, com.ai.da.mapper.third.entity.DesignItem.class);
|
|
||||||
// designItemZS.setId(null);
|
|
||||||
// designItemZS.setAccountId(11420L);
|
|
||||||
// designItemZS.setDesignId(designZS.getId());
|
|
||||||
// designItemZSMapper.insert(designItemZS);
|
|
||||||
//
|
|
||||||
// QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
|
||||||
// designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItem.getId());
|
|
||||||
// List<DesignItemDetail> designItemDetails = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
|
||||||
// for (DesignItemDetail designItemDetail : designItemDetails) {
|
|
||||||
// com.ai.da.mapper.third.entity.DesignItemDetail designItemDetailZS = CopyUtil.copyObject(designItemDetail, com.ai.da.mapper.third.entity.DesignItemDetail.class);
|
|
||||||
// designItemDetailZS.setId(null);
|
|
||||||
// designItemDetailZS.setDesignItemId(designItemZS.getId());
|
|
||||||
// designItemDetailZS.setAccountId(11420L);
|
|
||||||
// designItemDetailZS.setDesignId(designZS.getId());
|
|
||||||
// designItemDetailZSMapper.insert(designItemDetailZS);
|
|
||||||
//
|
|
||||||
// QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
|
|
||||||
// designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetail.getId());
|
|
||||||
// List<DesignItemDetailPrint> designItemDetailPrintList = designItemDetailPrintMapper.selectList(designItemDetailPrintQueryWrapper);
|
|
||||||
// if (!CollectionUtils.isEmpty(designItemDetailPrintList)) {
|
|
||||||
// for (DesignItemDetailPrint designItemDetailPrint : designItemDetailPrintList) {
|
|
||||||
// com.ai.da.mapper.third.entity.DesignItemDetailPrint designItemDetailPrintZS = CopyUtil.copyObject(designItemDetailPrint, com.ai.da.mapper.third.entity.DesignItemDetailPrint.class);
|
|
||||||
// designItemDetailPrintZS.setId(null);
|
|
||||||
// designItemDetailPrintZS.setDesignItemDetailId(designItemDetailZS.getId());
|
|
||||||
// designItemDetailPrintZSMapper.insert(designItemDetailPrintZS);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// userLikeZS.setDesignItemId(designItemZS.getId());
|
|
||||||
// TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(userLike.getDesignOutfitId());
|
|
||||||
// com.ai.da.mapper.third.entity.TDesignPythonOutfit tDesignPythonOutfitZS = CopyUtil.copyObject(tDesignPythonOutfit, com.ai.da.mapper.third.entity.TDesignPythonOutfit.class);
|
|
||||||
// tDesignPythonOutfitZS.setId(null);
|
|
||||||
// tDesignPythonOutfitZS.setDesignItemId(designItemZS.getId());
|
|
||||||
// tDesignPythonOutfitZS.setCollectionId(collectionZS.getId());
|
|
||||||
// tDesignPythonOutfitZS.setUserId(11420L);
|
|
||||||
// tDesignPythonOutfitZS.setDesignId(designZS.getId());
|
|
||||||
// designPythonOutfitZSMapper.insert(tDesignPythonOutfitZS);
|
|
||||||
//
|
|
||||||
// userLikeZS.setUserLikeGroupId(userLikeGroupZS.getId());
|
|
||||||
// userLikeZS.setDesignId(designZS.getId());
|
|
||||||
// userLikeZS.setDesignOutfitId(tDesignPythonOutfitZS.getId());
|
|
||||||
// userLikeZSMapper.insert(userLikeZS);
|
|
||||||
//
|
|
||||||
// QueryWrapper<TDesignPythonOutfitDetail> designPythonOutfitDetailQueryWrapper = new QueryWrapper<>();
|
|
||||||
// designPythonOutfitDetailQueryWrapper.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, tDesignPythonOutfit.getId());
|
|
||||||
// List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(designPythonOutfitDetailQueryWrapper);
|
|
||||||
// for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
|
||||||
// com.ai.da.mapper.third.entity.TDesignPythonOutfitDetail tDesignPythonOutfitDetailZS = CopyUtil.copyObject(tDesignPythonOutfitDetail, com.ai.da.mapper.third.entity.TDesignPythonOutfitDetail.class);
|
|
||||||
// tDesignPythonOutfitDetailZS.setDesignPythonOutfitId(tDesignPythonOutfitZS.getId());
|
|
||||||
// tDesignPythonOutfitDetailZS.setId(null);
|
|
||||||
// tDesignPythonOutfitDetailZS.setDesignId(designZS.getId());
|
|
||||||
// designPythonOutfitDetailZSMapper.insert(tDesignPythonOutfitDetailZS);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package com.ai.da.common.task;
|
|
||||||
|
|
||||||
import com.ai.da.common.enums.PayTypeEnum;
|
|
||||||
import com.ai.da.mapper.primary.entity.OrderInfo;
|
|
||||||
import com.ai.da.service.OrderInfoService;
|
|
||||||
import com.ai.da.service.PayPalCheckoutService;
|
|
||||||
import com.paypal.http.exceptions.SerializeException;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class PaypalTask {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private OrderInfoService orderInfoService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private PayPalCheckoutService payPalCheckoutService;
|
|
||||||
|
|
||||||
// @Scheduled(cron = "0/30 * * * * ?")
|
|
||||||
public void orderConfirm() throws SerializeException {
|
|
||||||
|
|
||||||
// log.info("PayPal orderConfirm 被执行......");
|
|
||||||
|
|
||||||
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(30, PayTypeEnum.PAYPAL.getType());
|
|
||||||
|
|
||||||
for (OrderInfo orderInfo : orderInfoList) {
|
|
||||||
String orderNo = orderInfo.getOrderNo();
|
|
||||||
log.warn("超时订单 ===> {}", orderNo);
|
|
||||||
|
|
||||||
//核实订单状态:调用支付宝查单接口
|
|
||||||
payPalCheckoutService.checkOrderStatus(orderNo);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package com.ai.da.common.task;
|
|
||||||
|
|
||||||
import com.ai.da.common.enums.PayTypeEnum;
|
|
||||||
import com.ai.da.mapper.primary.entity.OrderInfo;
|
|
||||||
import com.ai.da.service.OrderInfoService;
|
|
||||||
import com.ai.da.service.StripeService;
|
|
||||||
import com.paypal.http.exceptions.SerializeException;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class StripeTask {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private OrderInfoService orderInfoService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private StripeService stripeService;
|
|
||||||
|
|
||||||
// @Scheduled(cron = "0/30 * * * * ?")
|
|
||||||
public void orderConfirm() throws SerializeException {
|
|
||||||
|
|
||||||
// 查看超过30分钟以上仍未支付的订单 置为超时订单
|
|
||||||
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(30, PayTypeEnum.STRIPE.getType());
|
|
||||||
|
|
||||||
for (OrderInfo orderInfo : orderInfoList) {
|
|
||||||
String orderNo = orderInfo.getOrderNo();
|
|
||||||
log.warn("超时订单 ===> {}", orderNo);
|
|
||||||
|
|
||||||
//核实订单状态:调用支付宝查单接口
|
|
||||||
stripeService.checkOrderStatus(orderNo);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,13 +27,12 @@ public class AccessLimitUtils {
|
|||||||
Integer useCount= LocalCacheUtils.getAidaInterfaceCurrentLimitingCache(interfaceName);
|
Integer useCount= LocalCacheUtils.getAidaInterfaceCurrentLimitingCache(interfaceName);
|
||||||
if(useCount >count){
|
if(useCount >count){
|
||||||
//系统繁忙
|
//系统繁忙
|
||||||
throw new BusinessException("system.busy");
|
throw new BusinessException("system busy !");
|
||||||
}else{
|
}else{
|
||||||
useCount ++;
|
useCount ++;
|
||||||
LocalCacheUtils.setAidaInterfaceCurrentLimitingCache(interfaceName,useCount);
|
LocalCacheUtils.setAidaInterfaceCurrentLimitingCache(interfaceName,useCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验过后 接口完毕 去掉限流
|
* 校验过后 接口完毕 去掉限流
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,383 +0,0 @@
|
|||||||
package com.ai.da.common.utils;
|
|
||||||
|
|
||||||
import cn.hutool.core.io.resource.ClassPathResource;
|
|
||||||
import com.ai.da.model.dto.AlipayHKParametersDTO;
|
|
||||||
import com.ai.da.model.dto.AlipayHKRequestDTO;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
|
|
||||||
import org.bouncycastle.crypto.digests.SHA256Digest;
|
|
||||||
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
|
|
||||||
import org.bouncycastle.crypto.signers.RSADigestSigner;
|
|
||||||
import org.bouncycastle.crypto.util.PublicKeyFactory;
|
|
||||||
import org.bouncycastle.openssl.PEMParser;
|
|
||||||
import org.bouncycastle.util.io.pem.PemObject;
|
|
||||||
import org.bouncycastle.util.io.pem.PemReader;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.crypto.*;
|
|
||||||
import javax.crypto.spec.IvParameterSpec;
|
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
|
||||||
import java.io.*;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.security.*;
|
|
||||||
import java.security.spec.PKCS8EncodedKeySpec;
|
|
||||||
import java.security.spec.X509EncodedKeySpec;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Base64;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class AlipayHKEncryptionUtil {
|
|
||||||
|
|
||||||
@Value("${alipayHK.merchantId}")
|
|
||||||
private String merchantId;
|
|
||||||
|
|
||||||
@Value("${alipayHK.segmentId}")
|
|
||||||
private String segmentId;
|
|
||||||
|
|
||||||
@Value("${alipayHK.AESKey}")
|
|
||||||
private String aesKey;
|
|
||||||
|
|
||||||
@Value("${alipayHK.rsaPrivateKey}")
|
|
||||||
private String privateKeyPath;
|
|
||||||
|
|
||||||
@Value("${alipayHK.rsaPublicKey}")
|
|
||||||
private String publicKeyPath;
|
|
||||||
|
|
||||||
@Value("${alipayHK.CODPublicKey}")
|
|
||||||
private String CODPublicKeyPath;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加密
|
|
||||||
* @param param
|
|
||||||
* @param serviceName
|
|
||||||
* @return
|
|
||||||
* @throws NoSuchPaddingException
|
|
||||||
* @throws NoSuchAlgorithmException
|
|
||||||
* @throws InvalidAlgorithmParameterException
|
|
||||||
* @throws InvalidKeyException
|
|
||||||
* @throws IllegalBlockSizeException
|
|
||||||
* @throws BadPaddingException
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public AlipayHKRequestDTO AESCBCWithRSA(HashMap<String, Object> param, String serviceName) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException {
|
|
||||||
// Pre-shared secret key, DO NOT hardcode this key
|
|
||||||
String key = aesKey;
|
|
||||||
// The path to the rsa private key file, DO NOT save this key to a publicly accessible location
|
|
||||||
// 使用私钥创建数字签名
|
|
||||||
// Mode, aes-128-cbc for 128bit key
|
|
||||||
// String mode = "aes-128-cbc";
|
|
||||||
String mode = "aes-256-cbc";
|
|
||||||
// Padding mode
|
|
||||||
String padding = "pkcs7";
|
|
||||||
// signature alogrithm
|
|
||||||
String signatureAlgorithm = "rsa-sha256";
|
|
||||||
// String signatureAlgorithm = "SHA256withRSA";
|
|
||||||
// Message body
|
|
||||||
AlipayHKParametersDTO requestMessage = new AlipayHKParametersDTO();
|
|
||||||
requestMessage.setService(serviceName);
|
|
||||||
requestMessage.setMerchant_id(merchantId);
|
|
||||||
requestMessage.setRequest_time(Long.toString(System.currentTimeMillis() / 1000L));
|
|
||||||
requestMessage.setRequest_uuid(UUID.randomUUID().toString());
|
|
||||||
// HashMap<String, Object> param = new HashMap<>();
|
|
||||||
requestMessage.setParameters(param);
|
|
||||||
|
|
||||||
// Serialize message body
|
|
||||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
|
||||||
String content = gson.toJson(requestMessage);
|
|
||||||
log.info("alipay-hk request 加密前:{}", content);
|
|
||||||
|
|
||||||
// Secure random iv 获取随机种子
|
|
||||||
SecureRandom secureRandom = new SecureRandom();
|
|
||||||
byte[] iv = new byte[16]; //NEVER REUSE THIS IV WITH THE SAME KEY
|
|
||||||
secureRandom.nextBytes(iv);
|
|
||||||
|
|
||||||
// Algorithms
|
|
||||||
String alogrithm = "AES/CBC/PKCS5Padding";
|
|
||||||
|
|
||||||
// 创建 AES 密钥对象
|
|
||||||
SecretKey secretKey = new SecretKeySpec(key.getBytes(), "AES");
|
|
||||||
// 为加密算法提供一个随机的初始化向量,以增强加密安全性
|
|
||||||
IvParameterSpec parameterSpec = new IvParameterSpec(iv);
|
|
||||||
// 创建 Cipher 对象
|
|
||||||
Cipher cipher = Cipher.getInstance(alogrithm);
|
|
||||||
// 初始化为加密模式 Cipher.ENCRYPT_MODE
|
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey, parameterSpec);
|
|
||||||
|
|
||||||
// Cipher text 对请求内容加密
|
|
||||||
byte[] cipherText = cipher.doFinal(content.getBytes());
|
|
||||||
|
|
||||||
// Concat iv and cipher text for signing
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
outputStream.write(iv);
|
|
||||||
outputStream.write(cipherText);
|
|
||||||
byte signMessage[] = outputStream.toByteArray();
|
|
||||||
|
|
||||||
// Sign key 读取rsa私钥文件,解析并得到私钥对象 privateKey
|
|
||||||
String rsaPrivateKeyPath = privateKeyPath;
|
|
||||||
PrivateKey privateKey = null;
|
|
||||||
byte[] signature;
|
|
||||||
try {
|
|
||||||
privateKey = readPrivateKeyFromFile(rsaPrivateKeyPath);
|
|
||||||
Signature signer = Signature.getInstance("SHA256withRSA");
|
|
||||||
signer.initSign(privateKey);
|
|
||||||
// 将加密内容和随机向量均加签
|
|
||||||
signer.update(signMessage);
|
|
||||||
signature = signer.sign();
|
|
||||||
} catch (SignatureException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
Base64.Encoder encoder = Base64.getEncoder();
|
|
||||||
// Combine result
|
|
||||||
AlipayHKRequestDTO alipayHKRequestDTO = new AlipayHKRequestDTO();
|
|
||||||
alipayHKRequestDTO.setMerchant_id(merchantId);
|
|
||||||
alipayHKRequestDTO.setNonce(encoder.encodeToString(iv));
|
|
||||||
alipayHKRequestDTO.setMessage(encoder.encodeToString(cipherText));
|
|
||||||
alipayHKRequestDTO.setTag(encoder.encodeToString(signature));
|
|
||||||
String cipherSuite = mode + "-" + padding + "-with-" + signatureAlgorithm;
|
|
||||||
alipayHKRequestDTO.setCipher_suite(cipherSuite);
|
|
||||||
|
|
||||||
// Encode to json
|
|
||||||
String jsonEncoded = JSONObject.toJSONString(alipayHKRequestDTO);
|
|
||||||
log.info("alipay-hk request 加密加签后:{}",jsonEncoded);
|
|
||||||
|
|
||||||
// String info = AlipayHKRequestUtil.createOrder(alipayHKRequestDTO);
|
|
||||||
// log.info(info);
|
|
||||||
return alipayHKRequestDTO;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从文件中读取RSA私钥
|
|
||||||
* @param filePath
|
|
||||||
* @return
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
private static PrivateKey readPrivateKeyFromFile(String filePath) throws Exception {
|
|
||||||
ClassPathResource classPathResource = new ClassPathResource(filePath);
|
|
||||||
InputStream inputstream = classPathResource.getStream();
|
|
||||||
String privateKeyContent = getString(inputstream);
|
|
||||||
|
|
||||||
// 进行 Base64 解码
|
|
||||||
byte[] privateKeyBytes = Base64.getDecoder().decode(privateKeyContent);
|
|
||||||
|
|
||||||
// 根据 PKCS8 格式的私钥字节数组构造私钥对象
|
|
||||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
|
||||||
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
|
|
||||||
return keyFactory.generatePrivate(keySpec);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private static String getString(InputStream inputstream) throws IOException {
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream));
|
|
||||||
// BufferedReader reader = new BufferedReader(new FileReader(filePath));
|
|
||||||
StringBuilder keyBuffer = new StringBuilder();
|
|
||||||
String line;
|
|
||||||
|
|
||||||
// 读取文本文件中的内容
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
keyBuffer.append(line);
|
|
||||||
}
|
|
||||||
reader.close();
|
|
||||||
|
|
||||||
// 去除私钥内容中的头部和尾部信息
|
|
||||||
String privateKeyContent = keyBuffer.toString()
|
|
||||||
.replace("-----BEGIN PRIVATE KEY-----", "")
|
|
||||||
.replace("-----END PRIVATE KEY-----", "")
|
|
||||||
.replaceAll("\\s+", ""); // 去除空格、换行等字符
|
|
||||||
return privateKeyContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用 AES 密钥和随机向量进行解密
|
|
||||||
*/
|
|
||||||
public String decryptAES(String encryptedText, String iv) throws Exception {
|
|
||||||
byte[] encryptedBytes = Base64.getDecoder().decode(encryptedText);
|
|
||||||
byte[] ivBytes = Base64.getDecoder().decode(iv);
|
|
||||||
|
|
||||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
|
||||||
SecretKeySpec secretKeySpec = new SecretKeySpec(aesKey.getBytes(), "AES");
|
|
||||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(ivBytes);
|
|
||||||
|
|
||||||
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec);
|
|
||||||
byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
|
|
||||||
|
|
||||||
return new String(decryptedBytes, StandardCharsets.UTF_8);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void test() throws Exception {
|
|
||||||
// 加密数据
|
|
||||||
AlipayHKParametersDTO requestMessage = new AlipayHKParametersDTO();
|
|
||||||
requestMessage.setService("create_order");
|
|
||||||
requestMessage.setMerchant_id(merchantId);
|
|
||||||
requestMessage.setRequest_time(Long.toString(System.currentTimeMillis() / 1000L));
|
|
||||||
requestMessage.setRequest_uuid(UUID.randomUUID().toString());
|
|
||||||
HashMap<String, Object> param = new HashMap<>();
|
|
||||||
requestMessage.setParameters(param);
|
|
||||||
String orderRef = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
|
||||||
param.put("order_ref", orderRef);
|
|
||||||
param.put("amount", 208.12);
|
|
||||||
param.put("subject", "四月帳單 April Bill");
|
|
||||||
param.put("wallet", "ALIPAYHK");
|
|
||||||
param.put("segment_id", segmentId);
|
|
||||||
param.put("payment_solution", "WAP");
|
|
||||||
Gson gson = new Gson();
|
|
||||||
String plaintext = gson.toJson(requestMessage);
|
|
||||||
System.out.println(plaintext);
|
|
||||||
|
|
||||||
// 生成 AES 密钥
|
|
||||||
String key = aesKey;
|
|
||||||
SecretKey aesKey = new SecretKeySpec(key.getBytes(), "AES");
|
|
||||||
|
|
||||||
// 使用 RSA 公钥加密 AES 密钥
|
|
||||||
String rsaPublicKeyPath = publicKeyPath;
|
|
||||||
PublicKey publicKey = readPublicKey(rsaPublicKeyPath);
|
|
||||||
|
|
||||||
Cipher rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
|
|
||||||
// Cipher rsaCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
|
||||||
rsaCipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
|
||||||
byte[] encryptedAesKey = rsaCipher.doFinal(aesKey.getEncoded());
|
|
||||||
|
|
||||||
// 使用 AES-128-CBC 加密数据
|
|
||||||
Cipher aesCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
|
||||||
byte[] ivBytes = generateRandomIV(aesCipher.getBlockSize());
|
|
||||||
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
|
|
||||||
|
|
||||||
aesCipher.init(Cipher.ENCRYPT_MODE, aesKey, ivSpec);
|
|
||||||
byte[] encryptedData = aesCipher.doFinal(plaintext.getBytes());
|
|
||||||
|
|
||||||
// 数字签名(使用 RSA 私钥)
|
|
||||||
String rsaPrivateKeyPath = privateKeyPath;
|
|
||||||
PrivateKey privateKey = readPrivateKeyFromFile(rsaPrivateKeyPath);
|
|
||||||
Signature signer = Signature.getInstance("SHA256withRSA");
|
|
||||||
signer.initSign(privateKey);
|
|
||||||
signer.update(encryptedData);
|
|
||||||
byte[] signatureBytes = signer.sign();
|
|
||||||
Base64.Encoder encoder = Base64.getEncoder();
|
|
||||||
|
|
||||||
// 将加密后的数据和签名进行Base64编码
|
|
||||||
String base64EncryptedData = Base64.getEncoder().encodeToString(encryptedData);
|
|
||||||
String base64Signature = Base64.getEncoder().encodeToString(signatureBytes);
|
|
||||||
|
|
||||||
// 输出加密后的数据和签名
|
|
||||||
System.out.println("加密后的数据:" + base64EncryptedData);
|
|
||||||
System.out.println("数字签名:" + base64Signature);
|
|
||||||
|
|
||||||
|
|
||||||
HashMap<String, String> result = new HashMap<String, String>();
|
|
||||||
result.put("merchant_id",merchantId);
|
|
||||||
result.put("nonce", encoder.encodeToString(ivBytes));
|
|
||||||
result.put("message", encoder.encodeToString(encryptedData));
|
|
||||||
result.put("tag", encoder.encodeToString(signatureBytes));
|
|
||||||
|
|
||||||
String mode = "aes-128-cbc";
|
|
||||||
// Padding mode
|
|
||||||
String padding = "pkcs7";
|
|
||||||
// signature alogrithm
|
|
||||||
String signatureAlgorithm = "rsa-sha256";
|
|
||||||
String cipherSuite = mode + "-" + padding + "-with-" + signatureAlgorithm;
|
|
||||||
result.put("cipher_suite", cipherSuite);
|
|
||||||
|
|
||||||
System.out.println("map 格式:" + result);
|
|
||||||
// Encode to json
|
|
||||||
String jsonEncoded = JSONObject.toJSONString(result);
|
|
||||||
System.out.println("json 格式:" + jsonEncoded);
|
|
||||||
|
|
||||||
AlipayHKRequestDTO alipayHKRequestDTO = new AlipayHKRequestDTO();
|
|
||||||
alipayHKRequestDTO.setMerchant_id(merchantId);
|
|
||||||
alipayHKRequestDTO.setNonce(encoder.encodeToString(ivBytes));
|
|
||||||
alipayHKRequestDTO.setMessage(encoder.encodeToString(encryptedData));
|
|
||||||
alipayHKRequestDTO.setTag(encoder.encodeToString(signatureBytes));
|
|
||||||
alipayHKRequestDTO.setCipher_suite(cipherSuite);
|
|
||||||
|
|
||||||
// String info = AlipayHKRequestUtil.createOrder(result);
|
|
||||||
// log.info(info);
|
|
||||||
|
|
||||||
// 解密和验证
|
|
||||||
// byte[] decryptedAesKey = rsaCipher.doFinal(encryptedAesKey);
|
|
||||||
byte[] decryptedAesKey = rsaCipher.doFinal(aesKey.getEncoded());
|
|
||||||
SecretKey decryptedAesSecretKey = new SecretKeySpec(decryptedAesKey, "AES");
|
|
||||||
|
|
||||||
aesCipher.init(Cipher.DECRYPT_MODE, decryptedAesSecretKey, ivSpec);
|
|
||||||
byte[] decryptedData = aesCipher.doFinal(Base64.getDecoder().decode(base64EncryptedData));
|
|
||||||
|
|
||||||
// 验证数字签名
|
|
||||||
Signature verifier = Signature.getInstance("SHA256withRSA");
|
|
||||||
verifier.initVerify(publicKey);
|
|
||||||
verifier.update(decryptedData);
|
|
||||||
boolean signatureValid = verifier.verify(Base64.getDecoder().decode(base64Signature));
|
|
||||||
|
|
||||||
System.out.println("解密后的数据:" + new String(decryptedData));
|
|
||||||
System.out.println("数字签名验证结果:" + signatureValid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// public static PublicKey readPublicKey(File file) throws Exception {
|
|
||||||
public static PublicKey readPublicKey(String fileName) throws Exception {
|
|
||||||
KeyFactory factory = KeyFactory.getInstance("RSA");
|
|
||||||
|
|
||||||
ClassPathResource classPathResource = new ClassPathResource(fileName);
|
|
||||||
InputStream inputStream = classPathResource.getStream();
|
|
||||||
BufferedReader fileReader = new BufferedReader(new InputStreamReader(inputStream));
|
|
||||||
try (PemReader pemReader = new PemReader(fileReader)) {
|
|
||||||
|
|
||||||
PemObject pemObject = pemReader.readPemObject();
|
|
||||||
byte[] content = pemObject.getContent();
|
|
||||||
X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(content);
|
|
||||||
return factory.generatePublic(pubKeySpec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static byte[] generateRandomIV(int blockSize) {
|
|
||||||
SecureRandom random = new SecureRandom();
|
|
||||||
byte[] iv = new byte[blockSize];
|
|
||||||
random.nextBytes(iv);
|
|
||||||
return iv;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean signatureVerification(String data, String signatureBase64){
|
|
||||||
|
|
||||||
Base64.Decoder decoder = Base64.getDecoder();
|
|
||||||
// Verify key
|
|
||||||
try {
|
|
||||||
ClassPathResource classPathResource = new ClassPathResource(CODPublicKeyPath);
|
|
||||||
InputStream inputstream = classPathResource.getStream();
|
|
||||||
// 从指定的路径读取公钥文件
|
|
||||||
InputStreamReader isrPub = new InputStreamReader(inputstream);
|
|
||||||
PEMParser pemParserPub = new PEMParser(isrPub);
|
|
||||||
// 使用 PEMParser 解析公钥文件
|
|
||||||
SubjectPublicKeyInfo pubInfo = (SubjectPublicKeyInfo) pemParserPub.readObject();
|
|
||||||
// 从 SubjectPublicKeyInfo 创建 AsymmetricKeyParameter 对象
|
|
||||||
AsymmetricKeyParameter pubKey = PublicKeyFactory.createKey(pubInfo);
|
|
||||||
// Verifying; 创建 RSADigestSigner 对象并使用 SHA-256 作为摘要算法
|
|
||||||
RSADigestSigner verifier = new RSADigestSigner(new SHA256Digest());
|
|
||||||
// 初始化 RSADigestSigner,设置为验证模式并提供公钥参数
|
|
||||||
verifier.init(false, pubKey);
|
|
||||||
// 将要验证的数据转换为字节数组
|
|
||||||
byte[] signMessageForVerifying = data.getBytes();
|
|
||||||
// 将 Base64 编码的签名转换为字节数组
|
|
||||||
byte[] signatureBase64ForVerifying = decoder.decode(signatureBase64);
|
|
||||||
// 使用签名器更新要验证的数据
|
|
||||||
verifier.update(signMessageForVerifying, 0, signMessageForVerifying.length);
|
|
||||||
// 验证签名并返回结果
|
|
||||||
Boolean verifyResult = verifier.verifySignature(signatureBase64ForVerifying);
|
|
||||||
return verifyResult;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
package com.ai.da.common.utils;
|
|
||||||
|
|
||||||
import com.ai.da.common.config.exception.BusinessException;
|
|
||||||
import com.ai.da.model.dto.AlipayHKRequestDTO;
|
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import okhttp3.*;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class AlipayHKRequestUtil {
|
|
||||||
|
|
||||||
public String requestAlipayHK(AlipayHKRequestDTO alipayHKRequestDTO) {
|
|
||||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
||||||
.connectTimeout(30, TimeUnit.SECONDS)
|
|
||||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
|
||||||
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
|
|
||||||
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
|
|
||||||
.build();
|
|
||||||
MediaType mediaType = MediaType.parse("application/json;charset=utf-8");
|
|
||||||
long epochMilli = Instant.now().toEpochMilli();
|
|
||||||
log.info("Alipay-HK send request unix timestamp: {}", epochMilli);
|
|
||||||
|
|
||||||
String jsonString = JSONObject.toJSONString(alipayHKRequestDTO, SerializerFeature.WriteMapNullValue);
|
|
||||||
// log.info(jsonString);
|
|
||||||
|
|
||||||
RequestBody body = RequestBody.create(mediaType, jsonString);
|
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
|
||||||
// .url("https://aqs-api.sandbox-codpayment.com/v1/service")
|
|
||||||
.url("https://aqs-api.codpayment.com/v1/service")
|
|
||||||
.method("POST", body)
|
|
||||||
.addHeader("Content-Type", "application/json;charset=utf-8")
|
|
||||||
.build();
|
|
||||||
Response response;
|
|
||||||
String bodyString;
|
|
||||||
try {
|
|
||||||
response = client.newCall(request).execute();
|
|
||||||
assert response.body() != null;
|
|
||||||
bodyString = response.body().string();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new BusinessException(e.getMessage());
|
|
||||||
}
|
|
||||||
JSONObject jsonObject = JSONObject.parseObject(bodyString);
|
|
||||||
boolean success = (boolean) jsonObject.get("success");
|
|
||||||
if (success){
|
|
||||||
return bodyString;
|
|
||||||
} else {
|
|
||||||
String message = jsonObject.get("error_code").toString() + ":" + jsonObject.get("error");
|
|
||||||
log.error("Alipay return message : {}", message);
|
|
||||||
throw new BusinessException("Alipay return message : " + message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
package com.ai.da.common.utils;
|
|
||||||
|
|
||||||
import com.ai.da.common.config.exception.BusinessException;
|
|
||||||
import com.ai.da.model.dto.GenerateToPythonDTO;
|
|
||||||
import com.ai.da.python.PythonService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.*;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class AsyncCallerUtil {
|
|
||||||
|
|
||||||
// 存放状态 表示当前任务是否需要继续等待,默认持续等待
|
|
||||||
public static Map<String, Boolean> waitingStatus = new HashMap<>();
|
|
||||||
|
|
||||||
private static PythonService pythonService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public void setPythonService(PythonService pythonService) {
|
|
||||||
AsyncCallerUtil.pythonService = pythonService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletableFuture<List<String>> callGenerateAsync(GenerateToPythonDTO generateToPython) {
|
|
||||||
// return CompletableFuture.supplyAsync(() -> pythonService.generateSketchOrPrint(generateToPython));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> generate(GenerateToPythonDTO generateToPython) {
|
|
||||||
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(5);
|
|
||||||
String taskId = generateToPython.getTasks_id();
|
|
||||||
ScheduledFuture<?> timeoutTask = null;
|
|
||||||
if (!waitingStatus.containsKey(taskId)) waitingStatus.put(taskId, true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
CompletableFuture<List<String>> generateResult = callGenerateAsync(generateToPython);
|
|
||||||
// 5秒后第一次确认,之后每隔10秒确认一次用户选择结果
|
|
||||||
timeoutTask = scheduledExecutorService.scheduleAtFixedRate(() -> {
|
|
||||||
// 调用另一个接口获取用户的选择
|
|
||||||
if (!waitingStatus.get(taskId)) {
|
|
||||||
// 如果用户选择取消,则取消对generate的调用
|
|
||||||
generateResult.cancel(true);
|
|
||||||
waitingStatus.remove(taskId);
|
|
||||||
} else log.info("===============持续等待===============");
|
|
||||||
}, 5, 10, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
log.info("阻塞等待结果...");
|
|
||||||
// 阻塞,等待结果
|
|
||||||
List<String> result = generateResult.get();
|
|
||||||
// 取消定时任务
|
|
||||||
timeoutTask.cancel(true);
|
|
||||||
waitingStatus.remove(taskId);
|
|
||||||
return result;
|
|
||||||
} catch (CancellationException e) {
|
|
||||||
// generateResult.cancel(true);通过抛出异常取消该任务
|
|
||||||
log.info("==========成功取消generate任务==========");
|
|
||||||
return null;
|
|
||||||
} catch (InterruptedException | ExecutionException | BusinessException e) {
|
|
||||||
// 处理异常
|
|
||||||
log.error("发生错误 : " + e, e);
|
|
||||||
// 取消定时任务
|
|
||||||
assert timeoutTask != null;
|
|
||||||
timeoutTask.cancel(true);
|
|
||||||
throw new BusinessException(e.getMessage());
|
|
||||||
} finally {
|
|
||||||
// 关闭线程池
|
|
||||||
// executorService.shutdown();
|
|
||||||
// scheduledExecutorService.shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -12,13 +12,11 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DateUtil {
|
public class DateUtil {
|
||||||
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||||
public static final String YYYYMM = "yyyyMM";
|
public static final String YYYYMM = "yyyyMM";
|
||||||
public static final String YYYY_MM_DD = "yyyyMMdd";
|
public static final String YYYY_MM_DD = "yyyyMMdd";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LocalDate -> Date
|
* LocalDate -> Date
|
||||||
*/
|
*/
|
||||||
@@ -32,10 +30,8 @@ public class DateUtil {
|
|||||||
public static Date asDate(LocalDateTime localDateTime) {
|
public static Date asDate(LocalDateTime localDateTime) {
|
||||||
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* date 装 String
|
* date 装 String
|
||||||
*
|
|
||||||
* @param date
|
* @param date
|
||||||
* @param formatter
|
* @param formatter
|
||||||
* @return
|
* @return
|
||||||
@@ -47,10 +43,8 @@ public class DateUtil {
|
|||||||
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zoneId);
|
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zoneId);
|
||||||
return dateTimeFormatter.format(localDateTime);
|
return dateTimeFormatter.format(localDateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据时区获取时间
|
* 根据时区获取时间
|
||||||
*
|
|
||||||
* @param timeZone "Asia/Tokyo"
|
* @param timeZone "Asia/Tokyo"
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -68,17 +62,4 @@ public class DateUtil {
|
|||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定时区的时间戳的前十位
|
|
||||||
* @param timeZone 时区
|
|
||||||
* @return 当前时间戳的前十位
|
|
||||||
*/
|
|
||||||
public static String getTimeStamp(String timeZone){
|
|
||||||
ZoneId zoneId = ZoneId.of(timeZone);
|
|
||||||
|
|
||||||
long epochSecond = Instant.now().atZone(zoneId).toEpochSecond();
|
|
||||||
|
|
||||||
return String.valueOf(epochSecond).substring(0, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.ai.da.common.utils;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ExcelReader {
|
|
||||||
public static List<List<String>> readExcel(String filePath) throws IOException {
|
|
||||||
List<List<String>> data = new ArrayList<>();
|
|
||||||
try (FileInputStream fis = new FileInputStream(filePath);
|
|
||||||
Workbook workbook = new XSSFWorkbook(fis)) {
|
|
||||||
Sheet sheet = workbook.getSheetAt(0);
|
|
||||||
int numberOfColumns = sheet.getRow(0).getLastCellNum();
|
|
||||||
|
|
||||||
for (int i = 0; i < numberOfColumns; i++) {
|
|
||||||
List<String> columnData = new ArrayList<>();
|
|
||||||
for (Row row : sheet) {
|
|
||||||
Cell cell = row.getCell(i);
|
|
||||||
if (cell != null) {
|
|
||||||
switch (cell.getCellType()) {
|
|
||||||
case STRING:
|
|
||||||
columnData.add(cell.getStringCellValue());
|
|
||||||
break;
|
|
||||||
case NUMERIC:
|
|
||||||
columnData.add(String.valueOf(cell.getNumericCellValue()));
|
|
||||||
break;
|
|
||||||
case BOOLEAN:
|
|
||||||
columnData.add(String.valueOf(cell.getBooleanCellValue()));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// 跳过空单元格或其他类型(比如错误类型)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 只有当这一列有数据时,才添加到结果列表中
|
|
||||||
if (!columnData.isEmpty()) {
|
|
||||||
data.add(columnData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,19 +5,27 @@ import cn.hutool.core.util.IdUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.ai.da.common.config.exception.BusinessException;
|
import com.ai.da.common.config.exception.BusinessException;
|
||||||
import com.ai.da.model.vo.FileVO;
|
import com.ai.da.model.vo.FileVO;
|
||||||
|
import org.apache.tomcat.util.http.fileupload.FileUtils;
|
||||||
|
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.util.FileSystemUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.security.MessageDigest;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
//import org.apache.poi.util.IOUtils;
|
||||||
|
//import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||||
|
|
||||||
public class FileUtil extends cn.hutool.core.io.FileUtil {
|
public class FileUtil extends cn.hutool.core.io.FileUtil {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(com.ai.da.common.utils.FileUtil.class);
|
private static final Logger log = LoggerFactory.getLogger(com.ai.da.common.utils.FileUtil.class);
|
||||||
@@ -144,7 +152,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||||||
}
|
}
|
||||||
return new FileVO(height,width);
|
return new FileVO(height,width);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件尺寸
|
* 获取文件尺寸
|
||||||
*/
|
*/
|
||||||
@@ -163,7 +170,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||||||
}
|
}
|
||||||
return new FileVO(height,width);
|
return new FileVO(height,width);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取远程文件流
|
* 获取远程文件流
|
||||||
*/
|
*/
|
||||||
@@ -175,10 +181,9 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||||||
return url.openStream();
|
return url.openStream();
|
||||||
}catch (IOException ioException){
|
}catch (IOException ioException){
|
||||||
log.error("获取文件尺寸异常###{}###path##{}", ExceptionUtil.stacktraceToString(ioException),path);
|
log.error("获取文件尺寸异常###{}###path##{}", ExceptionUtil.stacktraceToString(ioException),path);
|
||||||
throw new BusinessException("get.file.failed");
|
throw new BusinessException("get file is failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将文件名解析成文件的上传路径
|
* 将文件名解析成文件的上传路径
|
||||||
*/
|
*/
|
||||||
@@ -207,7 +212,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将文件名解析成文件的上传路径
|
* 将文件名解析成文件的上传路径
|
||||||
*/
|
*/
|
||||||
@@ -246,7 +250,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定文件夹下所有文件,不含文件夹里的文件
|
* 获取指定文件夹下所有文件,不含文件夹里的文件
|
||||||
*
|
*
|
||||||
@@ -294,20 +297,5 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断文件是否存在
|
|
||||||
public static boolean isFileExists(String filePath) {
|
|
||||||
File file = new File(filePath);
|
|
||||||
return file.exists() && file.isFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据路径获取文件
|
|
||||||
public static File getFile(String filePath) {
|
|
||||||
File file = new File(filePath);
|
|
||||||
if (file.exists() && file.isFile()) {
|
|
||||||
return file;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ public class ImageUtil {
|
|||||||
static int r,g,b; // 分别用来存放获取的RGB值
|
static int r,g,b; // 分别用来存放获取的RGB值
|
||||||
static int heigth,width;
|
static int heigth,width;
|
||||||
static int id = 0;
|
static int id = 0;
|
||||||
|
|
||||||
public static void find(){
|
public static void find(){
|
||||||
// 读取要操作的图片,这里的图片路径请改成自己要处理的图片
|
// 读取要操作的图片,这里的图片路径请改成自己要处理的图片
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package com.ai.da.common.utils;
|
package com.ai.da.common.utils;
|
||||||
|
|
||||||
|
import com.ai.da.mapper.entity.Collection;
|
||||||
|
import com.ai.da.mapper.entity.SysFile;
|
||||||
import com.ai.da.model.vo.SysFileVO;
|
import com.ai.da.model.vo.SysFileVO;
|
||||||
import com.google.common.cache.*;
|
import com.google.common.cache.*;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -21,8 +25,8 @@ public final class LocalCacheUtils {
|
|||||||
* token
|
* token
|
||||||
*/
|
*/
|
||||||
private static LoadingCache<String, String> tokenCache = loadTokenCache();
|
private static LoadingCache<String, String> tokenCache = loadTokenCache();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
*缓存接口这里是LoadingCache,LoadingCache在缓存项不存在时可以自动加载缓存
|
*缓存接口这里是LoadingCache,LoadingCache在缓存项不存在时可以自动加载缓存
|
||||||
*/
|
*/
|
||||||
private static LoadingCache<String, String> loadTokenCache(){
|
private static LoadingCache<String, String> loadTokenCache(){
|
||||||
@@ -40,7 +44,6 @@ public final class LocalCacheUtils {
|
|||||||
});
|
});
|
||||||
return tokenCache;
|
return tokenCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 邮箱,短信验证码
|
* 邮箱,短信验证码
|
||||||
*/
|
*/
|
||||||
@@ -173,10 +176,8 @@ public final class LocalCacheUtils {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加token本地缓存
|
* 添加token本地缓存
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
@@ -186,7 +187,6 @@ public final class LocalCacheUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取token本地缓存
|
* 获取token本地缓存
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -202,10 +202,8 @@ public final class LocalCacheUtils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除token本地缓存(登出)
|
* 删除token本地缓存(登出)
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -216,10 +214,8 @@ public final class LocalCacheUtils {
|
|||||||
log.error("delTokenCache方法错误", e);
|
log.error("delTokenCache方法错误", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加验证码本地缓存
|
* 添加验证码本地缓存
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
@@ -229,7 +225,6 @@ public final class LocalCacheUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取验证码本地缓存
|
* 获取验证码本地缓存
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -245,10 +240,8 @@ public final class LocalCacheUtils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加系统文本地缓存
|
* 添加系统文本地缓存
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param sysFile
|
* @param sysFile
|
||||||
*/
|
*/
|
||||||
@@ -258,7 +251,6 @@ public final class LocalCacheUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取系统文件本地缓存
|
* 获取系统文件本地缓存
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -271,10 +263,8 @@ public final class LocalCacheUtils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除所有系统文件本地缓存
|
* 清除所有系统文件本地缓存
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static void clearAllSysFileCache() {
|
public static void clearAllSysFileCache() {
|
||||||
@@ -284,10 +274,8 @@ public final class LocalCacheUtils {
|
|||||||
log.error("clearAllSysFileCache方法错误", e);
|
log.error("clearAllSysFileCache方法错误", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加系统文本地缓存,通过类型
|
* 添加系统文本地缓存,通过类型
|
||||||
*
|
|
||||||
* @param level1Type
|
* @param level1Type
|
||||||
* @param sysFileList
|
* @param sysFileList
|
||||||
*/
|
*/
|
||||||
@@ -297,7 +285,6 @@ public final class LocalCacheUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取系统文件本地缓存
|
* 获取系统文件本地缓存
|
||||||
*
|
|
||||||
* @param level2Type
|
* @param level2Type
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -309,10 +296,8 @@ public final class LocalCacheUtils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除所有系统文件本地缓存
|
* 清除所有系统文件本地缓存
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static void clearAllSysFileCacheByLevel2Type() {
|
public static void clearAllSysFileCacheByLevel2Type() {
|
||||||
@@ -322,10 +307,8 @@ public final class LocalCacheUtils {
|
|||||||
log.error("clearAllSysFileCacheByLevel2Type方法错误", e);
|
log.error("clearAllSysFileCacheByLevel2Type方法错误", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加系统文件范围最大最小值本地缓存
|
* 添加系统文件范围最大最小值本地缓存
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
@@ -335,7 +318,6 @@ public final class LocalCacheUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取系统文件范围最大最小值本地缓存
|
* 获取系统文件范围最大最小值本地缓存
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -351,10 +333,8 @@ public final class LocalCacheUtils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除所有系统文件范围最大最小值本地缓存
|
* 清除所有系统文件范围最大最小值本地缓存
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static void clearAllMaxMinValueCache() {
|
public static void clearAllMaxMinValueCache() {
|
||||||
@@ -364,10 +344,8 @@ public final class LocalCacheUtils {
|
|||||||
log.error("clearAllMaxMinValueCache方法错误", e);
|
log.error("clearAllMaxMinValueCache方法错误", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加系design文件进度统计
|
* 添加系design文件进度统计
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
@@ -377,7 +355,6 @@ public final class LocalCacheUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取design文件进度统计
|
* 获取design文件进度统计
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -390,10 +367,8 @@ public final class LocalCacheUtils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进度统计完后 删除进度
|
* 进度统计完后 删除进度
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -407,7 +382,6 @@ public final class LocalCacheUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置本次接口流量数
|
* 设置本次接口流量数
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
@@ -417,7 +391,6 @@ public final class LocalCacheUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取本次接口流量数
|
* 获取本次接口流量数
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -430,49 +403,4 @@ public final class LocalCacheUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 预签名URL缓存
|
|
||||||
*/
|
|
||||||
private static LoadingCache<String, String> presignedUrlCache = CacheBuilder.newBuilder()
|
|
||||||
.concurrencyLevel(10)
|
|
||||||
.expireAfterWrite((24 * 60 - 1), TimeUnit.MINUTES)
|
|
||||||
.initialCapacity(100)
|
|
||||||
.maximumSize(10000)
|
|
||||||
.recordStats()
|
|
||||||
.build(new CacheLoader<String, String>() {
|
|
||||||
@Override
|
|
||||||
public String load(String key) throws Exception {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加预签名URL到缓存
|
|
||||||
*
|
|
||||||
* @param key URL的唯一标识
|
|
||||||
* @param value 预签名URL
|
|
||||||
*/
|
|
||||||
public static void setPresignedUrlCache(String key, String value) {
|
|
||||||
presignedUrlCache.put(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取预签名URL
|
|
||||||
*
|
|
||||||
* @param key URL的唯一标识
|
|
||||||
* @return 预签名URL,如果不存在则返回null
|
|
||||||
*/
|
|
||||||
public static String getPresignedUrlCache(String key) {
|
|
||||||
try {
|
|
||||||
String value = presignedUrlCache.get(key);
|
|
||||||
if ("null".equals(value)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
log.error("getPresignedUrlCache方法错误", e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ public class MD5Utils {
|
|||||||
}
|
}
|
||||||
return md5;
|
return md5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MD5加密文件
|
* MD5加密文件
|
||||||
*
|
*
|
||||||
@@ -75,16 +74,6 @@ public class MD5Utils {
|
|||||||
return md5;
|
return md5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String encryptFile(InputStream inputStream) {
|
|
||||||
String md5 = null;
|
|
||||||
try {
|
|
||||||
md5 = DigestUtils.md5DigestAsHex(inputStream);
|
|
||||||
} catch (IOException ioException) {
|
|
||||||
log.error("文件InputStream md5加密异常ioException##{}", ExceptionUtil.getThrowableList(ioException));
|
|
||||||
}
|
|
||||||
return md5;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) throws FileNotFoundException, IOException {
|
public static void main(String[] args) throws FileNotFoundException, IOException {
|
||||||
File file1 = new File("/Users/yanglei/Documents/阳磊日报2019-04-23.numbers");
|
File file1 = new File("/Users/yanglei/Documents/阳磊日报2019-04-23.numbers");
|
||||||
File file2 = new File("/Users/yanglei/Documents/7777.numbers");
|
File file2 = new File("/Users/yanglei/Documents/7777.numbers");
|
||||||
|
|||||||
@@ -1,540 +0,0 @@
|
|||||||
package com.ai.da.common.utils;
|
|
||||||
|
|
||||||
import com.ai.da.common.config.exception.BusinessException;
|
|
||||||
import com.ai.da.mapper.primary.entity.ObjectItem;
|
|
||||||
import io.minio.*;
|
|
||||||
import io.minio.errors.MinioException;
|
|
||||||
import io.minio.http.Method;
|
|
||||||
import io.minio.messages.DeleteError;
|
|
||||||
import io.minio.messages.DeleteObject;
|
|
||||||
import io.minio.messages.Item;
|
|
||||||
import io.netty.util.internal.StringUtil;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.security.InvalidKeyException;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Base64;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description: minio工具类
|
|
||||||
* @version:3.0
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class MinioUtil {
|
|
||||||
@Autowired
|
|
||||||
private MinioClient minioClient;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* description: 判断bucket是否存在,不存在则创建
|
|
||||||
*
|
|
||||||
* @return: void
|
|
||||||
*/
|
|
||||||
public void existBucket(String name) {
|
|
||||||
try {
|
|
||||||
boolean exists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(name).build());
|
|
||||||
if (!exists) {
|
|
||||||
minioClient.makeBucket(MakeBucketArgs.builder().bucket(name).build());
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建存储bucket
|
|
||||||
*
|
|
||||||
* @param bucketName 存储bucket名称
|
|
||||||
* @return Boolean
|
|
||||||
*/
|
|
||||||
public Boolean makeBucket(String bucketName) {
|
|
||||||
try {
|
|
||||||
minioClient.makeBucket(MakeBucketArgs.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.build());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除存储bucket
|
|
||||||
*
|
|
||||||
* @param bucketName 存储bucket名称
|
|
||||||
* @return Boolean
|
|
||||||
*/
|
|
||||||
public Boolean removeBucket(String bucketName) {
|
|
||||||
try {
|
|
||||||
minioClient.removeBucket(RemoveBucketArgs.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.build());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* description: 上传文件
|
|
||||||
*
|
|
||||||
* @param bucketName
|
|
||||||
* @param path
|
|
||||||
* @param multipartFile
|
|
||||||
* @return: java.lang.String
|
|
||||||
*/
|
|
||||||
public List<String> uploadBatch(String bucketName, String path, MultipartFile[] multipartFile) {
|
|
||||||
List<String> names = new ArrayList<>(multipartFile.length);
|
|
||||||
for (MultipartFile file : multipartFile) {
|
|
||||||
String fileName = file.getOriginalFilename();
|
|
||||||
String[] split = fileName.split("\\.");
|
|
||||||
if (split.length > 1) {
|
|
||||||
fileName = path + "/" + UUID.randomUUID() + "." + split[1];
|
|
||||||
} else {
|
|
||||||
fileName = path + "/" + UUID.randomUUID();
|
|
||||||
}
|
|
||||||
InputStream in = null;
|
|
||||||
try {
|
|
||||||
in = file.getInputStream();
|
|
||||||
minioClient.putObject(PutObjectArgs.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.object(fileName)
|
|
||||||
.stream(in, in.available(), -1)
|
|
||||||
.contentType(file.getContentType())
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
if (in != null) {
|
|
||||||
try {
|
|
||||||
in.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
names.add(fileName);
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String uploadImageFromBase64(String bucketName, String base64Image, String imageType) {
|
|
||||||
byte[] imageBytes = Base64.getDecoder().decode(base64Image);
|
|
||||||
String fileName = UUID.randomUUID().toString() + "." + imageType; // or any other image format
|
|
||||||
|
|
||||||
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
|
|
||||||
minioClient.putObject(PutObjectArgs.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.object(fileName)
|
|
||||||
.stream(in, in.available(), -1)
|
|
||||||
.contentType("image/png") // Set the content type according to your image format
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
|
|
||||||
return bucketName + "/" + fileName;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null; // or throw an exception
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* description: 上传文件
|
|
||||||
*
|
|
||||||
* @param bucketName
|
|
||||||
* @param path
|
|
||||||
* @param file
|
|
||||||
* @return: java.lang.String
|
|
||||||
*/
|
|
||||||
public String upload(String bucketName, String path, MultipartFile file) {
|
|
||||||
String fileName = file.getOriginalFilename();
|
|
||||||
String[] split = fileName.split("\\.");
|
|
||||||
if (split.length > 1) {
|
|
||||||
fileName = path + "/" + UUID.randomUUID() + "." + split[split.length - 1];
|
|
||||||
} else {
|
|
||||||
fileName = path + "/" + UUID.randomUUID();
|
|
||||||
}
|
|
||||||
InputStream in = null;
|
|
||||||
try {
|
|
||||||
in = file.getInputStream();
|
|
||||||
minioClient.putObject(PutObjectArgs.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.object(fileName)
|
|
||||||
.stream(in, in.available(), -1)
|
|
||||||
.contentType(file.getContentType())
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
if (in != null) {
|
|
||||||
try {
|
|
||||||
in.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bucketName + "/" + fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String upload(String bucketName, String path, MultipartFile file, String copy) {
|
|
||||||
InputStream in = null;
|
|
||||||
try {
|
|
||||||
in = file.getInputStream();
|
|
||||||
minioClient.putObject(PutObjectArgs.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.object(path)
|
|
||||||
.stream(in, in.available(), -1)
|
|
||||||
.contentType(file.getContentType())
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
if (in != null) {
|
|
||||||
try {
|
|
||||||
in.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bucketName + "/" + path;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public String upload(String bucketName, String path, File file) {
|
|
||||||
// InputStream in = null;
|
|
||||||
// try {
|
|
||||||
// in = new FileInputStream(file);
|
|
||||||
// minioClient.putObject(PutObjectArgs.builder()
|
|
||||||
// .bucket(bucketName)
|
|
||||||
// .object(path)
|
|
||||||
// .stream(in, in.available(), -1)
|
|
||||||
// .contentType(file.getContentType())
|
|
||||||
// .build()
|
|
||||||
// );
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// } finally {
|
|
||||||
// if (in != null) {
|
|
||||||
// try {
|
|
||||||
// in.close();
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return fileName;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public InputStream download(String bucketName, String objectName) throws MinioException, IOException {
|
|
||||||
try {
|
|
||||||
return minioClient.getObject(GetObjectArgs.builder().bucket(bucketName).object(objectName).build());
|
|
||||||
} catch (InvalidKeyException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public InputStream download(String path) throws MinioException, IOException {
|
|
||||||
if (!path.contains("/")) {
|
|
||||||
throw new BusinessException("the.path.is.error");
|
|
||||||
}
|
|
||||||
int index = path.indexOf("/");
|
|
||||||
String bucketName = path.substring(0, index);
|
|
||||||
String objectName = path.substring(index + 1);
|
|
||||||
return download(bucketName, objectName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* description: 下载文件
|
|
||||||
*
|
|
||||||
* @param path
|
|
||||||
* @param bucketName
|
|
||||||
* @return: org.springframework.http.ResponseEntity<byte [ ]>
|
|
||||||
*/
|
|
||||||
// public ResponseEntity<byte[]> download(String path, String bucketName) {
|
|
||||||
// ResponseEntity<byte[]> responseEntity = null;
|
|
||||||
// InputStream in = null;
|
|
||||||
// ByteArrayOutputStream out = null;
|
|
||||||
// try {
|
|
||||||
// in = minioClient.getObject(GetObjectArgs.builder().bucket(bucketName).object(path).build());
|
|
||||||
// out = new ByteArrayOutputStream();
|
|
||||||
// IOUtils.copy(in, out);
|
|
||||||
// //封装返回值
|
|
||||||
// byte[] bytes = out.toByteArray();
|
|
||||||
// HttpHeaders headers = new HttpHeaders();
|
|
||||||
// try {
|
|
||||||
// headers.add("Content-Disposition", "attachment;filename=" + URLEncoder.encode(path, "UTF-8"));
|
|
||||||
// } catch (UnsupportedEncodingException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// headers.setContentLength(bytes.length);
|
|
||||||
// headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
|
||||||
// headers.setAccessControlExposeHeaders(Arrays.asList("*"));
|
|
||||||
// responseEntity = new ResponseEntity<byte[]>(bytes, headers, HttpStatus.OK);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// } finally {
|
|
||||||
// try {
|
|
||||||
// if (in != null) {
|
|
||||||
// try {
|
|
||||||
// in.close();
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (out != null) {
|
|
||||||
// out.close();
|
|
||||||
// }
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return responseEntity;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看文件对象
|
|
||||||
*
|
|
||||||
* @param bucketName 存储bucket名称
|
|
||||||
* @return 存储bucket内文件对象信息
|
|
||||||
*/
|
|
||||||
public List<ObjectItem> listObjects(String bucketName) {
|
|
||||||
Iterable<Result<Item>> results = minioClient.listObjects(
|
|
||||||
ListObjectsArgs.builder().bucket(bucketName).build());
|
|
||||||
List<ObjectItem> objectItems = new ArrayList<>();
|
|
||||||
try {
|
|
||||||
for (Result<Item> result : results) {
|
|
||||||
Item item = result.get();
|
|
||||||
ObjectItem objectItem = new ObjectItem();
|
|
||||||
objectItem.setObjectName(item.objectName());
|
|
||||||
objectItem.setSize(item.size());
|
|
||||||
objectItems.add(objectItem);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return objectItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除文件对象
|
|
||||||
*
|
|
||||||
* @param bucketName 存储bucket名称
|
|
||||||
* @param objects 对象名称集合
|
|
||||||
*/
|
|
||||||
public Iterable<Result<DeleteError>> removeObjects(String bucketName, List<String> objects) {
|
|
||||||
List<DeleteObject> dos = objects.stream().map(e -> new DeleteObject(e)).collect(Collectors.toList());
|
|
||||||
Iterable<Result<DeleteError>> results = minioClient.removeObjects(RemoveObjectsArgs.builder().bucket(bucketName).objects(dos).build());
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteObject(String bucketName, String objectName) {
|
|
||||||
try {
|
|
||||||
minioClient.removeObject(RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build());
|
|
||||||
System.out.println("Object " + objectName + " successfully removed from bucket " + bucketName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
System.err.println("Error while removing object " + objectName + " from bucket " + bucketName + ": " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteObject(String path) {
|
|
||||||
if (!path.contains("/")) {
|
|
||||||
throw new BusinessException("The path is error!");
|
|
||||||
}
|
|
||||||
int index = path.indexOf("/");
|
|
||||||
String bucketName = path.substring(0, index);
|
|
||||||
String objectName = path.substring(index + 1);
|
|
||||||
deleteObject(bucketName, objectName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文件的临时URL
|
|
||||||
*
|
|
||||||
* @param bucketName 存储桶名称
|
|
||||||
* @param fileName 文件名
|
|
||||||
* @param expiry 过期时间(单位:分)
|
|
||||||
* @return 文件的临时URL,如果出现异常则返回null
|
|
||||||
*/
|
|
||||||
public String getPreSignedUrl(String bucketName, String fileName, int expiry) {
|
|
||||||
try {
|
|
||||||
return minioClient.getPresignedObjectUrl(
|
|
||||||
GetPresignedObjectUrlArgs.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.object(fileName)
|
|
||||||
.expiry(expiry, TimeUnit.MINUTES)
|
|
||||||
.method(Method.GET)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
} catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new BusinessException(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPreSignedUrl(String path, int expiry) {
|
|
||||||
if (LocalCacheUtils.getPresignedUrlCache(path) != null) {
|
|
||||||
return LocalCacheUtils.getPresignedUrlCache(path);
|
|
||||||
} else {
|
|
||||||
if (!path.contains("/")) {
|
|
||||||
throw new BusinessException("The path is error!");
|
|
||||||
}
|
|
||||||
int index = path.indexOf("/");
|
|
||||||
String bucketName = path.substring(0, index);
|
|
||||||
String fileName = path.substring(index + 1);
|
|
||||||
String presignedUrl = getPreSignedUrl(bucketName, fileName, expiry);
|
|
||||||
LocalCacheUtils.setPresignedUrlCache(path, presignedUrl);
|
|
||||||
return presignedUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPreSignedUrl(String path, int expiry, boolean resetCache) {
|
|
||||||
if (resetCache || LocalCacheUtils.getPresignedUrlCache(path) == null) {
|
|
||||||
if (!path.contains("/")) {
|
|
||||||
throw new BusinessException("The path is error!");
|
|
||||||
}
|
|
||||||
int index = path.indexOf("/");
|
|
||||||
String bucketName = path.substring(0, index);
|
|
||||||
String fileName = path.substring(index + 1);
|
|
||||||
String presignedUrl = getPreSignedUrl(bucketName, fileName, expiry);
|
|
||||||
LocalCacheUtils.setPresignedUrlCache(path, presignedUrl);
|
|
||||||
return presignedUrl;
|
|
||||||
} else {
|
|
||||||
return LocalCacheUtils.getPresignedUrlCache(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将桶名、文件名从url中分离出来
|
|
||||||
*
|
|
||||||
* @param url 带桶名、文件名的url
|
|
||||||
* @param expiry 图片过期时间
|
|
||||||
* @return 可以直接访问的minio图片地址
|
|
||||||
*/
|
|
||||||
public String splitThenGetPreviewUrl(String url, int expiry) {
|
|
||||||
String[] parts = url.split("/");
|
|
||||||
String bucketName = parts[0];
|
|
||||||
StringBuilder fileName = new StringBuilder();
|
|
||||||
for (int i = 1; i < parts.length; i++) {
|
|
||||||
fileName.append(parts[i]);
|
|
||||||
if (i != parts.length - 1) {
|
|
||||||
fileName.append("/");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getPreSignedUrl(bucketName, String.valueOf(fileName), expiry);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean doesObjectExist(String bucketName, String objectName) {
|
|
||||||
try {
|
|
||||||
minioClient.statObject(
|
|
||||||
StatObjectArgs.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.object(objectName)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
// 如果发生异常,说明文件不存在或者出现了其他错误
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String base64UploadToPath(String base64, String bucketName, String path){
|
|
||||||
String[] parts = base64.split(",");
|
|
||||||
String imageType = parts[0].split("/")[1].split(";")[0];
|
|
||||||
String base64Data = parts[1];
|
|
||||||
|
|
||||||
byte[] imageBytes = Base64.getDecoder().decode(base64Data);
|
|
||||||
String fileName;
|
|
||||||
if (!StringUtil.isNullOrEmpty(path)){
|
|
||||||
fileName = path + "." + imageType; // or any other image format
|
|
||||||
}else {
|
|
||||||
fileName = UUID.randomUUID() + "." + imageType;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
|
|
||||||
minioClient.putObject(PutObjectArgs.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.object(fileName)
|
|
||||||
.stream(in, in.available(), -1)
|
|
||||||
.contentType("image/" + imageType) // Set the content type according to your image format
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
|
|
||||||
return bucketName + "/" + fileName;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
return null; // or throw an exception
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从 MinIO 下载对象到本地路径
|
|
||||||
*
|
|
||||||
* @param bucketName 存储桶名称
|
|
||||||
* @param objectName MinIO 上对象的名称
|
|
||||||
* @param localFilePath 本地文件路径
|
|
||||||
*/
|
|
||||||
public void downloadMinioObjectToLocal(String bucketName, String objectName, String localFilePath) {
|
|
||||||
File localFile = new File(localFilePath);
|
|
||||||
File parentDir = localFile.getParentFile();
|
|
||||||
if (parentDir != null) {
|
|
||||||
parentDir.mkdirs(); // 创建文件夹,确保路径结构与 MinIO 一致
|
|
||||||
}
|
|
||||||
|
|
||||||
try (InputStream stream = minioClient.getObject(
|
|
||||||
GetObjectArgs.builder().bucket(bucketName).object(objectName).build());
|
|
||||||
FileOutputStream out = new FileOutputStream(localFile)) {
|
|
||||||
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int bytesRead;
|
|
||||||
while ((bytesRead = stream.read(buffer)) != -1) {
|
|
||||||
out.write(buffer, 0, bytesRead);
|
|
||||||
}
|
|
||||||
log.info("Downloaded object {} to {}", objectName, localFilePath);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Error while downloading object {}: {}", objectName, e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从路径中提取存储桶名称
|
|
||||||
*
|
|
||||||
* @param path MinIO 路径
|
|
||||||
* @return 存储桶名称
|
|
||||||
*/
|
|
||||||
public String getBucketNameFromPath(String path) {
|
|
||||||
int index = path.indexOf("/");
|
|
||||||
return path.substring(0, index); // 获取第一级路径作为 bucket 名称
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从路径中提取对象名称
|
|
||||||
*
|
|
||||||
* @param path MinIO 路径
|
|
||||||
* @return 对象名称
|
|
||||||
*/
|
|
||||||
public String getObjectNameFromPath(String path) {
|
|
||||||
int index = path.indexOf("/");
|
|
||||||
return path.substring(index + 1); // 获取路径的其余部分作为对象名称
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -45,20 +45,24 @@ public class MultiReadHttpServletRequest extends HttpServletRequestWrapper {
|
|||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
sb.append(line);
|
sb.append(line);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
if (inputStream != null) {
|
if (inputStream != null) {
|
||||||
try {
|
try {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
try {
|
try {
|
||||||
reader.close();
|
reader.close();
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,7 +72,6 @@ public class MultiReadHttpServletRequest extends HttpServletRequestWrapper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 复制输入流
|
* 复制输入流
|
||||||
*
|
|
||||||
* @param inputStream 请求输入流
|
* @param inputStream 请求输入流
|
||||||
* @return 复制出来的输入流
|
* @return 复制出来的输入流
|
||||||
*/
|
*/
|
||||||
@@ -81,7 +84,8 @@ public class MultiReadHttpServletRequest extends HttpServletRequestWrapper {
|
|||||||
byteArrayOutputStream.write(buffer, 0, len);
|
byteArrayOutputStream.write(buffer, 0, len);
|
||||||
}
|
}
|
||||||
byteArrayOutputStream.flush();
|
byteArrayOutputStream.flush();
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
return new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
package com.ai.da.common.utils;
|
package com.ai.da.common.utils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
package com.ai.da.common.utils;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单号工具类
|
|
||||||
*
|
|
||||||
* @author qy
|
|
||||||
* @since 1.0
|
|
||||||
*/
|
|
||||||
public class OrderNoUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取订单编号
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String getOrderNo() {
|
|
||||||
return "ORDER_" + getNo();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取退款单编号
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String getRefundNo() {
|
|
||||||
return "REFUND_" + getNo();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取编号
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String getNo() {
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
||||||
String newDate = sdf.format(new Date());
|
|
||||||
String result = "";
|
|
||||||
Random random = new Random();
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
result += random.nextInt(10);
|
|
||||||
}
|
|
||||||
return newDate + result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package com.ai.da.common.utils;
|
|
||||||
|
|
||||||
public class PantoneUtils {
|
|
||||||
|
|
||||||
public static int[] rgbToHsv(int[] rgb) {
|
|
||||||
//切割rgb数组
|
|
||||||
int red = rgb[0];
|
|
||||||
int green = rgb[1];
|
|
||||||
int blue = rgb[2];
|
|
||||||
|
|
||||||
float r = (float) red / 255;
|
|
||||||
float g = (float) green / 255;
|
|
||||||
float b = (float) blue / 255;
|
|
||||||
|
|
||||||
float min = Math.min(Math.min(r, g), b);
|
|
||||||
|
|
||||||
float[] hsv = {60, 0, Math.max(Math.max(r, g), b)};
|
|
||||||
|
|
||||||
hsv[1] = (hsv[2] == 0) ? 0 : 1 - min / hsv[2];
|
|
||||||
|
|
||||||
hsv[0] = 60 * (
|
|
||||||
(hsv[2] == min) ? Float.NaN :
|
|
||||||
(hsv[2] == r) ? (g - b) / (hsv[2] - min) + ((g < b) ? 6 : 0) :
|
|
||||||
(hsv[2] == g) ? (b - r) / (hsv[2] - min) + 2 :
|
|
||||||
(r - g) / (hsv[2] - min) + 4
|
|
||||||
);
|
|
||||||
|
|
||||||
return new int[]{Math.round(hsv[0]), Math.round(hsv[1] * 100), Math.round(hsv[2] * 100)};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -37,7 +37,6 @@ public class RandomsUtil {
|
|||||||
public static String generateVerifyCode(Long randomStart, Long randomEnd) {
|
public static String generateVerifyCode(Long randomStart, Long randomEnd) {
|
||||||
return String.valueOf(RandomUtil.randomLong(randomStart,randomEnd));
|
return String.valueOf(RandomUtil.randomLong(randomStart,randomEnd));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成随机系统图片
|
* 生成随机系统图片
|
||||||
*
|
*
|
||||||
@@ -48,9 +47,5 @@ public class RandomsUtil {
|
|||||||
return RandomUtil.randomLong(randomStart,randomEnd);
|
return RandomUtil.randomLong(randomStart,randomEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer randomSysFile(Integer randomEnd) {
|
|
||||||
return RandomUtil.randomInt(randomEnd);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,281 +0,0 @@
|
|||||||
package com.ai.da.common.utils;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.data.redis.core.HashOperations;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.data.redis.core.ZSetOperations;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class RedisUtil {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private RedisTemplate<String, String> redisTemplate;
|
|
||||||
|
|
||||||
public Boolean hasKey(String key){
|
|
||||||
return redisTemplate.hasKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
//- - - - - - - - - - - - - - - - - - - - - ZSet类型 - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 向ZSet中添加元素
|
|
||||||
*/
|
|
||||||
public void addToZSet(String key, String value, Double score) {
|
|
||||||
redisTemplate.opsForZSet().add(key, value, score);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从ZSet中删除元素
|
|
||||||
*/
|
|
||||||
public void removeFromZSet(String key, String value) {
|
|
||||||
redisTemplate.opsForZSet().remove(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定元素的当前排列顺序
|
|
||||||
*/
|
|
||||||
public Long getRank(String key, String value) {
|
|
||||||
return redisTemplate.opsForZSet().rank(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前ZSet中的最大score
|
|
||||||
*/
|
|
||||||
public Double getMaxScore(String key) {
|
|
||||||
Set<ZSetOperations.TypedTuple<String>> set = redisTemplate.opsForZSet().reverseRangeWithScores(key, 0, 0);
|
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(set)) {
|
|
||||||
Double score = set.iterator().next().getScore();
|
|
||||||
return score + 1.0;
|
|
||||||
} else {
|
|
||||||
return 1.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断元素是否存在
|
|
||||||
*/
|
|
||||||
public Boolean isElementExistsInZSet(String key, String value) {
|
|
||||||
return redisTemplate.opsForZSet().score(key, value) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前ZSet中数据量的总和
|
|
||||||
*/
|
|
||||||
public Long getZSetTotalCount(String key) {
|
|
||||||
return redisTemplate.opsForZSet().zCard(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Set<String> getZSetTotalData(String key){
|
|
||||||
return redisTemplate.opsForZSet().range(key, 0, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//- - - - - - - - - - - - - - - - - - - - - set类型 - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将数据放入set缓存
|
|
||||||
*/
|
|
||||||
public void addToSet(String key, String value) {
|
|
||||||
redisTemplate.opsForSet().add(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 弹出变量中的元素
|
|
||||||
*/
|
|
||||||
public void removeFromSet(String key, String value) {
|
|
||||||
redisTemplate.opsForSet().remove(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查给定的元素是否在变量中。
|
|
||||||
*/
|
|
||||||
public Boolean isElementExistsInSet(String key, String obj) {
|
|
||||||
return redisTemplate.opsForSet().isMember(key, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//- - - - - - - - - - - - - - - - - - - - - hash类型 - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加入缓存
|
|
||||||
*/
|
|
||||||
public void addToMap(String key, Map<String, String> map) {
|
|
||||||
redisTemplate.opsForHash().putAll(key, map);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证指定 key 下 有没有指定的 hashkey
|
|
||||||
*/
|
|
||||||
public Boolean isElementExistsInMap(String key, String hashKey) {
|
|
||||||
return redisTemplate.opsForHash().hasKey(key, hashKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定key的值string
|
|
||||||
*/
|
|
||||||
public String getMapValue(String key1, String key2) {
|
|
||||||
return String.valueOf(redisTemplate.opsForHash().get(key1, key2));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定 hash 的 HashKey
|
|
||||||
*
|
|
||||||
* @return 删除成功的 数量
|
|
||||||
*/
|
|
||||||
public Long removeFromMap(String key, String hashKeys) {
|
|
||||||
return redisTemplate.opsForHash().delete(key, hashKeys);
|
|
||||||
}
|
|
||||||
|
|
||||||
//- - - - - - - - - - - - - - - - - - - - - String类型 - - - - - - - - - - - - - - - - - - - -
|
|
||||||
public void addToString(String key, String value){
|
|
||||||
redisTemplate.opsForValue().set(key,value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addToString(String key, String value, Long expiresIn){
|
|
||||||
redisTemplate.opsForValue().set(key,value,expiresIn, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFromString(String key){
|
|
||||||
return redisTemplate.opsForValue().get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getKeysFromString(String key){
|
|
||||||
return redisTemplate.keys(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getSize(String key){return redisTemplate.opsForSet().size(key);}
|
|
||||||
|
|
||||||
public List<String> getMultiValue(Set<String> keys){
|
|
||||||
return redisTemplate.opsForValue().multiGet(keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getExpire(String key){
|
|
||||||
return redisTemplate.getExpire(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeFromString(String key){
|
|
||||||
redisTemplate.delete(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final static String PORTFOLIO_LIKE_KEY = "portfolio:like:";
|
|
||||||
|
|
||||||
public void likePost(Long portfolioId, Long userId) {
|
|
||||||
redisTemplate.opsForSet().add(PORTFOLIO_LIKE_KEY + portfolioId, String.valueOf(userId));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getLikeCount(Long portfolioId) {
|
|
||||||
String key = PORTFOLIO_LIKE_KEY + portfolioId;
|
|
||||||
return redisTemplate.opsForSet().size(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Long> getLikedPortfolios(Long userId) {
|
|
||||||
// 获取所有包含PORTFOLIO_LIKE_KEY的键
|
|
||||||
Set<String> likedPortfolios = redisTemplate.keys(PORTFOLIO_LIKE_KEY + "*");
|
|
||||||
|
|
||||||
// 如果没有喜欢的,返回空列表
|
|
||||||
if (likedPortfolios == null || likedPortfolios.isEmpty()) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 过滤出包含指定用户ID的键,并提取投资组合ID
|
|
||||||
return likedPortfolios.stream()
|
|
||||||
.filter(key -> redisTemplate.opsForSet().isMember(key, String.valueOf(userId)))
|
|
||||||
.map(key -> Long.valueOf(key.replace(PORTFOLIO_LIKE_KEY, "")))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unLikePost(Long portfolioId, Long userId) {
|
|
||||||
redisTemplate.opsForSet().remove(PORTFOLIO_LIKE_KEY + portfolioId, userId.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查用户是否喜欢某个作品
|
|
||||||
public boolean isPostLikedByUser(Long portfolioId, Long userId) {
|
|
||||||
String key = PORTFOLIO_LIKE_KEY + portfolioId;
|
|
||||||
Boolean isMember = redisTemplate.opsForSet().isMember(key, userId.toString());
|
|
||||||
return isMember != null && isMember;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final static String PORTFOLIO_VIEW_KEY = "portfolio:view:";
|
|
||||||
|
|
||||||
public void increaseViewCount(Long portfolioId) {
|
|
||||||
String key = PORTFOLIO_VIEW_KEY + portfolioId;
|
|
||||||
redisTemplate.opsForValue().increment(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getViewCount(Long portfolioId) {
|
|
||||||
String key = PORTFOLIO_VIEW_KEY + portfolioId;
|
|
||||||
return redisTemplate.opsForValue().increment(key, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getViewCount(String key) {
|
|
||||||
Object value = redisTemplate.opsForValue().get(key);
|
|
||||||
if (value instanceof Integer) {
|
|
||||||
return Long.valueOf((Integer) value);
|
|
||||||
} else if (value instanceof Long) {
|
|
||||||
return (Long) value;
|
|
||||||
} else if (value instanceof String) {
|
|
||||||
return Long.valueOf((String) value);
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Unexpected value type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final static String PERSONAL_HOMEPAGE_VIEW_KEY = "PersonalHomepage:view:";
|
|
||||||
|
|
||||||
public void increasePersonalHomepageViewCount(Long accountId) {
|
|
||||||
String key = PERSONAL_HOMEPAGE_VIEW_KEY + accountId;
|
|
||||||
redisTemplate.opsForValue().increment(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getPersonalHomepageViewCount(Long accountId) {
|
|
||||||
String key = PERSONAL_HOMEPAGE_VIEW_KEY + accountId;
|
|
||||||
return redisTemplate.opsForValue().increment(key, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final static String MOODBOARD_POSITION_KEY = "moodboard:position:";
|
|
||||||
|
|
||||||
public void saveMoodboardPosition(Long id, String moodboardPosition) {
|
|
||||||
addToString(MOODBOARD_POSITION_KEY + id, moodboardPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMoodboardPosition(Long id) {
|
|
||||||
return getFromString(MOODBOARD_POSITION_KEY + id);
|
|
||||||
}
|
|
||||||
public final static String NICKNAME_MODIFY_TIMES = "NicknameModifyTimes:";
|
|
||||||
public void increaseCount(String key) {
|
|
||||||
redisTemplate.opsForValue().increment(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getIncrementCount(String key) {
|
|
||||||
return redisTemplate.opsForValue().increment(key, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKeyExpire(String key, Long expire) {
|
|
||||||
redisTemplate.expire(key, expire, TimeUnit.DAYS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final static String CHANGE_MAILBOX = "ChangeMailbox:";
|
|
||||||
|
|
||||||
// 每天允许通知3次
|
|
||||||
public final static String UPLOAD_TIMEOUT_REMINDER_COUNTER = "UploadTimeoutReminderCounter";
|
|
||||||
|
|
||||||
public void addProcessId(String processId, int progress) {
|
|
||||||
// Redis 中的键,可以通过 processId 来唯一标识
|
|
||||||
String redisKey = "process:progress:" + processId;
|
|
||||||
|
|
||||||
// 将当前进度存储到 Redis
|
|
||||||
redisTemplate.opsForValue().set(redisKey, String.valueOf(progress));
|
|
||||||
|
|
||||||
// 设置过期时间为 5 分钟(300 秒)
|
|
||||||
redisTemplate.expire(redisKey, 5, TimeUnit.MINUTES);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,8 +10,8 @@ public class RequestInfoUtil {
|
|||||||
* @param request
|
* @param request
|
||||||
* @return java.lang.String
|
* @return java.lang.String
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* <p>
|
*
|
||||||
* <p>
|
*
|
||||||
* 使用了ng等代理服务器要在ng加以下配置
|
* 使用了ng等代理服务器要在ng加以下配置
|
||||||
* location / {
|
* location / {
|
||||||
* proxy_pass http://127.0.0.1:10678;
|
* proxy_pass http://127.0.0.1:10678;
|
||||||
@@ -20,6 +20,7 @@ public class RequestInfoUtil {
|
|||||||
* proxy_set_header REMOTE-HOST $remote_addr;
|
* proxy_set_header REMOTE-HOST $remote_addr;
|
||||||
* proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
* proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
* }
|
* }
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public static String getIpAddress(HttpServletRequest request) {
|
public static String getIpAddress(HttpServletRequest request) {
|
||||||
String ip = request.getHeader("x-forwarded-for");
|
String ip = request.getHeader("x-forwarded-for");
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ public class RsaDecryptUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 解密
|
* 解密
|
||||||
*
|
|
||||||
* @param args
|
* @param args
|
||||||
* @throws NoSuchAlgorithmException
|
* @throws NoSuchAlgorithmException
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,380 +0,0 @@
|
|||||||
package com.ai.da.common.utils;
|
|
||||||
|
|
||||||
import com.ai.da.common.config.exception.BusinessException;
|
|
||||||
import com.ai.da.common.constant.CommonConstant;
|
|
||||||
import io.netty.util.internal.StringUtil;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
|
|
||||||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
|
|
||||||
import software.amazon.awssdk.core.ResponseBytes;
|
|
||||||
import software.amazon.awssdk.core.sync.RequestBody;
|
|
||||||
import software.amazon.awssdk.regions.Region;
|
|
||||||
import software.amazon.awssdk.services.s3.S3Client;
|
|
||||||
import software.amazon.awssdk.services.s3.S3Configuration;
|
|
||||||
import software.amazon.awssdk.services.s3.model.*;
|
|
||||||
import software.amazon.awssdk.services.s3.presigner.S3Presigner;
|
|
||||||
import software.amazon.awssdk.services.s3.presigner.model.GetObjectPresignRequest;
|
|
||||||
import software.amazon.awssdk.services.s3.presigner.model.PresignedGetObjectRequest;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import java.io.*;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class S3Util {
|
|
||||||
|
|
||||||
@Value("${aws.s3.accessKeyId}")
|
|
||||||
private String accessKeyId;
|
|
||||||
|
|
||||||
@Value("${aws.s3.secretKey}")
|
|
||||||
private String secretKey;
|
|
||||||
|
|
||||||
@Value("${aws.s3.regionName}")
|
|
||||||
private String region;
|
|
||||||
|
|
||||||
public static String S3_ACCESS_KEY_ID = null;
|
|
||||||
|
|
||||||
public static String S3_SECRET_KEY = null;
|
|
||||||
|
|
||||||
public static String S3_REGION = null;
|
|
||||||
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void init() {
|
|
||||||
S3_ACCESS_KEY_ID = accessKeyId;
|
|
||||||
S3_SECRET_KEY = secretKey;
|
|
||||||
S3_REGION = region;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static S3Client s3Client;
|
|
||||||
|
|
||||||
private static S3Presigner s3Presigner;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return software.amazon.awssdk.services.s3.S3Client
|
|
||||||
* @description: 获取S3客户端对象
|
|
||||||
*/
|
|
||||||
public synchronized S3Client getS3Client() {
|
|
||||||
if (null == s3Client) {
|
|
||||||
s3Client = S3Client.builder()
|
|
||||||
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(S3_ACCESS_KEY_ID, S3_SECRET_KEY)))
|
|
||||||
// .endpointOverride(URI.create(S3_URI))
|
|
||||||
.serviceConfiguration(item -> item.pathStyleAccessEnabled(true).checksumValidationEnabled(false))
|
|
||||||
.region(Region.of(S3_REGION))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
return s3Client;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return software.amazon.awssdk.services.s3.presigner.S3Presigner
|
|
||||||
* @description: 获取预签名对象
|
|
||||||
*/
|
|
||||||
public synchronized S3Presigner getS3PreSigner() {
|
|
||||||
if (null == s3Presigner) {
|
|
||||||
s3Presigner = S3Presigner.builder()
|
|
||||||
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(S3_ACCESS_KEY_ID, S3_SECRET_KEY)))
|
|
||||||
// .endpointOverride(URI.create(S3_URI))
|
|
||||||
.serviceConfiguration(S3Configuration.builder()
|
|
||||||
.checksumValidationEnabled(false)
|
|
||||||
.pathStyleAccessEnabled(true)
|
|
||||||
.build())
|
|
||||||
.region(Region.of(S3_REGION))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
return s3Presigner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String uploadImageFromBase64(String bucketName, String base64Image, String imageType) {
|
|
||||||
S3Client s3Client = getS3Client();
|
|
||||||
byte[] imageBytes = Base64.getDecoder().decode(base64Image);
|
|
||||||
String fileName = UUID.randomUUID() + "." + imageType; // or any other image format
|
|
||||||
|
|
||||||
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
|
|
||||||
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.contentType("image/png")
|
|
||||||
.contentLength((long) in.available())
|
|
||||||
.key(fileName)
|
|
||||||
.acl(ObjectCannedACL.PUBLIC_READ)
|
|
||||||
.build();
|
|
||||||
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(in, in.available()));
|
|
||||||
|
|
||||||
log.info("uploadImageFromBase64 上传的位置:桶 - {},路径 - {}", bucketName, fileName);
|
|
||||||
return bucketName + "/" + fileName;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null; // or throw an exception
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String upload(String bucketName, String path, MultipartFile file) {
|
|
||||||
S3Client s3Client = getS3Client();
|
|
||||||
try {
|
|
||||||
String fileName = file.getOriginalFilename();
|
|
||||||
assert fileName != null;
|
|
||||||
String[] split = fileName.split("\\.");
|
|
||||||
if (split.length > 1) {
|
|
||||||
fileName = path + "/" + UUID.randomUUID() + "." + split[split.length - 1];
|
|
||||||
} else {
|
|
||||||
fileName = path + "/" + UUID.randomUUID();
|
|
||||||
}
|
|
||||||
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.contentType(file.getContentType())
|
|
||||||
.contentLength(file.getSize())
|
|
||||||
.key(fileName)
|
|
||||||
.acl(ObjectCannedACL.PUBLIC_READ)
|
|
||||||
.build();
|
|
||||||
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(file.getInputStream(), file.getSize()));
|
|
||||||
|
|
||||||
log.info("upload 上传的位置:桶 - {},路径 - {}", bucketName, fileName);
|
|
||||||
return bucketName + "/" + fileName;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("上传文件到S3失败 异常:{}", e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo
|
|
||||||
public String upload(String bucketName, String path, MultipartFile file, String copy) {
|
|
||||||
S3Client s3Client = getS3Client();
|
|
||||||
InputStream in = null;
|
|
||||||
try {
|
|
||||||
in = file.getInputStream();
|
|
||||||
|
|
||||||
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.contentType(file.getContentType())
|
|
||||||
.contentLength(file.getSize())
|
|
||||||
.key(path)
|
|
||||||
.acl(ObjectCannedACL.PUBLIC_READ)
|
|
||||||
.build();
|
|
||||||
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(file.getInputStream(), file.getSize()));
|
|
||||||
log.info("upload-copy 上传的位置:桶 - {},路径 - {}", bucketName, path);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
if (in != null) {
|
|
||||||
try {
|
|
||||||
in.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bucketName + "/" + path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InputStream download(String path) {
|
|
||||||
if (!path.contains("/")) {
|
|
||||||
throw new BusinessException("the.path.is.error");
|
|
||||||
}
|
|
||||||
int index = path.indexOf("/");
|
|
||||||
String bucketName = path.substring(0, index);
|
|
||||||
String objectName = path.substring(index + 1);
|
|
||||||
return download(bucketName, objectName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InputStream download(String bucketName, String objectName) {
|
|
||||||
try {
|
|
||||||
S3Client s3Client = getS3Client();
|
|
||||||
GetObjectRequest objectRequest = GetObjectRequest
|
|
||||||
.builder()
|
|
||||||
.key(objectName)
|
|
||||||
.bucket(bucketName)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// ResponseBytes<GetObjectResponse> objectBytes = s3.getObjectAsBytes(objectRequest);
|
|
||||||
ResponseBytes<GetObjectResponse> objectAsBytes = s3Client.getObjectAsBytes(objectRequest);
|
|
||||||
byte[] data = objectAsBytes.asByteArray();
|
|
||||||
log.info("download 下载图片位置:桶 - {},路径 - {}", bucketName, objectName);
|
|
||||||
return new ByteArrayInputStream(data);
|
|
||||||
|
|
||||||
/*// Write the data to a local file.
|
|
||||||
File myFile = new File("files/images.png");
|
|
||||||
OutputStream os = new FileOutputStream(myFile);
|
|
||||||
os.write(data);
|
|
||||||
System.out.println("Successfully obtained bytes from an S3 object");
|
|
||||||
os.close();
|
|
||||||
return null;*/
|
|
||||||
// return minioClient.getObject(GetObjectArgs.builder().bucket(bucketName).object(objectName).build());
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("");
|
|
||||||
throw new BusinessException("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteObject(String path) {
|
|
||||||
if (!path.contains("/")) {
|
|
||||||
throw new BusinessException("The path is error!");
|
|
||||||
}
|
|
||||||
int index = path.indexOf("/");
|
|
||||||
String bucketName = path.substring(0, index);
|
|
||||||
String objectName = path.substring(index + 1);
|
|
||||||
deleteObject(bucketName, objectName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteObject(String bucketName, String objectName) {
|
|
||||||
try {
|
|
||||||
S3Client s3Client = getS3Client();
|
|
||||||
DeleteObjectRequest deleteObjectRequest = DeleteObjectRequest
|
|
||||||
.builder()
|
|
||||||
.key(objectName)
|
|
||||||
.bucket(bucketName)
|
|
||||||
.build();
|
|
||||||
s3Client.deleteObject(deleteObjectRequest);
|
|
||||||
log.info("Object " + objectName + " successfully removed from bucket " + bucketName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
log.info("Error while removing object " + objectName + " from bucket " + bucketName + ": " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPreSignedUrl(String path, int expiry) {
|
|
||||||
if (LocalCacheUtils.getPresignedUrlCache(path) != null) {
|
|
||||||
return LocalCacheUtils.getPresignedUrlCache(path);
|
|
||||||
} else {
|
|
||||||
if (!path.contains("/")) {
|
|
||||||
throw new BusinessException("The path is error!");
|
|
||||||
}
|
|
||||||
int index = path.indexOf("/");
|
|
||||||
String bucketName = path.substring(0, index);
|
|
||||||
String fileName = path.substring(index + 1);
|
|
||||||
String preSignedUrl = getPreSignatureUrl(bucketName, fileName, expiry);
|
|
||||||
LocalCacheUtils.setPresignedUrlCache(path, preSignedUrl);
|
|
||||||
return preSignedUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPreSignedUrl(String path, int expiry, boolean resetCache) {
|
|
||||||
if (resetCache || LocalCacheUtils.getPresignedUrlCache(path) == null) {
|
|
||||||
if (!path.contains("/")) {
|
|
||||||
throw new BusinessException("The path is error!");
|
|
||||||
}
|
|
||||||
int index = path.indexOf("/");
|
|
||||||
String bucketName = path.substring(0, index);
|
|
||||||
String fileName = path.substring(index + 1);
|
|
||||||
String presignedUrl = getPreSignatureUrl(bucketName, fileName, expiry);
|
|
||||||
LocalCacheUtils.setPresignedUrlCache(path, presignedUrl);
|
|
||||||
return presignedUrl;
|
|
||||||
} else {
|
|
||||||
return LocalCacheUtils.getPresignedUrlCache(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param keyName key名称: test/2022/06/123.pdf
|
|
||||||
* @param signatureDurationTime 有效期 单位:秒
|
|
||||||
* @return java.lang.String
|
|
||||||
* @description: 生成预签名URL
|
|
||||||
*/
|
|
||||||
public String getPreSignatureUrl(String bucket, String keyName, Integer signatureDurationTime) {
|
|
||||||
String preSignatureUrl = "";
|
|
||||||
try {
|
|
||||||
S3Presigner s3PreSigner = getS3PreSigner();
|
|
||||||
S3Client s3Client = getS3Client();
|
|
||||||
setObjectAcl(s3Client, bucket, keyName, ObjectCannedACL.PUBLIC_READ);
|
|
||||||
|
|
||||||
GetObjectRequest getObjectRequest = GetObjectRequest.builder()
|
|
||||||
.bucket(bucket)
|
|
||||||
.key(keyName)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
//设置预签名URL可访问时间
|
|
||||||
signatureDurationTime = Optional.ofNullable(signatureDurationTime)
|
|
||||||
.map(item -> {
|
|
||||||
if (item.intValue() > CommonConstant.Numbers.NUMBER_10080) {
|
|
||||||
item = CommonConstant.Numbers.NUMBER_10080;
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
})
|
|
||||||
.orElse(CommonConstant.Numbers.NUMBER_10);
|
|
||||||
GetObjectPresignRequest getObjectPresignRequest = GetObjectPresignRequest.builder()
|
|
||||||
.signatureDuration(Duration.ofMinutes(signatureDurationTime))
|
|
||||||
.getObjectRequest(getObjectRequest)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
PresignedGetObjectRequest presignedGetObjectRequest =
|
|
||||||
s3PreSigner.presignGetObject(getObjectPresignRequest);
|
|
||||||
|
|
||||||
preSignatureUrl = String.valueOf(presignedGetObjectRequest.url());
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("生成预签名URL失败,异常:{}", e.getMessage());
|
|
||||||
}
|
|
||||||
return preSignatureUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setObjectAcl(S3Client s3, String bucketName, String keyName, ObjectCannedACL acl) {
|
|
||||||
PutObjectAclRequest aclRequest = PutObjectAclRequest.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.key(keyName)
|
|
||||||
.acl(acl)
|
|
||||||
.build();
|
|
||||||
s3.putObjectAcl(aclRequest);
|
|
||||||
}
|
|
||||||
public boolean doesObjectExist(String bucketName, String objectName) {
|
|
||||||
try {
|
|
||||||
S3Client s3Client = getS3Client();
|
|
||||||
HeadObjectRequest headObjectRequest = HeadObjectRequest.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.key(objectName)
|
|
||||||
.build();
|
|
||||||
HeadObjectResponse headObjectResponse = s3Client.headObject(headObjectRequest);
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.info("指定文件 {}/{} 不存在", bucketName, objectName);
|
|
||||||
// 如果发生异常,说明文件不存在或者出现了其他错误
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String base64UploadToPath(String base64, String bucketName, String path) {
|
|
||||||
S3Client s3Client = getS3Client();
|
|
||||||
String[] parts = base64.split(",");
|
|
||||||
String imageType = parts[0].split("/")[1].split(";")[0];
|
|
||||||
String base64Data = parts[1];
|
|
||||||
|
|
||||||
byte[] imageBytes = Base64.getDecoder().decode(base64Data);
|
|
||||||
String fileName;
|
|
||||||
if (!StringUtil.isNullOrEmpty(path)) {
|
|
||||||
fileName = path + "." + imageType; // or any other image format
|
|
||||||
} else {
|
|
||||||
fileName = UUID.randomUUID() + "." + imageType;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
|
|
||||||
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
|
|
||||||
.bucket(bucketName)
|
|
||||||
.contentType("image/" + imageType)
|
|
||||||
.contentLength((long) in.available())
|
|
||||||
.key(fileName)
|
|
||||||
.acl(ObjectCannedACL.PUBLIC_READ)
|
|
||||||
.build();
|
|
||||||
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(in, in.available()));
|
|
||||||
|
|
||||||
log.info("base64UploadToPath 上传的位置:桶 - {},路径 - {}", bucketName, fileName);
|
|
||||||
return bucketName + "/" + fileName;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null; // or throw an exception
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<String> listAllBucket() {
|
|
||||||
S3Client s3Client = getS3Client();
|
|
||||||
ListBucketsResponse listBucketsResponse = s3Client.listBuckets();
|
|
||||||
List<Bucket> buckets = listBucketsResponse.buckets();
|
|
||||||
return buckets.stream().map(Bucket::name).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.ai.da.common.utils;
|
package com.ai.da.common.utils;
|
||||||
|
|
||||||
import com.ai.da.mapper.primary.entity.Account;
|
|
||||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ai.da.common.config.exception.BusinessException;
|
import com.ai.da.common.config.exception.BusinessException;
|
||||||
import com.tencentcloudapi.common.Credential;
|
import com.tencentcloudapi.common.Credential;
|
||||||
@@ -9,14 +7,11 @@ import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
|||||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||||
import com.tencentcloudapi.common.profile.HttpProfile;
|
import com.tencentcloudapi.common.profile.HttpProfile;
|
||||||
import com.tencentcloudapi.ses.v20201002.SesClient;
|
import com.tencentcloudapi.ses.v20201002.SesClient;
|
||||||
import com.tencentcloudapi.ses.v20201002.models.Attachment;
|
|
||||||
import com.tencentcloudapi.ses.v20201002.models.SendEmailRequest;
|
import com.tencentcloudapi.ses.v20201002.models.SendEmailRequest;
|
||||||
import com.tencentcloudapi.ses.v20201002.models.SendEmailResponse;
|
import com.tencentcloudapi.ses.v20201002.models.SendEmailResponse;
|
||||||
import com.tencentcloudapi.ses.v20201002.models.Template;
|
import com.tencentcloudapi.ses.v20201002.models.Template;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import java.util.Base64;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,7 +31,6 @@ public class SendEmailUtil {
|
|||||||
* 发信地址
|
* 发信地址
|
||||||
*/
|
*/
|
||||||
private static String SEND_ADDRESS = "info@aida.com.hk";
|
private static String SEND_ADDRESS = "info@aida.com.hk";
|
||||||
private final static String CODE_CREATE_SEND_ADDRESS = "info@code-create.com.hk";
|
|
||||||
/**
|
/**
|
||||||
* 登入主题
|
* 登入主题
|
||||||
*/
|
*/
|
||||||
@@ -53,12 +47,10 @@ public class SendEmailUtil {
|
|||||||
* 绑定邮箱
|
* 绑定邮箱
|
||||||
*/
|
*/
|
||||||
public static String BIND_MAILBOX_SUBJECT = "绑定邮箱";
|
public static String BIND_MAILBOX_SUBJECT = "绑定邮箱";
|
||||||
public static String CHANGE_MAILBOX_SUBJECT = "Change Mailbox";
|
|
||||||
/**
|
/**
|
||||||
* 登入模板id
|
* 登入模板id
|
||||||
*/
|
*/
|
||||||
public static Long LOGIN_TEMPLATE_ID = 58020L;
|
public static Long LOGIN_TEMPLATE_ID = 58020L;
|
||||||
public static Long PORTFOLIO_REGISTER_ID = 124847L;
|
|
||||||
/**
|
/**
|
||||||
* 修改密码模板id
|
* 修改密码模板id
|
||||||
*/
|
*/
|
||||||
@@ -72,8 +64,6 @@ public class SendEmailUtil {
|
|||||||
*/
|
*/
|
||||||
public static Long BIND_MAILBOX_TEMPLATE_ID = 45619L;
|
public static Long BIND_MAILBOX_TEMPLATE_ID = 45619L;
|
||||||
|
|
||||||
public static Long CHANGE_MAILBOX_TEMPLATE_ID = 128210L;
|
|
||||||
|
|
||||||
|
|
||||||
public static Boolean send(String receiverAddress,String ip,Long templateId,String verifyCode) {
|
public static Boolean send(String receiverAddress,String ip,Long templateId,String verifyCode) {
|
||||||
try{
|
try{
|
||||||
@@ -95,8 +85,7 @@ public class SendEmailUtil {
|
|||||||
req.setDestination(new String[]{receiverAddress});
|
req.setDestination(new String[]{receiverAddress});
|
||||||
String subject = templateId == LOGIN_TEMPLATE_ID ? LOGIN_SUBJECT :
|
String subject = templateId == LOGIN_TEMPLATE_ID ? LOGIN_SUBJECT :
|
||||||
templateId == UPDATE_PWD_TEMPLATE_ID ? FORGET_PWD_SUBJECT :
|
templateId == UPDATE_PWD_TEMPLATE_ID ? FORGET_PWD_SUBJECT :
|
||||||
templateId == EXCEPTION_ID_TEMPLATE_ID ? EXCEPTION_ID_SUBJECT :
|
templateId == EXCEPTION_ID_TEMPLATE_ID ? EXCEPTION_ID_SUBJECT :BIND_MAILBOX_SUBJECT;
|
||||||
templateId == CHANGE_MAILBOX_TEMPLATE_ID ? CHANGE_MAILBOX_SUBJECT : BIND_MAILBOX_SUBJECT;
|
|
||||||
req.setSubject(subject);
|
req.setSubject(subject);
|
||||||
req.setTemplate(contractTemplate(templateId, verifyCode,ip));
|
req.setTemplate(contractTemplate(templateId, verifyCode,ip));
|
||||||
|
|
||||||
@@ -107,10 +96,9 @@ public class SendEmailUtil {
|
|||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
} catch (TencentCloudSDKException e) {
|
} catch (TencentCloudSDKException e) {
|
||||||
log.info("邮件发送失败###{}",e.toString());
|
log.info("邮件发送失败###{}",e.toString());
|
||||||
throw new BusinessException("failed.to.send.mail");
|
throw new BusinessException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Template contractTemplate(Long templateId,String verifyCode,String ip){
|
private static Template contractTemplate(Long templateId,String verifyCode,String ip){
|
||||||
Template template = new Template();
|
Template template = new Template();
|
||||||
template.setTemplateID(templateId);
|
template.setTemplateID(templateId);
|
||||||
@@ -125,687 +113,4 @@ public class SendEmailUtil {
|
|||||||
template.setTemplateData(jsonObject.toJSONString());
|
template.setTemplateData(jsonObject.toJSONString());
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 发送不同类型的邮件
|
|
||||||
*
|
|
||||||
* @param receiverAddress 收件人邮箱地址
|
|
||||||
* @param senderAddress 发件人邮箱地址
|
|
||||||
* @param emailType 邮件类型:1 - 提交试用请求,2 - 审批通过,3 - 试用请求通过通知
|
|
||||||
* @return 发送结果
|
|
||||||
*/
|
|
||||||
private final static Long YOUR_TRIAL_TEMPLATE_ID = 117214L;
|
|
||||||
private final static Long APPROVAL_TEMPLATE_ID = 117215L;
|
|
||||||
private final static Long NOTIFICATION_TEMPLATE_ID = 117216L;
|
|
||||||
private final static Long NOTIFICATION_CHINESE_TEMPLATE_ID = 122229L;
|
|
||||||
private final static Long TRIAL_ORDER_LIST_ID = 122273L;
|
|
||||||
private final static Long NO_TRIAL_ORDER_LIST_ID = 122591L;
|
|
||||||
|
|
||||||
public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType, String country, boolean link) {
|
|
||||||
try {
|
|
||||||
// 实例化一个认证对象
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
if (StringUtils.isEmpty(senderAddress)) {
|
|
||||||
senderAddress = SEND_ADDRESS;
|
|
||||||
}
|
|
||||||
req.setFromEmailAddress(senderAddress);
|
|
||||||
req.setDestination(new String[]{receiverAddress});
|
|
||||||
|
|
||||||
// 根据邮件类型设置不同的主题和模板
|
|
||||||
String subject = "";
|
|
||||||
Template template = new Template();
|
|
||||||
switch (emailType) {
|
|
||||||
case 1:
|
|
||||||
subject = "试用订单请求";
|
|
||||||
template.setTemplateID(YOUR_TRIAL_TEMPLATE_ID);
|
|
||||||
template.setTemplateData(buildTrialOrderData(trialOrder));
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
subject = "试用订单审批通过";
|
|
||||||
template.setTemplateID(APPROVAL_TEMPLATE_ID);
|
|
||||||
template.setTemplateData(buildApprovalData(trialOrder));
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
subject = "Approval Confirmation for AiDA System Trial Access";
|
|
||||||
if (country.equals("China")) {
|
|
||||||
template.setTemplateID(NOTIFICATION_CHINESE_TEMPLATE_ID);
|
|
||||||
}else {
|
|
||||||
template.setTemplateID(NOTIFICATION_TEMPLATE_ID);
|
|
||||||
}
|
|
||||||
template.setTemplateData(buildNotificationData(trialOrder, link));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
req.setSubject(subject);
|
|
||||||
req.setTemplate(template);
|
|
||||||
|
|
||||||
// 发送邮件
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendExcelEmail(String receiverAddress, String senderAddress, byte[] fileContent, String fileName) {
|
|
||||||
try {
|
|
||||||
// 实例化一个认证对象
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
if (StringUtils.isEmpty(senderAddress)) {
|
|
||||||
senderAddress = SEND_ADDRESS;
|
|
||||||
}
|
|
||||||
req.setFromEmailAddress(senderAddress);
|
|
||||||
req.setDestination(new String[]{receiverAddress});
|
|
||||||
|
|
||||||
// 根据邮件类型设置不同的主题和模板
|
|
||||||
String subject = "";
|
|
||||||
Template template = new Template();
|
|
||||||
subject = "昨日试用订单数据";
|
|
||||||
template.setTemplateID(TRIAL_ORDER_LIST_ID);
|
|
||||||
|
|
||||||
req.setSubject(subject);
|
|
||||||
req.setTemplate(template);
|
|
||||||
|
|
||||||
Attachment attachment = new Attachment();
|
|
||||||
attachment.setFileName(fileName); // 设置附件文件名
|
|
||||||
// 设置附件内容
|
|
||||||
attachment.setContent(Base64.getEncoder().encodeToString(fileContent));
|
|
||||||
req.setAttachments(new Attachment[] {attachment});
|
|
||||||
// 发送邮件
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void sendNoExcelEmail(String receiverAddress, String senderAddress) {
|
|
||||||
try {
|
|
||||||
// 实例化一个认证对象
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
if (StringUtils.isEmpty(senderAddress)) {
|
|
||||||
senderAddress = SEND_ADDRESS;
|
|
||||||
}
|
|
||||||
req.setFromEmailAddress(senderAddress);
|
|
||||||
req.setDestination(new String[]{receiverAddress});
|
|
||||||
|
|
||||||
// 根据邮件类型设置不同的主题和模板
|
|
||||||
String subject = "";
|
|
||||||
Template template = new Template();
|
|
||||||
subject = "昨日试用订单数据";
|
|
||||||
template.setTemplateID(NO_TRIAL_ORDER_LIST_ID);
|
|
||||||
|
|
||||||
req.setSubject(subject);
|
|
||||||
req.setTemplate(template);
|
|
||||||
// 发送邮件
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private final static Long WILLBEEXPIRED_TEMPLATE_ID = 118178L;
|
|
||||||
public static void sendWillBeExpiredEmail(Account account, String senderAddress) {
|
|
||||||
try {
|
|
||||||
// 实例化一个认证对象
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
if (StringUtils.isEmpty(senderAddress)) {
|
|
||||||
senderAddress = SEND_ADDRESS;
|
|
||||||
}
|
|
||||||
req.setFromEmailAddress(senderAddress);
|
|
||||||
req.setDestination(new String[]{account.getUserEmail()});
|
|
||||||
|
|
||||||
// 根据邮件类型设置不同的主题和模板
|
|
||||||
String subject = "";
|
|
||||||
Template template = new Template();
|
|
||||||
subject = "Renewal notice";
|
|
||||||
template.setTemplateID(WILLBEEXPIRED_TEMPLATE_ID);
|
|
||||||
template.setTemplateData(buildAccountData(account));
|
|
||||||
|
|
||||||
req.setSubject(subject);
|
|
||||||
req.setTemplate(template);
|
|
||||||
|
|
||||||
// 发送邮件
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String buildAccountData(Account account) {
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
// 设置试用订单相关数据
|
|
||||||
jsonObject.put("userName", account.getUserName());
|
|
||||||
|
|
||||||
// 用户到期时间戳
|
|
||||||
Long timestamp = account.getValidEndTime(); // 替换为你的时间戳
|
|
||||||
if (null != timestamp) {
|
|
||||||
// 获取当前时间戳
|
|
||||||
Long currentTimestamp = System.currentTimeMillis();
|
|
||||||
|
|
||||||
// 计算时间差(毫秒)
|
|
||||||
long timeDifference = currentTimestamp - timestamp;
|
|
||||||
|
|
||||||
// 向上取整计算天数
|
|
||||||
long days = (timeDifference + 24 * 60 * 60 * 1000 - 1) / (24 * 60 * 60 * 1000);
|
|
||||||
jsonObject.put("days", days);
|
|
||||||
}
|
|
||||||
return jsonObject.toJSONString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 构建试用订单数据
|
|
||||||
private static String buildTrialOrderData(TrialOrder trialOrder) {
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
// 设置试用订单相关数据
|
|
||||||
jsonObject.put("surname", trialOrder.getSurname());
|
|
||||||
jsonObject.put("givenName", trialOrder.getGivenName());
|
|
||||||
jsonObject.put("userName", trialOrder.getUserName());
|
|
||||||
jsonObject.put("email", trialOrder.getEmail());
|
|
||||||
jsonObject.put("country", trialOrder.getCountry());
|
|
||||||
return jsonObject.toJSONString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 构建审批通过数据
|
|
||||||
private static String buildApprovalData(TrialOrder trialOrder) {
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
// 设置审批通过相关数据
|
|
||||||
jsonObject.put("surname", trialOrder.getSurname());
|
|
||||||
jsonObject.put("givenName", trialOrder.getGivenName());
|
|
||||||
jsonObject.put("userName", trialOrder.getUserName());
|
|
||||||
jsonObject.put("email", trialOrder.getEmail());
|
|
||||||
jsonObject.put("country", trialOrder.getCountry());
|
|
||||||
return jsonObject.toJSONString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 构建试用订单通过通知数据
|
|
||||||
private static String buildNotificationData(TrialOrder trialOrder, boolean link) {
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
// 设置试用订单通过通知相关数据
|
|
||||||
jsonObject.put("title", trialOrder.getTitle());
|
|
||||||
jsonObject.put("surname", trialOrder.getSurname());
|
|
||||||
jsonObject.put("givenName", trialOrder.getGivenName());
|
|
||||||
jsonObject.put("userName", trialOrder.getUserName());
|
|
||||||
jsonObject.put("email", trialOrder.getEmail());
|
|
||||||
if (link) {
|
|
||||||
jsonObject.put("days", 14);
|
|
||||||
}else {
|
|
||||||
jsonObject.put("days", 5);
|
|
||||||
}
|
|
||||||
return jsonObject.toJSONString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Long UPGRADE_NOTIFICATION_ID = 118855L;
|
|
||||||
private final static Long UPGRADE_SUCCESS_NOTIFICATION_ID = 118856L;
|
|
||||||
private final static Long UPGRADE_NOTIFICATION_ID_CHINESE = 122898L;
|
|
||||||
private final static Long UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE = 122899L;
|
|
||||||
public static void sendUpgradeNotification(Account account, String senderAddress, Integer type) {
|
|
||||||
try {
|
|
||||||
// 实例化一个认证对象
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
if (StringUtils.isEmpty(senderAddress)) {
|
|
||||||
senderAddress = CODE_CREATE_SEND_ADDRESS;
|
|
||||||
}
|
|
||||||
req.setFromEmailAddress(senderAddress);
|
|
||||||
req.setDestination(new String[]{account.getUserEmail()});
|
|
||||||
|
|
||||||
// 根据邮件类型设置不同的主题和模板
|
|
||||||
String subject = "";
|
|
||||||
Template template = new Template();
|
|
||||||
// if (type == 1) {
|
|
||||||
// subject = "Upcoming System Upgrade for AiDA 3.0";
|
|
||||||
// template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
|
||||||
// }else {
|
|
||||||
// subject = "即将到来的AiDA 3.0系统升级";
|
|
||||||
// template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE);
|
|
||||||
// }
|
|
||||||
if (type == 1) {
|
|
||||||
subject = "Successful System Upgrade and New Features in AiDA 3.1";
|
|
||||||
template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID);
|
|
||||||
}else {
|
|
||||||
subject = "系统升级成功和AiDA 3.1新功能";
|
|
||||||
template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE);
|
|
||||||
}
|
|
||||||
template.setTemplateData(buildAccountData(account));
|
|
||||||
|
|
||||||
req.setSubject(subject);
|
|
||||||
req.setTemplate(template);
|
|
||||||
|
|
||||||
// 发送邮件
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Long GENERATE_EXCEPTION_WARNING_ID = 122589L;
|
|
||||||
public static void sendGenerateExceptionWarning(String message){
|
|
||||||
try {
|
|
||||||
// 实例化一个认证对象
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
req.setFromEmailAddress(CODE_CREATE_SEND_ADDRESS);
|
|
||||||
req.setDestination(new String[]{"xupei3360@163.com"});
|
|
||||||
|
|
||||||
// 根据邮件类型设置不同的主题和模板
|
|
||||||
String subject = "";
|
|
||||||
Template template = new Template();
|
|
||||||
subject = "Warning: AiDA 3.0 Generate Exception Warning";
|
|
||||||
template.setTemplateID(GENERATE_EXCEPTION_WARNING_ID);
|
|
||||||
|
|
||||||
JSONObject parameter = new JSONObject();
|
|
||||||
parameter.put("errorMessage", message);
|
|
||||||
parameter.put("time", DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS));
|
|
||||||
|
|
||||||
template.setTemplateData(parameter.toJSONString());
|
|
||||||
|
|
||||||
req.setSubject(subject);
|
|
||||||
req.setTemplate(template);
|
|
||||||
|
|
||||||
// 发送邮件
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Long QUESTIONNAIRE_FEEDBACK_EN_ID = 124151L;
|
|
||||||
private final static Long QUESTIONNAIRE_FEEDBACK_CN_ID = 124156L;
|
|
||||||
public static void questionnaireRelatedNotify(String userName, String email, String language){
|
|
||||||
try {
|
|
||||||
// 实例化一个认证对象
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
req.setFromEmailAddress(CODE_CREATE_SEND_ADDRESS);
|
|
||||||
req.setDestination(new String[]{email});
|
|
||||||
|
|
||||||
// 根据邮件类型设置不同的主题和模板
|
|
||||||
Template template = new Template();
|
|
||||||
String subject = "Thank You for Completing the AiDA System Survey";
|
|
||||||
template.setTemplateID(QUESTIONNAIRE_FEEDBACK_EN_ID);
|
|
||||||
if (language.equals("CN")) {
|
|
||||||
subject = "感谢您完成AiDA系统问卷调查";
|
|
||||||
template.setTemplateID(QUESTIONNAIRE_FEEDBACK_CN_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject parameter = new JSONObject();
|
|
||||||
parameter.put("userName", userName);
|
|
||||||
|
|
||||||
template.setTemplateData(parameter.toJSONString());
|
|
||||||
|
|
||||||
req.setSubject(subject);
|
|
||||||
req.setTemplate(template);
|
|
||||||
|
|
||||||
// 发送邮件
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private final static Long NEW_USER_PAYMENT_NOTIFICATION_EN = 124889L;
|
|
||||||
private final static Long NEW_USER_PAYMENT_NOTIFICATION_CN = 124888L;
|
|
||||||
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_EN = 124892L;
|
|
||||||
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_CN = 124891L;
|
|
||||||
|
|
||||||
public static void notificationForPaidUser(String receiverAddress, int emailType, String country, String userName, String date){
|
|
||||||
try {
|
|
||||||
// 实例化一个认证对象
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
req.setFromEmailAddress(SEND_ADDRESS);
|
|
||||||
req.setDestination(new String[]{receiverAddress});
|
|
||||||
|
|
||||||
// 根据邮件类型设置不同的主题和模板
|
|
||||||
String subject = "";
|
|
||||||
Template template = new Template();
|
|
||||||
JSONObject parameter = new JSONObject();
|
|
||||||
switch (emailType) {
|
|
||||||
// 新用户
|
|
||||||
case 1:
|
|
||||||
subject = "Welcome to AiDA!";
|
|
||||||
if (country.equals("China")) {
|
|
||||||
template.setTemplateID(NEW_USER_PAYMENT_NOTIFICATION_CN);
|
|
||||||
}else {
|
|
||||||
template.setTemplateID(NEW_USER_PAYMENT_NOTIFICATION_EN);
|
|
||||||
}
|
|
||||||
parameter.put("userName", userName);
|
|
||||||
parameter.put("email", receiverAddress);
|
|
||||||
break;
|
|
||||||
// 续费用户
|
|
||||||
case 2:
|
|
||||||
subject = "Account renewal notification";
|
|
||||||
if (country.equals("China")) {
|
|
||||||
template.setTemplateID(RENEWAL_NOTIFICATION_FOR_OLD_USER_CN);
|
|
||||||
}else {
|
|
||||||
template.setTemplateID(RENEWAL_NOTIFICATION_FOR_OLD_USER_EN);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
parameter.put("userName", userName);
|
|
||||||
parameter.put("date", date);
|
|
||||||
template.setTemplateData(parameter.toJSONString());
|
|
||||||
|
|
||||||
req.setSubject(subject);
|
|
||||||
req.setTemplate(template);
|
|
||||||
|
|
||||||
// 发送邮件
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Boolean designWorksRegister(String userEmail, String randomVerifyCode) {
|
|
||||||
try {
|
|
||||||
// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
|
|
||||||
// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
|
|
||||||
req.setFromEmailAddress(SEND_ADDRESS);
|
|
||||||
req.setDestination(new String[]{userEmail});
|
|
||||||
String subject = "Tourist registration";
|
|
||||||
req.setSubject(subject);
|
|
||||||
|
|
||||||
req.setTemplate(contractTemplate(PORTFOLIO_REGISTER_ID, randomVerifyCode, null));
|
|
||||||
|
|
||||||
// 返回的resp是一个SendEmailResponse的实例,与请求对象对应
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
// 输出json格式的字符串回包
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
return Boolean.TRUE;
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Long NEW_USER_REGISTER_NOTIFICATION_EN = 126919L;
|
|
||||||
|
|
||||||
public static void notificationForRegisterUser(String receiverAddress){
|
|
||||||
try{
|
|
||||||
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
|
||||||
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
|
||||||
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
req.setFromEmailAddress(SEND_ADDRESS);
|
|
||||||
req.setDestination(new String[]{receiverAddress});
|
|
||||||
|
|
||||||
req.setSubject("Welcome to AiDa");
|
|
||||||
Template template = new Template();
|
|
||||||
template.setTemplateID(NEW_USER_REGISTER_NOTIFICATION_EN);
|
|
||||||
template.setTemplateData("{\"email\":\" " + receiverAddress + "\"}");
|
|
||||||
req.setTemplate(template);
|
|
||||||
|
|
||||||
// 返回的resp是一个SendEmailResponse的实例,与请求对象对应
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Long CHANGE_MAILBOX_CONFIRM_CN = 128278L;
|
|
||||||
private final static Long CHANGE_MAILBOX_CONFIRM_EN = 128277L;
|
|
||||||
|
|
||||||
public static void changeMailboxConfirm(String receiverAddress, String language, String name, String link){
|
|
||||||
try{
|
|
||||||
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
|
||||||
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
|
||||||
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
req.setFromEmailAddress(SEND_ADDRESS);
|
|
||||||
req.setDestination(new String[]{receiverAddress});
|
|
||||||
Template template = new Template();
|
|
||||||
if (language.equals("ENGLISH")){
|
|
||||||
req.setSubject("Change the email address bound to the AiDA account");
|
|
||||||
template.setTemplateID(CHANGE_MAILBOX_CONFIRM_EN);
|
|
||||||
}else {
|
|
||||||
req.setSubject("更换AiDA账号绑定的邮箱地址");
|
|
||||||
template.setTemplateID(CHANGE_MAILBOX_CONFIRM_CN);
|
|
||||||
}
|
|
||||||
JSONObject param = new JSONObject();
|
|
||||||
param.put("userName", name);
|
|
||||||
param.put("link", link);
|
|
||||||
|
|
||||||
template.setTemplateData(param.toJSONString());
|
|
||||||
req.setTemplate(template);
|
|
||||||
|
|
||||||
// 返回的resp是一个SendEmailResponse的实例,与请求对象对应
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Long UPLOAD_TIMEOUT_REMINDER = 128324L;
|
|
||||||
|
|
||||||
public static void uploadTimeoutReminder(String userName, String time){
|
|
||||||
String xp = "xupei3360@163.com";
|
|
||||||
String shb = "shahaibodd99@gmail.com";
|
|
||||||
String wxd = "X1627315083@163.com";
|
|
||||||
String pkc = "kaicpang.pang@connect.polyu.hk";
|
|
||||||
try{
|
|
||||||
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
|
||||||
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
|
||||||
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
req.setFromEmailAddress(SEND_ADDRESS);
|
|
||||||
req.setDestination(new String[]{shb, xp, wxd, pkc});
|
|
||||||
Template template = new Template();
|
|
||||||
req.setSubject("上传图片超时提醒");
|
|
||||||
template.setTemplateID(UPLOAD_TIMEOUT_REMINDER);
|
|
||||||
JSONObject param = new JSONObject();
|
|
||||||
param.put("userName", userName);
|
|
||||||
param.put("time", time);
|
|
||||||
|
|
||||||
template.setTemplateData(param.toJSONString());
|
|
||||||
req.setTemplate(template);
|
|
||||||
|
|
||||||
// 返回的resp是一个SendEmailResponse的实例,与请求对象对应
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Long HALFPRICEPROMOTION_CN_ID = 128582L;
|
|
||||||
private final static Long HALFPRICEPROMOTION_EN_ID = 128583L;
|
|
||||||
public static void halfPricePromotion(Account account, String senderAddress, int type) {
|
|
||||||
try {
|
|
||||||
// 实例化一个认证对象
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
if (StringUtils.isEmpty(senderAddress)) {
|
|
||||||
senderAddress = CODE_CREATE_SEND_ADDRESS;
|
|
||||||
}
|
|
||||||
req.setFromEmailAddress(senderAddress);
|
|
||||||
req.setDestination(new String[]{account.getUserEmail()});
|
|
||||||
|
|
||||||
// 根据邮件类型设置不同的主题和模板
|
|
||||||
String subject = "";
|
|
||||||
Template template = new Template();
|
|
||||||
// if (type == 1) {
|
|
||||||
// subject = "Upcoming System Upgrade for AiDA 3.0";
|
|
||||||
// template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
|
||||||
// }else {
|
|
||||||
// subject = "即将到来的AiDA 3.0系统升级";
|
|
||||||
// template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE);
|
|
||||||
// }
|
|
||||||
if (type == 1) {
|
|
||||||
subject = "AiDA workshop - Win a trip to Hong Kong!";
|
|
||||||
template.setTemplateID(HALFPRICEPROMOTION_EN_ID);
|
|
||||||
}else {
|
|
||||||
subject = "AiDA workshop - 赢取香港之旅";
|
|
||||||
template.setTemplateID(HALFPRICEPROMOTION_CN_ID);
|
|
||||||
}
|
|
||||||
template.setTemplateData(buildAccountData(account));
|
|
||||||
|
|
||||||
req.setSubject(subject);
|
|
||||||
req.setTemplate(template);
|
|
||||||
|
|
||||||
// 发送邮件
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private final static Long SYSTEM_UPGRADE_CN_ID = 131743L;
|
|
||||||
private final static Long SYSTEM_UPGRADE_EN_ID = 131744L;
|
|
||||||
public static void temporaryUpgrade(Account account, String senderAddress, int type) {
|
|
||||||
try {
|
|
||||||
// 实例化一个认证对象
|
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
|
||||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
|
||||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
|
||||||
SendEmailRequest req = new SendEmailRequest();
|
|
||||||
if (StringUtils.isEmpty(senderAddress)) {
|
|
||||||
senderAddress = CODE_CREATE_SEND_ADDRESS;
|
|
||||||
}
|
|
||||||
req.setFromEmailAddress(senderAddress);
|
|
||||||
req.setDestination(new String[]{account.getUserEmail()});
|
|
||||||
|
|
||||||
// 根据邮件类型设置不同的主题和模板
|
|
||||||
String subject = "";
|
|
||||||
Template template = new Template();
|
|
||||||
if (type == 1) {
|
|
||||||
subject = "AiDA system upgrade completed";
|
|
||||||
template.setTemplateID(SYSTEM_UPGRADE_EN_ID);
|
|
||||||
}else {
|
|
||||||
subject = "AiDA系统升级完成";
|
|
||||||
template.setTemplateID(SYSTEM_UPGRADE_CN_ID);
|
|
||||||
}
|
|
||||||
template.setTemplateData(buildAccountData(account));
|
|
||||||
|
|
||||||
req.setSubject(subject);
|
|
||||||
req.setTemplate(template);
|
|
||||||
|
|
||||||
// 发送邮件
|
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
|
||||||
} catch (TencentCloudSDKException e) {
|
|
||||||
log.info("邮件发送失败###{}", e.toString());
|
|
||||||
throw new BusinessException("failed.to.send.mail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,137 +0,0 @@
|
|||||||
package com.ai.da.common.utils;
|
|
||||||
|
|
||||||
|
|
||||||
public class SnowflakeUtil {
|
|
||||||
|
|
||||||
// ==============================Fields===========================================
|
|
||||||
/** 开始时间截 (2015-01-01) */
|
|
||||||
private final long twepoch = 1420041600000L;
|
|
||||||
|
|
||||||
/** 机器id所占的位数 */
|
|
||||||
private final long workerIdBits = 5L;
|
|
||||||
|
|
||||||
/** 数据标识id所占的位数 */
|
|
||||||
private final long datacenterIdBits = 5L;
|
|
||||||
|
|
||||||
/** 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */
|
|
||||||
private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
|
|
||||||
|
|
||||||
/** 支持的最大数据标识id,结果是31 */
|
|
||||||
private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
|
|
||||||
|
|
||||||
/** 序列在id中占的位数 */
|
|
||||||
private final long sequenceBits = 12L;
|
|
||||||
|
|
||||||
/** 机器ID向左移12位 */
|
|
||||||
private final long workerIdShift = sequenceBits;
|
|
||||||
|
|
||||||
/** 数据标识id向左移17位(12+5) */
|
|
||||||
private final long datacenterIdShift = sequenceBits + workerIdBits;
|
|
||||||
|
|
||||||
/** 时间截向左移22位(5+5+12) */
|
|
||||||
private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
|
|
||||||
|
|
||||||
/** 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) */
|
|
||||||
private final long sequenceMask = -1L ^ (-1L << sequenceBits);
|
|
||||||
|
|
||||||
/** 工作机器ID(0~31) */
|
|
||||||
private long workerId;
|
|
||||||
|
|
||||||
/** 数据中心ID(0~31) */
|
|
||||||
private long datacenterId;
|
|
||||||
|
|
||||||
/** 毫秒内序列(0~4095) */
|
|
||||||
private long sequence = 0L;
|
|
||||||
|
|
||||||
/** 上次生成ID的时间截 */
|
|
||||||
private long lastTimestamp = -1L;
|
|
||||||
|
|
||||||
//==============================Constructors=====================================
|
|
||||||
/**
|
|
||||||
* 构造函数
|
|
||||||
* @param workerId 工作ID (0~31)
|
|
||||||
* @param datacenterId 数据中心ID (0~31)
|
|
||||||
*/
|
|
||||||
public SnowflakeUtil(long workerId, long datacenterId) {
|
|
||||||
if (workerId > maxWorkerId || workerId < 0) {
|
|
||||||
throw new IllegalArgumentException(String.format
|
|
||||||
("worker Id can't be greater than %d or less than 0", maxWorkerId));
|
|
||||||
}
|
|
||||||
if (datacenterId > maxDatacenterId || datacenterId < 0) {
|
|
||||||
throw new IllegalArgumentException(String.format
|
|
||||||
("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
|
|
||||||
}
|
|
||||||
this.workerId = workerId;
|
|
||||||
this.datacenterId = datacenterId;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==============================Methods==========================================
|
|
||||||
/**
|
|
||||||
* 获得下一个ID (该方法是线程安全的)
|
|
||||||
* @return SnowflakeId
|
|
||||||
*/
|
|
||||||
public synchronized long nextId() {
|
|
||||||
long timestamp = timeGen();
|
|
||||||
|
|
||||||
//如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
|
|
||||||
if (timestamp < lastTimestamp) {
|
|
||||||
throw new RuntimeException(
|
|
||||||
String.format
|
|
||||||
("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
|
|
||||||
}
|
|
||||||
|
|
||||||
//如果是同一时间生成的,则进行毫秒内序列
|
|
||||||
if (lastTimestamp == timestamp) {
|
|
||||||
sequence = (sequence + 1) & sequenceMask;
|
|
||||||
//毫秒内序列溢出
|
|
||||||
if (sequence == 0) {
|
|
||||||
//阻塞到下一个毫秒,获得新的时间戳
|
|
||||||
timestamp = tilNextMillis(lastTimestamp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//时间戳改变,毫秒内序列重置
|
|
||||||
else {
|
|
||||||
sequence = 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
//上次生成ID的时间截
|
|
||||||
lastTimestamp = timestamp;
|
|
||||||
|
|
||||||
//移位并通过或运算拼到一起组成64位的ID
|
|
||||||
return ((timestamp - twepoch) << timestampLeftShift) //
|
|
||||||
| (datacenterId << datacenterIdShift) //
|
|
||||||
| (workerId << workerIdShift) //
|
|
||||||
| sequence;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 阻塞到下一个毫秒,直到获得新的时间戳
|
|
||||||
* @param lastTimestamp 上次生成ID的时间截
|
|
||||||
* @return 当前时间戳
|
|
||||||
*/
|
|
||||||
protected long tilNextMillis(long lastTimestamp) {
|
|
||||||
long timestamp = timeGen();
|
|
||||||
while (timestamp <= lastTimestamp) {
|
|
||||||
timestamp = timeGen();
|
|
||||||
}
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回以毫秒为单位的当前时间
|
|
||||||
* @return 当前时间(毫秒)
|
|
||||||
*/
|
|
||||||
protected long timeGen() {
|
|
||||||
return System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
//==============================Test=============================================
|
|
||||||
/** 测试 */
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SnowflakeUtil idWorker = new SnowflakeUtil(0, 0);
|
|
||||||
long id = idWorker.nextId();
|
|
||||||
System.out.println("id:"+id);
|
|
||||||
//id:768842202204864512
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.ai.da.common.utils.paypalRequest;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.paypal.http.HttpRequest;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class AuthenticationRequest extends HttpRequest<HashMap> {
|
|
||||||
|
|
||||||
public AuthenticationRequest() {
|
|
||||||
super("/v1/oauth2/token", "POST", HashMap.class);
|
|
||||||
this.header("Content-Type", "application/x-www-form-urlencoded");
|
|
||||||
body();
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthenticationRequest authorization(String clientId, String clientSecret) {
|
|
||||||
this.header(clientId, clientSecret);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthenticationRequest body() {
|
|
||||||
HashMap<String, String> body = new HashMap<>();
|
|
||||||
body.put("grant_type", "client_credentials");
|
|
||||||
this.requestBody(body);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.ai.da.common.utils.paypalRequest;
|
|
||||||
|
|
||||||
import com.ai.da.model.dto.WebhookVerifyDTO;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.paypal.http.HttpRequest;
|
|
||||||
import com.paypal.orders.OrdersCreateRequest;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class WebhookVerifyRequest extends HttpRequest<HashMap> {
|
|
||||||
public WebhookVerifyRequest() {
|
|
||||||
super("/v1/notifications/verify-webhook-signature", "POST", HashMap.class);
|
|
||||||
this.header("Content-Type", "application/json");
|
|
||||||
}
|
|
||||||
|
|
||||||
public WebhookVerifyRequest authorization(String authorization) {
|
|
||||||
this.header("Authorization", "Bearer " + String.valueOf(authorization));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WebhookVerifyRequest requestBody(HashMap<String,String> webhookVerify) {
|
|
||||||
super.requestBody(webhookVerify);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
package com.ai.da.common.websocket;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
import javax.websocket.*;
|
|
||||||
import javax.websocket.server.PathParam;
|
|
||||||
import javax.websocket.server.ServerEndpoint;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
|
|
||||||
@ServerEndpoint(value = "/notification/{id}")
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class NotificationConnection {
|
|
||||||
|
|
||||||
//连接超时
|
|
||||||
public static final long MAX_TIME_OUT = 3 * 60 * 1000;
|
|
||||||
|
|
||||||
private Session session;
|
|
||||||
private Long userId;
|
|
||||||
// 这里用ConcurrentHashMap 因为他是一个线程安全的Map
|
|
||||||
private static ConcurrentHashMap<Long, NotificationConnection> websockets = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
@OnOpen
|
|
||||||
public void onOpen(Session session, @PathParam("id") String id) { // 接收到前端传来的用户ID
|
|
||||||
this.session = session;
|
|
||||||
this.userId = Long.valueOf(id);
|
|
||||||
this.session.setMaxIdleTimeout(MAX_TIME_OUT);
|
|
||||||
websockets.put(Long.parseLong(id), this); //将ID作为key,当前的对象作为Value
|
|
||||||
log.info("【建立连接】 用户为:{}", this.session);
|
|
||||||
log.info("【建立连接】 用户Id为:{}", id);
|
|
||||||
log.info("【当前连接总数】 为:{}", websockets.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClose
|
|
||||||
public void onClose(CloseReason reason) {
|
|
||||||
log.info("【连接断开】 用户为:{}, sessionId: {}, 原因为{}", this.userId, this.session.getId(), reason);
|
|
||||||
log.info("【当前连接总数】 为:{}", websockets.size());
|
|
||||||
websockets.remove(this.userId); // 将当前的对象从集合中删除
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 错误时调用
|
|
||||||
* @param throwable 异常
|
|
||||||
*/
|
|
||||||
@OnError
|
|
||||||
public void onError(Throwable throwable) {
|
|
||||||
log.info("【连接异常】 用户为:{} , sessionId: {}", this.userId, this.session.getId(), throwable);
|
|
||||||
websockets.remove(this.userId); // 将当前的对象从集合中删除
|
|
||||||
log.info("【当前连接总数】 为:{}", websockets.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
//收到了客户端消息执行的操作
|
|
||||||
@OnMessage
|
|
||||||
public void onMessage(@RequestParam String text){
|
|
||||||
Map<String, String> textMap = JSONObject.parseObject(text, Map.class);
|
|
||||||
log.info("收到了一条来自 {} 的消息:{}, sessionId:{}", this.userId, textMap.get("text"), this.session.getId());
|
|
||||||
// return "已收到你的消息";
|
|
||||||
if (textMap.get("text").equals("PING")){
|
|
||||||
sendMsg(JSON.toJSONString("PONG"), this.userId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMsg(String message, Long userId) {
|
|
||||||
if (userId == null) { // 如果等于null则证明是群发
|
|
||||||
// 获取当前Map的一个迭代器,遍历Map的方式有很多种,看着来
|
|
||||||
// 这个就是遍历这个集合的过程....
|
|
||||||
for (Map.Entry<Long, NotificationConnection> entry : websockets.entrySet()) {
|
|
||||||
// 获取每一个Entry实例
|
|
||||||
// 获取每一个Value,而这个Value就是WebSocket的实例
|
|
||||||
NotificationConnection webSocket = entry.getValue();
|
|
||||||
// 接下来就是遍历群发
|
|
||||||
log.info("广播消息 【给用户】 :{}发送消息【{}】", webSocket, message);
|
|
||||||
try {
|
|
||||||
webSocket.session.getBasicRemote().sendText(message); // 发送!!!!!!!!!
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("Failed to send message to session {}: {}", webSocket.session.getId(), e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { // 如果不是群发,则判断ID,其余步骤一致
|
|
||||||
// 获取当前Map的一个迭代器,遍历Map的方式有很多种,看着来
|
|
||||||
// 这个就是遍历这个集合的过程....
|
|
||||||
for (Map.Entry<Long, NotificationConnection> entry : websockets.entrySet()) {
|
|
||||||
// 获取每一个Entry实例
|
|
||||||
// 获取每一个Value,而这个Value就是WebSocket的实例
|
|
||||||
NotificationConnection webSocket = entry.getValue();
|
|
||||||
// 获取每一个Key,这个Key就是用户ID
|
|
||||||
Long key = entry.getKey();
|
|
||||||
// 判断用户ID与当前的Key相等
|
|
||||||
if (userId.equals(key)) {
|
|
||||||
log.info("私发消息 【给用户】 :{}发送消息【{}】", key, message); // 打印
|
|
||||||
if (webSocket.session.isOpen()){
|
|
||||||
// 避免因为网络问题或其他原因导致连接突然关闭而报错
|
|
||||||
try {
|
|
||||||
webSocket.session.getBasicRemote().sendText(message); // 则发送给当前的用户即可
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("Failed to send message to session {}: {}", webSocket.session.getId(), e.getMessage());
|
|
||||||
// 这里可以选择移除关闭的 session
|
|
||||||
websockets.remove(entry.getKey());
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
log.info("连接已关闭,sessionId:{}, userId:{}", webSocket.session.getId(), key);
|
|
||||||
websockets.remove(entry.getKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.ai.da.common.websocket.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration of WebSocket
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class WebSocketConfig {
|
|
||||||
@Bean
|
|
||||||
public ServerEndpointExporter serverEndpointExporter() {
|
|
||||||
return new ServerEndpointExporter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +1,19 @@
|
|||||||
package com.ai.da.controller;
|
package com.ai.da.controller;
|
||||||
|
|
||||||
import com.ai.da.common.config.exception.BusinessException;
|
|
||||||
import com.ai.da.common.response.PageBaseResponse;
|
|
||||||
import com.ai.da.common.response.Response;
|
import com.ai.da.common.response.Response;
|
||||||
import com.ai.da.mapper.primary.entity.Account;
|
import com.ai.da.common.security.jwt.JWTTokenHelper;
|
||||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
|
||||||
import com.ai.da.model.dto.*;
|
import com.ai.da.model.dto.*;
|
||||||
import com.ai.da.model.vo.AccountLoginVO;
|
import com.ai.da.model.vo.AccountLoginVO;
|
||||||
import com.ai.da.model.vo.AccountPreLoginVO;
|
import com.ai.da.model.vo.AccountPreLoginVO;
|
||||||
import com.ai.da.model.vo.PersonalHomepageVO;
|
|
||||||
import com.ai.da.service.AccountService;
|
import com.ai.da.service.AccountService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
@Api(tags = "Account模块")
|
@Api(tags = "Account模块")
|
||||||
@@ -40,7 +30,6 @@ public class AccountController {
|
|||||||
public Response<AccountPreLoginVO> preLogin(@Valid @RequestBody AccountPreLoginDTO accountDTO) {
|
public Response<AccountPreLoginVO> preLogin(@Valid @RequestBody AccountPreLoginDTO accountDTO) {
|
||||||
return Response.success(accountService.preLogin(accountDTO));
|
return Response.success(accountService.preLogin(accountDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "登入")
|
@ApiOperation(value = "登入")
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public Response<AccountLoginVO> login(@Valid @RequestBody AccountLoginDTO accountDTO, HttpServletRequest request) {
|
public Response<AccountLoginVO> login(@Valid @RequestBody AccountLoginDTO accountDTO, HttpServletRequest request) {
|
||||||
@@ -77,237 +66,4 @@ public class AccountController {
|
|||||||
return Response.success( accountService.isLogin(accountLogoutDTO));
|
return Response.success( accountService.isLogin(accountLogoutDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取当前用户语言")
|
|
||||||
@PostMapping("/getUserLanguage")
|
|
||||||
public Response<String> getUserLanguage() {
|
|
||||||
return Response.success(accountService.getUserLanguage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "切换当前用户语言")
|
|
||||||
@GetMapping("/changeUserLanguage")
|
|
||||||
public Response<String> changeUserLanguage(String language) {
|
|
||||||
return Response.success(accountService.changeUserLanguage(language));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "试用用户退出登录")
|
|
||||||
@GetMapping("/trialUserLogout")
|
|
||||||
public Response<Boolean> trialUserLogout() {
|
|
||||||
return Response.success(accountService.trialUserLogout());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "完成新手教程")
|
|
||||||
@PostMapping("/completeGuidance")
|
|
||||||
public Response<Boolean> completeGuidance() {
|
|
||||||
return Response.success(accountService.completeGuidance());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "试用订单列表")
|
|
||||||
@PostMapping("/trialOrderList")
|
|
||||||
public Response<PageBaseResponse<TrialOrder>> trialOrderList(@Valid @RequestBody TrialOrderDTO trialOrderDTO) {
|
|
||||||
return Response.success(PageBaseResponse.success(accountService.trialOrderList(trialOrderDTO)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "通过试用订单审批")
|
|
||||||
@PostMapping("/trialOrderApproval")
|
|
||||||
public Response<Boolean> trialOrderApproval(@RequestParam("ids") List<Long> ids) {
|
|
||||||
return Response.success(accountService.trialOrderApproval(ids));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "拒绝试用订单审批")
|
|
||||||
@PostMapping("/trialOrderRefuse")
|
|
||||||
public Response<Boolean> trialOrderRefuse(@RequestParam("ids") List<Long> ids) {
|
|
||||||
return Response.success(accountService.trialOrderRefuse(ids));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "获取是否自动审评")
|
|
||||||
@PostMapping("/getIsAutoApproval")
|
|
||||||
public Response<Boolean> getIsAutoApproval() {
|
|
||||||
return Response.success(accountService.getIsAutoApproval());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "切换是否自动审评")
|
|
||||||
@PostMapping("/switchIsAutoApproval")
|
|
||||||
public Response<Boolean> switchIsAutoApproval() {
|
|
||||||
return Response.success(accountService.switchIsAutoApproval());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "aws状态检测")
|
|
||||||
@GetMapping("/healthy")
|
|
||||||
@ResponseStatus(HttpStatus.OK)
|
|
||||||
public Response<Map<String,Integer>> checkStatus(){
|
|
||||||
Map<String,Integer> returnMap = new HashMap<>();
|
|
||||||
returnMap.put("code",200);
|
|
||||||
return Response.success(returnMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "查询账号到期时间")
|
|
||||||
@PostMapping("/getExpiredTime")
|
|
||||||
public Response<Long> getExpiredTime(){
|
|
||||||
return Response.success(accountService.getExpiredTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "免密登录")
|
|
||||||
@PostMapping("/noLoginRequired")
|
|
||||||
public Response<AccountLoginVO> noLoginRequired(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request){
|
|
||||||
return Response.success(accountService.noLoginRequired(noLoginRequiredDTO, request));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("upgradeNotification")
|
|
||||||
@ApiOperation(value = "升级邮件通知")
|
|
||||||
public Response<Boolean> upgradeNotification() {
|
|
||||||
accountService.upgradeNotification();
|
|
||||||
return Response.success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@CrossOrigin
|
|
||||||
@ApiOperation(value = "广场用户注册")
|
|
||||||
@PostMapping("/designWorksRegister")
|
|
||||||
public Response<Boolean> designWorksRegister(@Valid @RequestBody AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO) {
|
|
||||||
return Response.success(accountService.designWorksRegister(accountDesignWorksRegisterDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@CrossOrigin
|
|
||||||
@ApiOperation(value = "广场用户注册")
|
|
||||||
@PostMapping("/designWorksRegisterCode")
|
|
||||||
public Response<AccountLoginVO> designWorksRegisterCode(@Valid @RequestBody AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO) {
|
|
||||||
return Response.success(accountService.designWorksRegisterCode(accountDesignWorksRegisterDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 填写调查问卷
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@ApiOperation(value = "填写调查问卷")
|
|
||||||
@PostMapping("/questionnaire")
|
|
||||||
public Response<Boolean> questionnaire(@Valid @RequestBody String questionnaireInfo){
|
|
||||||
return Response.success(accountService.collectQuestionnaires(questionnaireInfo));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 参与活动 获取福利
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@ApiOperation(value = "参与活动 获取福利")
|
|
||||||
@GetMapping("/activity")
|
|
||||||
public Response<String> getActivityBenefits(){
|
|
||||||
return Response.success(accountService.getActivityBenefits());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "将用户账号过期时间设置为过期当天的23:59:59")
|
|
||||||
@GetMapping("/setUserValidToDayEnd")
|
|
||||||
public Response<List<Long>> setUserValidToDayEnd(){
|
|
||||||
return Response.success(accountService.setUserValidToDayEnd());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 用户上传头像
|
|
||||||
@ApiOperation(value = "上传头像")
|
|
||||||
@PostMapping(path = "/uploadAvatar")
|
|
||||||
public Response<String> uploadAvatar(@RequestParam("file") MultipartFile file) {
|
|
||||||
if (null == file || StringUtils.isEmpty(file.getOriginalFilename())) {
|
|
||||||
throw new BusinessException("file.cannot.be.empty");
|
|
||||||
}
|
|
||||||
return Response.success(accountService.uploadAvatar(file));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "个人主页浏览量增加")
|
|
||||||
@GetMapping("/viewsIncrease")
|
|
||||||
public Response<Boolean> viewsGet(@RequestParam("id") Long id) {
|
|
||||||
return Response.success(accountService.viewsIncrease(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "获取个人主页信息")
|
|
||||||
@GetMapping("/personalHomepage")
|
|
||||||
public Response<PersonalHomepageVO> getPersonalHomepage(@RequestParam("id") Long id){
|
|
||||||
return Response.success(accountService.getPersonalHomepage(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "getUsernameModifyTimes")
|
|
||||||
@GetMapping("/getNicknameModifyTimes")
|
|
||||||
public Response<Map<String, Long>> getNicknameModifyTimes(){
|
|
||||||
return Response.success(accountService.getNicknameModifyTimes());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "editUserName")
|
|
||||||
@GetMapping("/editUserName")
|
|
||||||
public Response<String> editUserName(@RequestParam("newUserName") String newUserName){
|
|
||||||
accountService.editUserName(newUserName);
|
|
||||||
return Response.success("success");
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "verifyUserEmail")
|
|
||||||
@GetMapping("/verifyUserEmail")
|
|
||||||
public Response<String> verifyUserEmail(@RequestParam("verifyCode") String verifyCode){
|
|
||||||
accountService.verifyUserEmail(verifyCode);
|
|
||||||
return Response.success("success");
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "changeUserEmail")
|
|
||||||
@GetMapping("/changeUserEmail")
|
|
||||||
public Response<String> changeUserEmail(@RequestParam("newMailbox") String newMailbox){
|
|
||||||
accountService.changeUserEmail(newMailbox);
|
|
||||||
return Response.success("success");
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "activateNewEmail")
|
|
||||||
@GetMapping("/activateNewEmail")
|
|
||||||
public Response<String> activateNewEmail(@RequestParam("token") String token){
|
|
||||||
accountService.activateNewEmail(token);
|
|
||||||
return Response.success("success");
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("halfPricePromotion")
|
|
||||||
@ApiOperation(value = "十月半价活动")
|
|
||||||
public Response<Boolean> halfPricePromotion() {
|
|
||||||
accountService.halfPricePromotion();
|
|
||||||
return Response.success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("temporaryUpgrade")
|
|
||||||
@ApiOperation(value = "临时升级")
|
|
||||||
public Response<Boolean> temporaryUpgrade() {
|
|
||||||
accountService.temporaryUpgrade();
|
|
||||||
return Response.success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("enterpriseLogin")
|
|
||||||
@ApiOperation(value = "企业登录")
|
|
||||||
public Response<AccountLoginVO> enterpriseLogin(@Valid @RequestBody AccountLoginDTO accountDTO) {
|
|
||||||
return Response.success(accountService.enterpriseLogin(accountDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("schoolLogin")
|
|
||||||
@ApiOperation(value = "学校登录")
|
|
||||||
public Response<AccountLoginVO> schoolLogin(@Valid @RequestBody AccountLoginDTO accountDTO) {
|
|
||||||
return Response.success(accountService.schoolLogin(accountDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("addOrUpdateSubAccount")
|
|
||||||
@ApiOperation(value = "子账号新增")
|
|
||||||
public Response<Boolean> addSubAccount(@Valid @RequestBody AddSubAccountDTO addSubAccountDTO) {
|
|
||||||
return Response.success(accountService.addSubAccount(addSubAccountDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("deleteSubAccount")
|
|
||||||
@ApiOperation(value = "子账号删除")
|
|
||||||
public Response<Boolean> deleteSubAccount(@Valid @RequestBody AddSubAccountDTO addSubAccountDTO) {
|
|
||||||
return Response.success(accountService.deleteSubAccount(addSubAccountDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("subAccountList")
|
|
||||||
@ApiOperation(value = "子账号查询")
|
|
||||||
public Response<PageBaseResponse<Account>> subAccountList(@Valid @RequestBody SubAccountPageDTO subAccountPageDTO) {
|
|
||||||
return Response.success(accountService.subAccountList(subAccountPageDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("accountDetail")
|
|
||||||
@ApiOperation(value = "账号详情")
|
|
||||||
public Response<Account> accountDetail(@RequestParam("id") Long id) {
|
|
||||||
return Response.success(accountService.accountDetail(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("getAccountDetail")
|
|
||||||
@ApiOperation(value = "获取账户信息")
|
|
||||||
public Response<AccountLoginVO> getAccountDetail() {
|
|
||||||
return Response.success(accountService.getAccountDetail());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
package com.ai.da.controller;
|
|
||||||
|
|
||||||
import com.ai.da.common.response.Response;
|
|
||||||
import com.ai.da.service.AliPayService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@CrossOrigin
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/ali-pay")
|
|
||||||
@Api(tags = "网站支付宝支付")
|
|
||||||
@Slf4j
|
|
||||||
public class AliPayController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private AliPayService aliPayService;
|
|
||||||
|
|
||||||
@ApiOperation("统一收单下单并支付页面接口的调用")
|
|
||||||
@PostMapping("/trade/page/pay/{amount}")
|
|
||||||
public Response<String> tradePagePay(@PathVariable Integer amount, @RequestParam String returnUrl){
|
|
||||||
log.info("统一收单下单并支付页面接口的调用");
|
|
||||||
//支付宝开放平台接受 request 请求对象后
|
|
||||||
// 会为开发者生成一个html 形式的 form表单,包含自动提交的脚本
|
|
||||||
String formStr = aliPayService.tradeCreate(amount, returnUrl);
|
|
||||||
//我们将form表单字符串返回给前端程序,之后前端将会调用自动提交脚本,进行表单的提交
|
|
||||||
//此时,表单会自动提交到action属性所指向的支付宝开放平台中,从而为用户展示一个支付页面
|
|
||||||
return Response.success(formStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("支付通知")
|
|
||||||
@PostMapping("/trade/notify")
|
|
||||||
public String tradeNotify(@RequestParam Map<String, String> params){
|
|
||||||
return aliPayService.tradeNotify(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户取消订单
|
|
||||||
* @param orderNo
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@ApiOperation("用户取消订单")
|
|
||||||
@PostMapping("/trade/close/{orderNo}")
|
|
||||||
public Response<String> cancel(@PathVariable String orderNo){
|
|
||||||
log.info("取消订单");
|
|
||||||
aliPayService.cancelOrder(orderNo);
|
|
||||||
return Response.success("订单已取消");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询订单
|
|
||||||
* @param orderNo
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@ApiOperation("查询订单:测试订单状态用")
|
|
||||||
@GetMapping("/trade/query/{orderNo}")
|
|
||||||
public Response<String> queryOrder(@PathVariable String orderNo) {
|
|
||||||
log.info("查询订单");
|
|
||||||
String result = aliPayService.queryOrder(orderNo);
|
|
||||||
return Response.success(result);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 不在页面提供申请退款接口
|
|
||||||
* @param orderNo
|
|
||||||
* @param reason
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@ApiOperation("申请退款")
|
|
||||||
@PostMapping("/trade/refund/{orderNo}/{reason}")
|
|
||||||
public Response<String> refunds(@PathVariable String orderNo, @PathVariable String reason){
|
|
||||||
log.info("申请退款");
|
|
||||||
aliPayService.refund(orderNo, reason);
|
|
||||||
return Response.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询退款
|
|
||||||
* @param orderNo
|
|
||||||
* @return
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
@ApiOperation("查询退款:测试用")
|
|
||||||
@GetMapping("/trade/fastpay/refund/{orderNo}")
|
|
||||||
public Response<String> queryRefund(@PathVariable String orderNo) {
|
|
||||||
log.info("查询退款");
|
|
||||||
String result = aliPayService.queryRefund(orderNo);
|
|
||||||
return Response.success(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据账单类型和日期获取账单url地址
|
|
||||||
*
|
|
||||||
* @param billDate
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@ApiOperation("获取账单url")
|
|
||||||
@GetMapping("/bill/downloadurl/query/{billDate}/{type}")
|
|
||||||
public Response<String> queryTradeBill(
|
|
||||||
@PathVariable String billDate,
|
|
||||||
@PathVariable String type) {
|
|
||||||
log.info("获取账单url");
|
|
||||||
String downloadUrl = aliPayService.queryBill(billDate, type);
|
|
||||||
return Response.success(downloadUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
package com.ai.da.controller;
|
|
||||||
|
|
||||||
import com.ai.da.common.response.Response;
|
|
||||||
import com.ai.da.service.AlipayHKService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
@CrossOrigin
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/alipay-hk")
|
|
||||||
@Api(tags = "网站支付 香港支付宝")
|
|
||||||
@Slf4j
|
|
||||||
public class AlipayHKController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private AlipayHKService alipayHKService;
|
|
||||||
|
|
||||||
@ApiOperation(value = "创建订单")
|
|
||||||
@PostMapping(value = "/createOrder/{wallet}/{amount}")
|
|
||||||
public Response<String> createOrder(@PathVariable Integer amount, @PathVariable String wallet) {
|
|
||||||
String order = alipayHKService.createOrder(amount, wallet);
|
|
||||||
return Response.success(order);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("支付通知")
|
|
||||||
@PostMapping("/trade/notify")
|
|
||||||
public String callback(@RequestBody String paramString){
|
|
||||||
log.info("alipay-hk callback parameter : {}", paramString);
|
|
||||||
return alipayHKService.callback(paramString);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("订单查询")
|
|
||||||
@PostMapping("/trade/query/{orderRef}")
|
|
||||||
public Response<String> queryOrder(@PathVariable String orderRef){
|
|
||||||
String s = alipayHKService.queryDetail(orderRef);
|
|
||||||
return Response.success(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
package com.ai.da.controller;
|
|
||||||
|
|
||||||
import com.ai.da.common.response.Response;
|
|
||||||
import com.ai.da.model.dto.ClassificationDTO;
|
|
||||||
import com.ai.da.model.vo.ClassificationVO;
|
|
||||||
import com.ai.da.service.ClassificationService;
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 控制器
|
|
||||||
*
|
|
||||||
* @author SHAHAIBO
|
|
||||||
* @since 2023-11-03
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@RequestMapping("/api/classification")
|
|
||||||
@Api(value = "", tags = "分类")
|
|
||||||
public class ClassificationController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ClassificationService classificationService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增修改
|
|
||||||
*/
|
|
||||||
@PostMapping("/saveOrUpdate")
|
|
||||||
@ApiOperationSupport(order = 1)
|
|
||||||
@ApiOperation(value = "新增修改", notes = "传入ClassificationDTO")
|
|
||||||
public Response<Boolean> saveOrUpdate(@Valid @RequestBody ClassificationDTO classificationDTO) {
|
|
||||||
return Response.success(classificationService.saveOrUpdate(classificationDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*/
|
|
||||||
@PostMapping("/delete")
|
|
||||||
@ApiOperationSupport(order = 2)
|
|
||||||
@ApiOperation(value = "删除", notes = "传入ClassificationDTO")
|
|
||||||
public Response<Boolean> delete(@Valid @RequestBody ClassificationDTO classificationDTO) {
|
|
||||||
return Response.success(classificationService.delete(classificationDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/queryClassification")
|
|
||||||
@ApiOperationSupport(order = 3)
|
|
||||||
@ApiModelProperty(value = "查询", notes = "传入ClassificationDTO")
|
|
||||||
public Response<List<ClassificationVO>> queryClassification(@Valid @RequestBody ClassificationDTO classificationDTO) {
|
|
||||||
return Response.success(classificationService.queryClassification(classificationDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/relationLibrary")
|
|
||||||
@ApiOperationSupport(order = 4)
|
|
||||||
@ApiModelProperty(value = "关联", notes = "传入ClassificationDTO")
|
|
||||||
public Response<Boolean> relationLibrary(@Valid @RequestBody ClassificationDTO classificationDTO) {
|
|
||||||
return Response.success(classificationService.relationLibrary(classificationDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/getRelClassificationIdList")
|
|
||||||
@ApiOperationSupport(order = 5)
|
|
||||||
@ApiModelProperty(value = "获取关联分类IDList", notes = "传入ClassificationDTO")
|
|
||||||
public Response<List<Long>> getRelClassificationIdList(@Valid @RequestBody ClassificationDTO classificationDTO) {
|
|
||||||
return Response.success(classificationService.getRelClassificationIdList(classificationDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多选 获取共有标签
|
|
||||||
* @param classificationDTO
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/getRelPublicClassificationIdList")
|
|
||||||
@ApiOperationSupport(order = 5)
|
|
||||||
@ApiModelProperty(value = "获取关联公共分类IDList", notes = "传入ClassificationDTO")
|
|
||||||
public Response<List<Long>> getRelPublicClassificationIdList(@Valid @RequestBody ClassificationDTO classificationDTO) {
|
|
||||||
return Response.success(classificationService.getRelPublicClassificationIdList(classificationDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多选 编辑共有标签
|
|
||||||
* @param classificationDTO
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/editRelPublicClassificationIdList")
|
|
||||||
@ApiOperationSupport(order = 5)
|
|
||||||
@ApiModelProperty(value = "编辑关联公共分类IDList", notes = "传入ClassificationDTO")
|
|
||||||
public Response<Boolean> editRelPublicClassificationIdList(@Valid @RequestBody ClassificationDTO classificationDTO) {
|
|
||||||
return Response.success(classificationService.editRelPublicClassificationIdList(classificationDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
package com.ai.da.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import com.ai.da.common.context.UserContext;
|
|
||||||
import com.ai.da.common.response.Response;
|
|
||||||
import com.ai.da.mapper.primary.DesignMapper;
|
|
||||||
import com.ai.da.mapper.primary.entity.Account;
|
|
||||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
|
||||||
import com.ai.da.model.dto.AccountAddDTO;
|
|
||||||
import com.ai.da.model.dto.UserDesignStatisticDTO;
|
|
||||||
import com.ai.da.model.vo.QuestionnaireFeedbackVO;
|
|
||||||
import com.ai.da.model.vo.QuestionnaireVO;
|
|
||||||
import com.ai.da.model.vo.QueryUserConditionsVO;
|
|
||||||
import com.ai.da.service.ConvenientInquiryService;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import io.netty.util.internal.StringUtil;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Api(tags = "便利查询")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/inquiry")
|
|
||||||
public class ConvenientInquiryController {
|
|
||||||
@Resource
|
|
||||||
private DesignMapper designMapper;
|
|
||||||
@Resource
|
|
||||||
private ConvenientInquiryService convenientInquiryService;
|
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("获取当前所有试用用户")
|
|
||||||
@PostMapping("/getTrial")
|
|
||||||
public Response<IPage<TrialOrder>> getTrial(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
|
||||||
Long accountId = UserContext.getUserHolder().getId();
|
|
||||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)) {
|
|
||||||
return Response.success(convenientInquiryService.getTrial(queryUserConditionsVO));
|
|
||||||
} else {
|
|
||||||
return Response.fail("Sorry, you don't have permission");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取指定时间区间内所有用户design的使用情况")
|
|
||||||
@GetMapping("/getDesignStatistic")
|
|
||||||
public Response<List<UserDesignStatisticDTO>> getDesignStatistic(@RequestParam String startTime, @RequestParam String endTime,
|
|
||||||
@RequestParam(required = false) List<Long> ids, @RequestParam(required = false) String email) {
|
|
||||||
Long accountId = UserContext.getUserHolder().getId();
|
|
||||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)) {
|
|
||||||
if (StringUtil.isNullOrEmpty(startTime)) startTime = "2024-02-01 00:00:00";
|
|
||||||
if (StringUtil.isNullOrEmpty(endTime)) {
|
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
||||||
Date date = new Date();
|
|
||||||
endTime = simpleDateFormat.format(date);
|
|
||||||
}
|
|
||||||
if (!StringUtil.isNullOrEmpty(email)){
|
|
||||||
email = email.trim();
|
|
||||||
}
|
|
||||||
List<UserDesignStatisticDTO> designStatistic = designMapper.getDesignStatistic(startTime, endTime, ids, email);
|
|
||||||
return Response.success(designStatistic);
|
|
||||||
} else {
|
|
||||||
return Response.fail("Sorry, you don't have permission");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//调查问卷
|
|
||||||
@ApiOperation("获取调查问卷统计详情")
|
|
||||||
@GetMapping("/getQuestionnaireStatistic")
|
|
||||||
public Response<QuestionnaireFeedbackVO> getQuestionnaire() {
|
|
||||||
return Response.success(convenientInquiryService.getQuestionnaireInfo());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取所有调查问卷")
|
|
||||||
@GetMapping("/getAllQuestionnaire")
|
|
||||||
public Response<List<QuestionnaireVO>> getAllQuestionnaire() {
|
|
||||||
return Response.success(convenientInquiryService.getAllQuestionnaire());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取近期新用户")
|
|
||||||
@PostMapping("/recentNewUser")
|
|
||||||
public Response<IPage<Account>> recentNewUser(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
|
||||||
return Response.success(convenientInquiryService.recentNewUser(queryUserConditionsVO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取近期新用户图表数据")
|
|
||||||
@GetMapping("/recentNewUserChart")
|
|
||||||
public Response<Map<String, Object>> recentNewUserChart(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
|
||||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime,
|
|
||||||
@ApiParam("userType") @RequestParam Integer userType) {
|
|
||||||
return Response.success(convenientInquiryService.recentNewUserChart(startTime, endTime, userType));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取近期活跃用户")
|
|
||||||
@PostMapping("/recentActiveUser")
|
|
||||||
public Response<IPage<Account>> recentActiveUser(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
|
||||||
return Response.success(convenientInquiryService.recentActiveUser(queryUserConditionsVO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取近期活跃用户图表数据")
|
|
||||||
@GetMapping("/recentActiveUserChart")
|
|
||||||
public Response<Integer> recentActiveUserChart(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
|
||||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime) {
|
|
||||||
return Response.success(convenientInquiryService.recentActiveUserChart(startTime, endTime));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取用户的各模块功能使用详情")
|
|
||||||
@GetMapping("/getActiveUserFunc")
|
|
||||||
public Response<Map<String, List<Object>>> getActiveUserFunc(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
|
||||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime,
|
|
||||||
@ApiParam("userIdList") @RequestParam @Nullable List<Long> userIdList) {
|
|
||||||
return Response.success(convenientInquiryService.getActiveUserFunc(startTime, endTime, userIdList));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("试用用户到正式用户的转化率")
|
|
||||||
@GetMapping("/conversionRate")
|
|
||||||
public Response<Map<String, Object>> conversionRate(@ApiParam(value = "startTime") @RequestParam(required = false) @Nullable String startTime,
|
|
||||||
@ApiParam(value = "endTime") @RequestParam(required = false) @Nullable String endTime) {
|
|
||||||
return Response.success(convenientInquiryService.conversionRate(startTime, endTime));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("试用用户国家/城市分布")
|
|
||||||
@GetMapping("/trialUserCountry")
|
|
||||||
public Response<Map<String, List<Object>>> trialUserCountry(@ApiParam(value = "startTime") @RequestParam(required = false) @Nullable String startTime,
|
|
||||||
@ApiParam(value = "endTime") @RequestParam(required = false) @Nullable String endTime) {
|
|
||||||
return Response.success(convenientInquiryService.trialUserCountry(startTime, endTime));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("添加用户")
|
|
||||||
@PostMapping("/addUser")
|
|
||||||
public Response<Boolean> addUser(@Valid @RequestBody AccountAddDTO accountAddDTO) {
|
|
||||||
return Response.success(convenientInquiryService.addUser(accountAddDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("修改用户信息")
|
|
||||||
@PostMapping("/modifyUser")
|
|
||||||
public Response<Boolean> modifyUser(@ApiParam(value = "用户id") @RequestParam @Nullable Long accountId,
|
|
||||||
@ApiParam(value = "有效期截止时间的毫秒级unix格式") @RequestParam @Nullable Long validEndTime,
|
|
||||||
@ApiParam(value = "用户类型 1/2/3/0 -> yearly/monthly/trial/visitor") @RequestParam @Nullable Integer systemUser,
|
|
||||||
@ApiParam("积分") @RequestParam @Nullable Long credits) {
|
|
||||||
return Response.success(convenientInquiryService.modifyUser(accountId, validEndTime, systemUser, credits));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取用户信息")
|
|
||||||
@PostMapping("/getUserInfo")
|
|
||||||
public Response<IPage<Account>> getUserInfo(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
|
||||||
Long accountId = UserContext.getUserHolder().getId();
|
|
||||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)) {
|
|
||||||
return Response.success(convenientInquiryService.getUserInfo(queryUserConditionsVO));
|
|
||||||
} else {
|
|
||||||
return Response.fail("Sorry, you don't have permission");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取所有用户id")
|
|
||||||
@GetMapping("/getAllUserId")
|
|
||||||
public Response<List<Map<String, Object>>> getAllUsrIdList() {
|
|
||||||
return Response.success(convenientInquiryService.getAllUserIdList());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user