Compare commits
21 Commits
3352bc82d9
...
f4bb4b27a2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4bb4b27a2 | ||
|
|
10d39ac0c4 | ||
|
|
6687d0b5ff | ||
|
|
8eb42c9364 | ||
|
|
658149639f | ||
|
|
3df8767c47 | ||
| 5e6e9a8787 | |||
| 5005d8ac2a | |||
| 0eb5128b6f | |||
| acf4c6a307 | |||
| 3561cd098a | |||
| a2ed179fbb | |||
| faa655bc9d | |||
| b0bf6dc338 | |||
| 316702a8cf | |||
| 8482a88870 | |||
| eda8e74b1a | |||
| 8557335cd2 | |||
| a16cb37c7f | |||
| dbf6c45ec8 | |||
| d38a439e3c |
147
.gitea/workflows/prod_build_commit.yaml
Normal file
147
.gitea/workflows/prod_build_commit.yaml
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
name: git commit 控制 连卡佛 back-java prod 分支构建部署
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- prod/release_1.0
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: "contains(github.event.head_commit.message, '[run build]')"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
REMOTE_DEPLOY_PATH: /workspace/workspace_lanecrawford/back
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 1.检出代码
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: prod/release_1.0
|
||||||
|
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '21'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: 2.设置JAVA Maven 环境
|
||||||
|
run: |
|
||||||
|
# 适配act的root用户和Gitea Runner普通用户
|
||||||
|
SUDO=""
|
||||||
|
[ "$(id -u)" != "0" ] && SUDO="sudo"
|
||||||
|
|
||||||
|
# 安装依赖
|
||||||
|
$SUDO apt update && $SUDO apt install -y wget tar --no-install-recommends
|
||||||
|
|
||||||
|
# 下载并安装Maven
|
||||||
|
MAVEN_VERSION="3.6.3"
|
||||||
|
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: 2.构建jar包
|
||||||
|
run:
|
||||||
|
mvn -B clean package -DskipTests --file pom.xml
|
||||||
|
|
||||||
|
- name: 3.检查 Runner 本地文件
|
||||||
|
run: |
|
||||||
|
echo "当前目录:$(pwd)"
|
||||||
|
echo "target 目录内容:"
|
||||||
|
ls -la ./target/
|
||||||
|
|
||||||
|
# 容错:处理通配符无匹配的情况
|
||||||
|
JAR_FILE=$(ls ./target/*.jar 2>/dev/null | head -n1)
|
||||||
|
if [ -z "$JAR_FILE" ] || [ ! -f "$JAR_FILE" ]; then
|
||||||
|
echo "❌ Runner 本地无有效 JAR 包!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查Docker配置文件
|
||||||
|
for FILE in Dockerfile docker-compose.yml; do
|
||||||
|
if [ ! -f "./$FILE" ]; then
|
||||||
|
echo "❌ 缺失文件:$FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "✅ 本地文件校验通过!"
|
||||||
|
|
||||||
|
- name: 4. 同步文件到远程服务器
|
||||||
|
uses: appleboy/scp-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
source: "./target/*.jar,./Dockerfile,./docker-compose.yml"
|
||||||
|
target: ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
ssh_options: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
||||||
|
strip_components: 0
|
||||||
|
|
||||||
|
- name: 5. 验证远程文件
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
echo "===== 远程部署目录文件列表 ====="
|
||||||
|
ls -la ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
|
||||||
|
# 容错:检查JAR包
|
||||||
|
REMOTE_JAR=$(ls ${{ env.REMOTE_DEPLOY_PATH }}/target/*.jar 2>/dev/null | head -n1)
|
||||||
|
if [ -z "$REMOTE_JAR" ] || [ ! -f "$REMOTE_JAR" ]; then
|
||||||
|
echo "❌ 远程服务器无有效 JAR 包!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查Docker文件
|
||||||
|
for FILE in Dockerfile docker-compose.yml; do
|
||||||
|
if [ ! -f "${{ env.REMOTE_DEPLOY_PATH }}/$FILE" ]; then
|
||||||
|
echo "❌ 远程缺失文件:$FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "✅ 远程文件校验通过!"
|
||||||
|
|
||||||
|
- name: 6. 部署和运行服务
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
echo "===== 开始部署服务 ====="
|
||||||
|
cd ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
|
||||||
|
# 容错:停止旧容器(不存在则跳过)
|
||||||
|
echo "停止旧容器..."
|
||||||
|
docker compose down || true
|
||||||
|
|
||||||
|
# 清理无效镜像(可选,释放空间)
|
||||||
|
docker system prune -f
|
||||||
|
|
||||||
|
# 构建并启动新容器
|
||||||
|
echo "构建Docker镜像..."
|
||||||
|
docker compose build --no-cache
|
||||||
|
echo "启动服务..."
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# 验证服务状态
|
||||||
|
echo "验证容器状态..."
|
||||||
|
docker compose ps
|
||||||
|
echo "✅ 部署完成!"
|
||||||
143
.gitea/workflows/prod_build_manual.yaml
Normal file
143
.gitea/workflows/prod_build_manual.yaml
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
name: 手动 连卡佛 back-java prod 分支构建部署
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
REMOTE_DEPLOY_PATH: /workspace/workspace_lanecrawford/back
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 1.检出代码
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: prod/release_1.0
|
||||||
|
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '21'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: 2.设置JAVA Maven 环境
|
||||||
|
run: |
|
||||||
|
# 适配act的root用户和Gitea Runner普通用户
|
||||||
|
SUDO=""
|
||||||
|
[ "$(id -u)" != "0" ] && SUDO="sudo"
|
||||||
|
|
||||||
|
# 安装依赖
|
||||||
|
$SUDO apt update && $SUDO apt install -y wget tar --no-install-recommends
|
||||||
|
|
||||||
|
# 下载并安装Maven
|
||||||
|
MAVEN_VERSION="3.6.3"
|
||||||
|
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: 2.构建jar包
|
||||||
|
run:
|
||||||
|
mvn -B clean package -DskipTests --file pom.xml
|
||||||
|
|
||||||
|
- name: 3.检查 Runner 本地文件
|
||||||
|
run: |
|
||||||
|
echo "当前目录:$(pwd)"
|
||||||
|
echo "target 目录内容:"
|
||||||
|
ls -la ./target/
|
||||||
|
|
||||||
|
# 容错:处理通配符无匹配的情况
|
||||||
|
JAR_FILE=$(ls ./target/*.jar 2>/dev/null | head -n1)
|
||||||
|
if [ -z "$JAR_FILE" ] || [ ! -f "$JAR_FILE" ]; then
|
||||||
|
echo "❌ Runner 本地无有效 JAR 包!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查Docker配置文件
|
||||||
|
for FILE in Dockerfile docker-compose.yml; do
|
||||||
|
if [ ! -f "./$FILE" ]; then
|
||||||
|
echo "❌ 缺失文件:$FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "✅ 本地文件校验通过!"
|
||||||
|
|
||||||
|
- name: 4. 同步文件到远程服务器
|
||||||
|
uses: appleboy/scp-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
source: "./target/*.jar,./Dockerfile,./docker-compose.yml"
|
||||||
|
target: ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
ssh_options: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
||||||
|
strip_components: 0
|
||||||
|
|
||||||
|
- name: 5. 验证远程文件
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
echo "===== 远程部署目录文件列表 ====="
|
||||||
|
ls -la ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
|
||||||
|
# 容错:检查JAR包
|
||||||
|
REMOTE_JAR=$(ls ${{ env.REMOTE_DEPLOY_PATH }}/target/*.jar 2>/dev/null | head -n1)
|
||||||
|
if [ -z "$REMOTE_JAR" ] || [ ! -f "$REMOTE_JAR" ]; then
|
||||||
|
echo "❌ 远程服务器无有效 JAR 包!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查Docker文件
|
||||||
|
for FILE in Dockerfile docker-compose.yml; do
|
||||||
|
if [ ! -f "${{ env.REMOTE_DEPLOY_PATH }}/$FILE" ]; then
|
||||||
|
echo "❌ 远程缺失文件:$FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "✅ 远程文件校验通过!"
|
||||||
|
|
||||||
|
- name: 6. 部署和运行服务
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
echo "===== 开始部署服务 ====="
|
||||||
|
cd ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
|
||||||
|
# 容错:停止旧容器(不存在则跳过)
|
||||||
|
echo "停止旧容器..."
|
||||||
|
docker compose down || true
|
||||||
|
|
||||||
|
# 清理无效镜像(可选,释放空间)
|
||||||
|
docker system prune -f
|
||||||
|
|
||||||
|
# 构建并启动新容器
|
||||||
|
echo "构建Docker镜像..."
|
||||||
|
docker compose build --no-cache
|
||||||
|
echo "启动服务..."
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# 验证服务状态
|
||||||
|
echo "验证容器状态..."
|
||||||
|
docker compose ps
|
||||||
|
echo "✅ 部署完成!"
|
||||||
146
.gitea/workflows/prod_build_schedule.yaml
Normal file
146
.gitea/workflows/prod_build_schedule.yaml
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
name: 定时 连卡佛 back-java prod 分支构建部署
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# cron为UTC时区,构建时间=部署时间-8小时 {*分 (-8)时 *日 *月 *周} ---
|
||||||
|
# 示例: 1月1日22点22分触发构建 cron写作 - '22 14 1 1 *'
|
||||||
|
- cron: '22 14 1 1 *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
REMOTE_DEPLOY_PATH: /workspace/workspace_lanecrawford/back
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 1.检出代码
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: prod/release_1.0
|
||||||
|
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '21'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: 2.设置JAVA Maven 环境
|
||||||
|
run: |
|
||||||
|
# 适配act的root用户和Gitea Runner普通用户
|
||||||
|
SUDO=""
|
||||||
|
[ "$(id -u)" != "0" ] && SUDO="sudo"
|
||||||
|
|
||||||
|
# 安装依赖
|
||||||
|
$SUDO apt update && $SUDO apt install -y wget tar --no-install-recommends
|
||||||
|
|
||||||
|
# 下载并安装Maven
|
||||||
|
MAVEN_VERSION="3.6.3"
|
||||||
|
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: 2.构建jar包
|
||||||
|
run:
|
||||||
|
mvn -B clean package -DskipTests --file pom.xml
|
||||||
|
|
||||||
|
- name: 3.检查 Runner 本地文件
|
||||||
|
run: |
|
||||||
|
echo "当前目录:$(pwd)"
|
||||||
|
echo "target 目录内容:"
|
||||||
|
ls -la ./target/
|
||||||
|
|
||||||
|
# 容错:处理通配符无匹配的情况
|
||||||
|
JAR_FILE=$(ls ./target/*.jar 2>/dev/null | head -n1)
|
||||||
|
if [ -z "$JAR_FILE" ] || [ ! -f "$JAR_FILE" ]; then
|
||||||
|
echo "❌ Runner 本地无有效 JAR 包!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查Docker配置文件
|
||||||
|
for FILE in Dockerfile docker-compose.yml; do
|
||||||
|
if [ ! -f "./$FILE" ]; then
|
||||||
|
echo "❌ 缺失文件:$FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "✅ 本地文件校验通过!"
|
||||||
|
|
||||||
|
- name: 4. 同步文件到远程服务器
|
||||||
|
uses: appleboy/scp-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
source: "./target/*.jar,./Dockerfile,./docker-compose.yml"
|
||||||
|
target: ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
ssh_options: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
||||||
|
strip_components: 0
|
||||||
|
|
||||||
|
- name: 5. 验证远程文件
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
echo "===== 远程部署目录文件列表 ====="
|
||||||
|
ls -la ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
|
||||||
|
# 容错:检查JAR包
|
||||||
|
REMOTE_JAR=$(ls ${{ env.REMOTE_DEPLOY_PATH }}/target/*.jar 2>/dev/null | head -n1)
|
||||||
|
if [ -z "$REMOTE_JAR" ] || [ ! -f "$REMOTE_JAR" ]; then
|
||||||
|
echo "❌ 远程服务器无有效 JAR 包!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查Docker文件
|
||||||
|
for FILE in Dockerfile docker-compose.yml; do
|
||||||
|
if [ ! -f "${{ env.REMOTE_DEPLOY_PATH }}/$FILE" ]; then
|
||||||
|
echo "❌ 远程缺失文件:$FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "✅ 远程文件校验通过!"
|
||||||
|
|
||||||
|
- name: 6. 部署和运行服务
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
echo "===== 开始部署服务 ====="
|
||||||
|
cd ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
|
||||||
|
# 容错:停止旧容器(不存在则跳过)
|
||||||
|
echo "停止旧容器..."
|
||||||
|
docker compose down || true
|
||||||
|
|
||||||
|
# 清理无效镜像(可选,释放空间)
|
||||||
|
docker system prune -f
|
||||||
|
|
||||||
|
# 构建并启动新容器
|
||||||
|
echo "构建Docker镜像..."
|
||||||
|
docker compose build --no-cache
|
||||||
|
echo "启动服务..."
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# 验证服务状态
|
||||||
|
echo "验证容器状态..."
|
||||||
|
docker compose ps
|
||||||
|
echo "✅ 部署完成!"
|
||||||
@@ -6,4 +6,4 @@ services:
|
|||||||
# 日志目录映射
|
# 日志目录映射
|
||||||
- ./log:/log
|
- ./log:/log
|
||||||
ports:
|
ports:
|
||||||
- '10010:8080'
|
- '10095:8080'
|
||||||
@@ -28,8 +28,8 @@ public class CustomerController {
|
|||||||
description = "验证顾客身份并创建入店记录,如果是新顾客则自动注册到系统中。"
|
description = "验证顾客身份并创建入店记录,如果是新顾客则自动注册到系统中。"
|
||||||
)
|
)
|
||||||
@GetMapping("/checkIn")
|
@GetMapping("/checkIn")
|
||||||
public ApiResponse<CustomerCheckInVO> customerCheckIn(@RequestParam String name, @RequestParam String email) {
|
public ApiResponse<CustomerCheckInVO> customerCheckIn(@RequestParam String vipId) {
|
||||||
return ApiResponse.success(customerService.customerCheckIn(name, email));
|
return ApiResponse.success(customerService.customerCheckIn(vipId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/getAllCustomer")
|
@PostMapping("/getAllCustomer")
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class TryOnEffectController {
|
|||||||
@GetMapping("/getHistoricals")
|
@GetMapping("/getHistoricals")
|
||||||
public ApiResponse<List<? extends BaseVO>> getHistoricals(
|
public ApiResponse<List<? extends BaseVO>> getHistoricals(
|
||||||
@Parameter(description = "服装ID", required = true)
|
@Parameter(description = "服装ID", required = true)
|
||||||
@RequestBody HistoricalDTO historicalDTO) {
|
@ModelAttribute HistoricalDTO historicalDTO) {
|
||||||
if (CommonConstants.OUTFIT.equals(historicalDTO.getType())){
|
if (CommonConstants.OUTFIT.equals(historicalDTO.getType())){
|
||||||
List<OutfitHisVO> outfitHisVOS = tryOnEffectService.getOutfitHistoricals(historicalDTO);
|
List<OutfitHisVO> outfitHisVOS = tryOnEffectService.getOutfitHistoricals(historicalDTO);
|
||||||
return ApiResponse.success(outfitHisVOS);
|
return ApiResponse.success(outfitHisVOS);
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import lombok.Data;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class HistoricalDTO {
|
public class HistoricalDTO {
|
||||||
|
|
||||||
|
@Schema(description = "顾客ID",example = "1")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
@Schema(description = "进店记录ID",example = "1")
|
@Schema(description = "进店记录ID",example = "1")
|
||||||
private Long visitRecordId;
|
private Long visitRecordId;
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ import java.time.LocalDateTime;
|
|||||||
@TableName("customers")
|
@TableName("customers")
|
||||||
public class Customer extends BaseEntity {
|
public class Customer extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vip ID
|
||||||
|
*/
|
||||||
|
@TableField("vip_id")
|
||||||
|
private String vipId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 顾客姓名
|
* 顾客姓名
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
*/
|
*/
|
||||||
public interface CustomerService extends IService<Customer> {
|
public interface CustomerService extends IService<Customer> {
|
||||||
|
|
||||||
CustomerCheckInVO customerCheckIn(String name, String email);
|
CustomerCheckInVO customerCheckIn(String vipId);
|
||||||
|
|
||||||
IPage<CustomerVO> getAllCustomer(BaseRequest request);
|
IPage<CustomerVO> getAllCustomer(BaseRequest request);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.aida.lanecarford.common.security.context.UserContext;
|
|||||||
import com.aida.lanecarford.dto.BaseRequest;
|
import com.aida.lanecarford.dto.BaseRequest;
|
||||||
import com.aida.lanecarford.entity.Customer;
|
import com.aida.lanecarford.entity.Customer;
|
||||||
import com.aida.lanecarford.entity.VisitRecord;
|
import com.aida.lanecarford.entity.VisitRecord;
|
||||||
|
import com.aida.lanecarford.exception.BusinessException;
|
||||||
import com.aida.lanecarford.mapper.CustomerMapper;
|
import com.aida.lanecarford.mapper.CustomerMapper;
|
||||||
import com.aida.lanecarford.service.CustomerService;
|
import com.aida.lanecarford.service.CustomerService;
|
||||||
import com.aida.lanecarford.service.VisitRecordService;
|
import com.aida.lanecarford.service.VisitRecordService;
|
||||||
@@ -14,6 +15,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import io.netty.util.internal.StringUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -30,10 +32,13 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||||||
private final VisitRecordService visitRecordService;
|
private final VisitRecordService visitRecordService;
|
||||||
|
|
||||||
// 选择顾客登录并添加入店记录
|
// 选择顾客登录并添加入店记录
|
||||||
public CustomerCheckInVO customerCheckIn(String name, String email) {
|
public CustomerCheckInVO customerCheckIn(String vipId) {
|
||||||
|
if (StringUtil.isNullOrEmpty(vipId)) {
|
||||||
|
throw new BusinessException("Please enter a VIP ID.");
|
||||||
|
}
|
||||||
// 1. 判断当前顾客信息在数据库中是否有存储
|
// 1. 判断当前顾客信息在数据库中是否有存储
|
||||||
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(Customer::getName, name).eq(Customer::getEmail, email);
|
queryWrapper.eq(Customer::getVipId, vipId);
|
||||||
|
|
||||||
Customer customer = getOne(queryWrapper);
|
Customer customer = getOne(queryWrapper);
|
||||||
|
|
||||||
@@ -45,8 +50,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||||||
// 如果找到了,则添加到数据库
|
// 如果找到了,则添加到数据库
|
||||||
// 3. 添加当前顾客到本系统数据库
|
// 3. 添加当前顾客到本系统数据库
|
||||||
customer = new Customer();
|
customer = new Customer();
|
||||||
customer.setName(name);
|
customer.setVipId(vipId);
|
||||||
customer.setEmail(email);
|
|
||||||
customer.setCreatedTime(LocalDateTime.now());
|
customer.setCreatedTime(LocalDateTime.now());
|
||||||
|
|
||||||
save(customer);
|
save(customer);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
|
|||||||
|
|
||||||
StylistPathEnum stylistPathEnum = StylistPathEnum.of(requestOutfitDTO.getStylist());
|
StylistPathEnum stylistPathEnum = StylistPathEnum.of(requestOutfitDTO.getStylist());
|
||||||
Map<String, Object> params = setRequestOutfitParams(requestOutfitDTO.getCustomerId(), requestOutfitDTO.getNum(),
|
Map<String, Object> params = setRequestOutfitParams(requestOutfitDTO.getCustomerId(), requestOutfitDTO.getNum(),
|
||||||
stylistPathEnum.getPath(), requestOutfitDTO.getGender(), requestOutfitDTO.getSessionId());
|
stylistPathEnum.getName(), requestOutfitDTO.getGender(), requestOutfitDTO.getSessionId());
|
||||||
|
|
||||||
OutfitRequest outfitRequest = new OutfitRequest();
|
OutfitRequest outfitRequest = new OutfitRequest();
|
||||||
outfitRequest.setCustomerId(requestOutfitDTO.getCustomerId());
|
outfitRequest.setCustomerId(requestOutfitDTO.getCustomerId());
|
||||||
@@ -102,8 +102,9 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
|
|||||||
params.put("stylist_path", stylistPath);
|
params.put("stylist_path", stylistPath);
|
||||||
params.put("callback_url", webhookDomain);
|
params.put("callback_url", webhookDomain);
|
||||||
params.put("gender", gender);
|
params.put("gender", gender);
|
||||||
params.put("max_len", 9);
|
// params.put("max_len", 5);
|
||||||
params.put("session_id", sessionId);
|
params.put("session_id", sessionId);
|
||||||
|
params.put("batch_sources", Collections.singleton("2025_q4"));
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*
|
*
|
||||||
* @author AI Assistant
|
* @author AI Assistant
|
||||||
* @since 2024-01-01
|
* @since 2024-01-01
|
||||||
/**
|
* /**
|
||||||
* 试穿效果服务实现类
|
* 试穿效果服务实现类
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@@ -85,7 +85,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
CustomerPhoto customerPhoto = customerPhotoService.getById(customerPhotoId);
|
CustomerPhoto customerPhoto = customerPhotoService.getById(customerPhotoId);
|
||||||
String customerPhotoUrl = customerPhoto.getPhotoUrl();
|
String customerPhotoUrl = customerPhoto.getPhotoUrl();
|
||||||
if (customerPhotoUrl != null && !customerPhotoUrl.trim().isEmpty()) {
|
if (customerPhotoUrl != null && !customerPhotoUrl.trim().isEmpty()) {
|
||||||
if (imageUrls.isEmpty()){
|
if (imageUrls.isEmpty()) {
|
||||||
throw BusinessException.parameterRequired("TryOn result");
|
throw BusinessException.parameterRequired("TryOn result");
|
||||||
}
|
}
|
||||||
//先放tryon图片后放脸
|
//先放tryon图片后放脸
|
||||||
@@ -116,24 +116,24 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
for (Map<String, String> map : maps) {
|
for (Map<String, String> map : maps) {
|
||||||
String category = map.get("category");
|
String category = map.get("category");
|
||||||
sb.append("a ");
|
sb.append("a ");
|
||||||
sb.append( category);
|
sb.append(category);
|
||||||
sb.append(",");
|
sb.append(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt = "A full-body, photorealistic professional studio shot of a **young " + outfitRequest.getGender() + "**, mid-20s, with **clear facial features and a confident expression**. The model is centered in the frame.They are **standing in a direct, static, full-view pose** on a **clean, pure white background** **The entire figure, from head to toe, should be in frame and occupy approximately 80% of the vertical space.**.\n" +
|
prompt = "A full-body, photorealistic professional studio shot of a **young " + outfitRequest.getGender() + "**, mid-20s, with **clear facial features and a confident expression**. The model is centered in the frame.They are **standing in a direct, static, full-view pose** on a **clean, pure white background** **The entire figure, from head to toe, should be in frame and occupy approximately 80% of the vertical space.**.\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"**CRITICAL COMPOSITION INSTRUCTION:**\n" +
|
"**CRITICAL COMPOSITION INSTRUCTION:**\n" +
|
||||||
"Generate a single, seamless image of the model with a complete and fully visible head,**wearing ALL distinct items("+sb.toString()+")** from the uploaded image. **ALL items MUST be visible and correctly worn in the final outfit.**" +
|
"Generate a single, seamless image of the model with a complete and fully visible head,**wearing ALL distinct items(" + sb.toString() + ")** from the uploaded image. **ALL items MUST be visible and correctly worn in the final outfit.**" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"**Placement Detail:** Outerwear must be worn on the outside, and if a bag is present, it must be visible.\n" +
|
"**Placement Detail:** Outerwear must be worn on the outside, and if a bag is present, it must be visible.\n" +
|
||||||
"**Quality:** Ultra-high resolution, The figure should fill the frame as much as possible,studio photography quality. Emphasize **realistic fabric textures and sharp print fidelity**.\n" +
|
"**Quality:** Ultra-high resolution, The figure should fill the frame as much as possible,studio photography quality. Emphasize **realistic fabric textures and sharp print fidelity**.\n" +
|
||||||
"**Negative Constraints (Exclude):** **NO text, NO borders, NO tables, NO multiple models, NO extra items.** **CRITICAL: NO cropping of the head or face.**";
|
"**Negative Constraints (Exclude):** **NO text, NO borders, NO tables, NO multiple models, NO extra items.** **CRITICAL: NO cropping of the head or face.**";
|
||||||
aiRreultlogicalUrl = AITryOnEffect(prompt, imageUrls);
|
aiRreultlogicalUrl = AITryOnEffect(prompt, imageUrls);
|
||||||
|
|
||||||
}else if (tryOnEffectDto.getIsRegenerated() == 1 && imageUrls.size() == 1){
|
} else if (tryOnEffectDto.getIsRegenerated() == 1 && imageUrls.size() == 1) {
|
||||||
//根据提示词修改图像
|
//根据提示词修改图像
|
||||||
aiRreultlogicalUrl = AITryOnEffect(prompt, imageUrls);
|
aiRreultlogicalUrl = AITryOnEffect(prompt, imageUrls);
|
||||||
}else if (tryOnEffectDto.getIsRegenerated() == 1 && imageUrls.size() > 1){
|
} else if (tryOnEffectDto.getIsRegenerated() == 1 && imageUrls.size() > 1) {
|
||||||
//换脸
|
//换脸
|
||||||
aiRreultlogicalUrl = callFaceSwapAPI(imageUrls);
|
aiRreultlogicalUrl = callFaceSwapAPI(imageUrls);
|
||||||
}
|
}
|
||||||
@@ -186,6 +186,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加意见建议
|
* 添加意见建议
|
||||||
|
*
|
||||||
* @param suggestion 意见建议实体
|
* @param suggestion 意见建议实体
|
||||||
* @return 是否添加成功
|
* @return 是否添加成功
|
||||||
*/
|
*/
|
||||||
@@ -194,7 +195,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
try {
|
try {
|
||||||
// 保存意见建议
|
// 保存意见建议
|
||||||
int result = suggestionMapper.insert(suggestion);
|
int result = suggestionMapper.insert(suggestion);
|
||||||
|
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
log.info("意见建议添加成功 - id: {}", suggestion.getId());
|
log.info("意见建议添加成功 - id: {}", suggestion.getId());
|
||||||
return true;
|
return true;
|
||||||
@@ -236,7 +237,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
// 支持jpg和png格式的图片识别
|
// 支持jpg和png格式的图片识别
|
||||||
int jpgEndIndex = tryonUrl.indexOf(".jpg");
|
int jpgEndIndex = tryonUrl.indexOf(".jpg");
|
||||||
int pngEndIndex = tryonUrl.indexOf(".png");
|
int pngEndIndex = tryonUrl.indexOf(".png");
|
||||||
|
|
||||||
int endIndex = -1;
|
int endIndex = -1;
|
||||||
|
|
||||||
if (jpgEndIndex != -1 && (pngEndIndex == -1 || jpgEndIndex < pngEndIndex)) {
|
if (jpgEndIndex != -1 && (pngEndIndex == -1 || jpgEndIndex < pngEndIndex)) {
|
||||||
@@ -246,7 +247,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
// 找到png格式
|
// 找到png格式
|
||||||
endIndex = pngEndIndex + ".png".length();
|
endIndex = pngEndIndex + ".png".length();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endIndex != -1) {
|
if (endIndex != -1) {
|
||||||
String resultString = tryonUrl.substring(startIndex, endIndex);
|
String resultString = tryonUrl.substring(startIndex, endIndex);
|
||||||
aiRreultlogicalUrl = AITryOnEffect(prompt, Arrays.asList(resultString));
|
aiRreultlogicalUrl = AITryOnEffect(prompt, Arrays.asList(resultString));
|
||||||
@@ -259,53 +260,57 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO) {
|
public List<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO) {
|
||||||
LambdaQueryWrapper<TryOnEffect> tryOnEffectLambdaQueryWrapper = new LambdaQueryWrapper<TryOnEffect>()
|
LambdaQueryWrapper<TryOnEffect> tryOnEffectLambdaQueryWrapper = new LambdaQueryWrapper<TryOnEffect>()
|
||||||
.orderByDesc(TryOnEffect::getCreatedTime);
|
.eq(TryOnEffect::getCustomerId, historicalDTO.getCustomerId())
|
||||||
if (historicalDTO.getVisitRecordId() != null){
|
.orderByDesc(TryOnEffect::getCreatedTime);
|
||||||
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getVisitRecordId, historicalDTO.getVisitRecordId());
|
if (historicalDTO.getVisitRecordId() != null) {
|
||||||
}
|
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getVisitRecordId, historicalDTO.getVisitRecordId());
|
||||||
if (historicalDTO.getIsLibrary() != null||historicalDTO.getIsLibrary()){
|
}
|
||||||
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsFavorite,1);
|
if (historicalDTO.getIsLibrary() != null && historicalDTO.getIsLibrary()) {
|
||||||
}
|
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsFavorite, 1);
|
||||||
if (CommonConstants.TRYON.equals(historicalDTO.getType())){
|
}
|
||||||
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 0);
|
if (CommonConstants.TRYON.equals(historicalDTO.getType())) {
|
||||||
}else if (CommonConstants.GENAI.equals(historicalDTO.getType())){
|
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 0);
|
||||||
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 1);
|
} else if (CommonConstants.GENAI.equals(historicalDTO.getType())) {
|
||||||
}
|
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 1);
|
||||||
List<TryOnEffect> tryOnEffects = this.list(tryOnEffectLambdaQueryWrapper);
|
}
|
||||||
List<TryOnResultVO> tryOnResultVos = new ArrayList<>();
|
List<TryOnEffect> tryOnEffects = this.list(tryOnEffectLambdaQueryWrapper);
|
||||||
for (TryOnEffect tryOnEffect : tryOnEffects) {
|
List<TryOnResultVO> tryOnResultVos = new ArrayList<>();
|
||||||
TryOnResultVO tryOnResultVo = new TryOnResultVO();
|
for (TryOnEffect tryOnEffect : tryOnEffects) {
|
||||||
tryOnResultVo.setId(tryOnEffect.getId());
|
TryOnResultVO tryOnResultVo = new TryOnResultVO();
|
||||||
tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl(
|
tryOnResultVo.setId(tryOnEffect.getId());
|
||||||
tryOnEffect.getResultImageUrl(),
|
tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl(
|
||||||
|
tryOnEffect.getResultImageUrl(),
|
||||||
|
CommonConstants.MINIO_PATH_TIMEOUT
|
||||||
|
));
|
||||||
|
// 如果是原始效果,则获取对应的style图片
|
||||||
|
if (tryOnEffect.getIsRegenerated() == 0) {
|
||||||
|
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
styleLambdaQueryWrapper.eq(Style::getId, tryOnEffect.getStyleId()).select(Style::getStyleImageUrl);
|
||||||
|
Style style = styleService.getOne(styleLambdaQueryWrapper);
|
||||||
|
tryOnResultVo.setStyleUrl(minioUtil.convertToPresignedUrl(
|
||||||
|
style.getStyleImageUrl(),
|
||||||
CommonConstants.MINIO_PATH_TIMEOUT
|
CommonConstants.MINIO_PATH_TIMEOUT
|
||||||
));
|
));
|
||||||
// 如果是原始效果,则获取对应的style图片
|
|
||||||
if (tryOnEffect.getIsRegenerated() == 0) {
|
|
||||||
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
styleLambdaQueryWrapper.eq(Style::getId, tryOnEffect.getStyleId()).select(Style::getStyleImageUrl);
|
|
||||||
Style style = styleService.getOne(styleLambdaQueryWrapper);
|
|
||||||
tryOnResultVo.setStyleUrl(minioUtil.convertToPresignedUrl(
|
|
||||||
style.getStyleImageUrl(),
|
|
||||||
CommonConstants.MINIO_PATH_TIMEOUT
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
tryOnResultVo.setIsRegenerated(tryOnEffect.getIsRegenerated());
|
|
||||||
tryOnResultVo.setIsFavorite(tryOnEffect.getIsFavorite());
|
|
||||||
tryOnResultVos.add(tryOnResultVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tryOnResultVo.setIsRegenerated(tryOnEffect.getIsRegenerated());
|
||||||
|
tryOnResultVo.setIsFavorite(tryOnEffect.getIsFavorite());
|
||||||
|
tryOnResultVos.add(tryOnResultVo);
|
||||||
|
}
|
||||||
return tryOnResultVos;
|
return tryOnResultVos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO) {
|
public List<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO) {
|
||||||
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<Style>().orderByDesc(Style::getCreatedTime);
|
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<Style>()
|
||||||
if (historicalDTO.getVisitRecordId() != null){
|
.eq(Style::getCustomerId, historicalDTO.getCustomerId())
|
||||||
|
.eq(Style::getGenerationStatus, 1)
|
||||||
|
.orderByDesc(Style::getCreatedTime);
|
||||||
|
if (historicalDTO.getVisitRecordId() != null) {
|
||||||
styleLambdaQueryWrapper.eq(Style::getVisitRecordId, historicalDTO.getVisitRecordId());
|
styleLambdaQueryWrapper.eq(Style::getVisitRecordId, historicalDTO.getVisitRecordId());
|
||||||
}
|
}
|
||||||
if (historicalDTO.getIsLibrary() != null||historicalDTO.getIsLibrary()){
|
if (historicalDTO.getIsLibrary() != null && historicalDTO.getIsLibrary()) {
|
||||||
styleLambdaQueryWrapper.eq(Style::getIsFavorite, 1);
|
styleLambdaQueryWrapper.eq(Style::getIsFavorite, 1);
|
||||||
}
|
}
|
||||||
List<Style> styles = styleService.list(styleLambdaQueryWrapper);
|
List<Style> styles = styleService.list(styleLambdaQueryWrapper);
|
||||||
@@ -637,7 +642,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
String finishReason = candidate.getString("finishReason");
|
String finishReason = candidate.getString("finishReason");
|
||||||
if (!"STOP".equals(finishReason)) {
|
if (!"STOP".equals(finishReason)) {
|
||||||
String finishMessage = candidate.getString("finishMessage");
|
String finishMessage = candidate.getString("finishMessage");
|
||||||
if (finishReason != null && finishReason.equals("IMAGE_SAFETY")){
|
if (finishReason != null && finishReason.equals("IMAGE_SAFETY")) {
|
||||||
if (finishMessage != null && finishMessage.contains("Try rephrasing the prompt")) {
|
if (finishMessage != null && finishMessage.contains("Try rephrasing the prompt")) {
|
||||||
finishMessage = "Try rephrasing the prompt.If you think this was an error, send feedback.";
|
finishMessage = "Try rephrasing the prompt.If you think this was an error, send feedback.";
|
||||||
throw new BusinessException(finishMessage, "请尝试重新表述提示词。若您认为这是误判,可提交反馈。", ResultEnum.ERROR.getCode());
|
throw new BusinessException(finishMessage, "请尝试重新表述提示词。若您认为这是误判,可提交反馈。", ResultEnum.ERROR.getCode());
|
||||||
@@ -684,21 +689,22 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用换脸API
|
* 调用换脸API
|
||||||
|
*
|
||||||
* @param imageUrls 图片URL列表,第一个为源图片,第二个为目标图片
|
* @param imageUrls 图片URL列表,第一个为源图片,第二个为目标图片
|
||||||
* @return 换脸后的图片URL
|
* @return 换脸后的图片URL
|
||||||
*/
|
*/
|
||||||
private String callFaceSwapAPI(List<String> imageUrls) {
|
private String callFaceSwapAPI(List<String> imageUrls) {
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.info("开始调用换脸API - 源图片: {}, 目标图片: {}", imageUrls.get(0), imageUrls.get(1));
|
log.info("开始调用换脸API - 源图片: {}, 目标图片: {}", imageUrls.get(0), imageUrls.get(1));
|
||||||
|
|
||||||
|
|
||||||
String inputFaceUrl = imageUrls.get(1);
|
String inputFaceUrl = imageUrls.get(1);
|
||||||
|
|
||||||
// 构建输入图片列表(从第二张图片开始作为目标图片列表)
|
// 构建输入图片列表(从第二张图片开始作为目标图片列表)
|
||||||
JSONArray inputImageList = new JSONArray();
|
JSONArray inputImageList = new JSONArray();
|
||||||
inputImageList.add(imageUrls.get(0));
|
inputImageList.add(imageUrls.get(0));
|
||||||
|
|
||||||
// 构建请求体
|
// 构建请求体
|
||||||
JSONObject requestBody = new JSONObject();
|
JSONObject requestBody = new JSONObject();
|
||||||
@@ -789,19 +795,18 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
log.info("开始处理换脸API响应: {}", response);
|
log.info("开始处理换脸API响应: {}", response);
|
||||||
|
|
||||||
com.alibaba.fastjson.JSONObject jsonResponse = com.alibaba.fastjson.JSON.parseObject(response);
|
com.alibaba.fastjson.JSONObject jsonResponse = com.alibaba.fastjson.JSON.parseObject(response);
|
||||||
|
|
||||||
// 处理新的响应格式: {"output":["lanecarford/refaced_image/refaced1761809361.530157.png"]}
|
// 处理新的响应格式: {"output":["lanecarford/refaced_image/refaced1761809361.530157.png"]}
|
||||||
if (jsonResponse.containsKey("output")) {
|
if (jsonResponse.containsKey("output")) {
|
||||||
Object outputObj = jsonResponse.get("output");
|
Object outputObj = jsonResponse.get("output");
|
||||||
|
|
||||||
if (outputObj instanceof JSONArray) {
|
if (outputObj instanceof JSONArray) {
|
||||||
JSONArray outputArray = (JSONArray) outputObj;
|
JSONArray outputArray = (JSONArray) outputObj;
|
||||||
if (outputArray.size() > 0) {
|
if (outputArray.size() > 0) {
|
||||||
String imagePath = outputArray.getString(0);
|
String imagePath = outputArray.getString(0);
|
||||||
log.info("换脸成功,图片路径: {}", imagePath);
|
log.info("换脸成功,图片路径: {}", imagePath);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 下载图片并上传到MinIO
|
// 下载图片并上传到MinIO
|
||||||
return imagePath;
|
return imagePath;
|
||||||
} else {
|
} else {
|
||||||
@@ -812,7 +817,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
log.error("output字段不是数组格式: {}", outputObj);
|
log.error("output字段不是数组格式: {}", outputObj);
|
||||||
throw new BusinessException("Invalid output format", "output字段格式不正确", ResultEnum.ERROR.getCode());
|
throw new BusinessException("Invalid output format", "output字段格式不正确", ResultEnum.ERROR.getCode());
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
log.error("换脸API响应失败: {}", response);
|
log.error("换脸API响应失败: {}", response);
|
||||||
throw new BusinessException("reface error", "换脸失败", ResultEnum.ERROR.getCode());
|
throw new BusinessException("reface error", "换脸失败", ResultEnum.ERROR.getCode());
|
||||||
}
|
}
|
||||||
@@ -842,7 +847,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
throw new IOException("Failed to download image: HTTP " + response.code());
|
throw new IOException("Failed to download image: HTTP " + response.code());
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.body().bytes();
|
return response.body().bytes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ CREATE TABLE `styles` (
|
|||||||
`style_image_url` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '风格图片URL',
|
`style_image_url` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '风格图片URL',
|
||||||
`python_request_id` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Python请求ID',
|
`python_request_id` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Python请求ID',
|
||||||
`generation_status` tinyint DEFAULT '0' COMMENT '生成状态(0-处理中,1-已完成,2-失败)',
|
`generation_status` tinyint DEFAULT '0' COMMENT '生成状态(0-处理中,1-已完成,2-失败)',
|
||||||
`is_favorite` tinyint DEFAULT '0' COMMENT '是否喜欢(0-否,1-是)',
|
`is_favorite` tinyint NOT NULL DEFAULT '0' COMMENT '是否喜欢(0-否,1-是)',
|
||||||
`items` json DEFAULT NULL COMMENT '单品唯一标识',
|
`items` json DEFAULT NULL COMMENT '单品唯一标识',
|
||||||
`error_message` text COLLATE utf8mb4_unicode_ci COMMENT '错误信息',
|
`error_message` text COLLATE utf8mb4_unicode_ci COMMENT '错误信息',
|
||||||
`created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
|||||||
Reference in New Issue
Block a user