44 Commits

Author SHA1 Message Date
litianxiang
5f2825af80 Merge remote-tracking branch 'origin/prod/release_1.0' into dev/dev-ltx
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2026-02-05 10:16:30 +08:00
litianxiang
01d1e69e17 提示词修改 2026-02-05 10:15:46 +08:00
8bc8bc08da TASK:修改设计师名称
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2026-01-13 14:49:45 +08:00
413e4cb7fb TASK:新增设计师类型
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2026-01-13 14:12:49 +08:00
c376acfb2c TASK:新增状态continue
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2026-01-07 13:25:29 +08:00
d7d0fc53fd TASK:新增状态ALMOST_DONE
Some checks failed
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
定时 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Failing after 7m14s
2025-12-31 09:59:41 +08:00
litianxiang
655f434cf0 文件上传校验;部分演示代码废弃 2025-12-30 13:47:19 +08:00
fd61c6b588 TASK:从历史再次生成outfit,添加checkInId
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-30 11:33:53 +08:00
595c1eeaa8 BUGFIX: 添加retry_failed状态,不处理failed状态
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-30 10:56:22 +08:00
f74685c4d1 BUGFIX: 创建超过3分钟的搭配请求设置为失败
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-29 16:19:42 +08:00
litianxiang
318309c770 Merge remote-tracking branch 'origin/dev/dev-ltx' into prod/release_1.0
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-24 11:50:59 +08:00
litianxiang
4f149263a5 修改用户信息 2025-12-24 11:49:39 +08:00
fecf9bcb61 更新 docker-compose.yml
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-24 10:46:35 +08:00
litianxiang
190a57c855 Merge branch 'dev/dev' into prod/release_1.0
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-23 14:58:19 +08:00
litianxiang
fd6be37bc5 获取历史数据加入分页 2025-12-23 14:57:36 +08:00
278510aa21 Merge branch 'dev/dev-xp' into prod/release_1.0
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-23 14:31:19 +08:00
91eb21aa84 BUGFIX:token过期都返回401 2025-12-23 14:30:24 +08:00
f7f221ae62 Merge remote-tracking branch 'origin/prod/release_1.0' into prod/release_1.0
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
# Conflicts:
#	src/main/java/com/aida/lanecarford/controller/StyleController.java
#	src/main/java/com/aida/lanecarford/service/StyleService.java
#	src/main/java/com/aida/lanecarford/service/impl/StyleServiceImpl.java
2025-12-23 11:46:19 +08:00
2972ab1dca TASK:1.request outfit and retrieve history session regenerate 2.customer check-in 2025-12-23 11:38:48 +08:00
litianxiang
76cd268d0e debug:换脸请求参数log
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-23 10:08:10 +08:00
litianxiang
e25f8e0844 fix:适配新的生成,没有styleid的情况
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-22 17:35:34 +08:00
litianxiang
f4bb4b27a2 fix:获取历史记录加入判断条件,只查询成功生成的
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-22 15:37:16 +08:00
litianxiang
10d39ac0c4 Revert "fix:获取历史记录加入判断条件,只查询成功生成的"
This reverts commit 6687d0b5ff.
2025-12-22 15:35:50 +08:00
litianxiang
6687d0b5ff fix:获取历史记录加入判断条件,只查询成功生成的 2025-12-22 15:35:23 +08:00
litianxiang
8eb42c9364 fix:获取历史记录加入顾客id
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-22 15:17:12 +08:00
litianxiang
658149639f Merge remote-tracking branch 'origin/dev/dev' into prod/release_1.0
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-22 14:31:36 +08:00
litianxiang
3df8767c47 Merge remote-tracking branch 'origin/dev/dev-ltx' into dev/dev 2025-12-22 14:30:44 +08:00
litianxiang
3352bc82d9 style表新增喜欢字段 2025-12-22 14:29:06 +08:00
litianxiang
23cb45062f 修改查询历史生成记录的接口,新增outfit点赞接口 2025-12-22 14:28:27 +08:00
5e6e9a8787 Merge branch 'dev/dev-xp' into prod/release_1.0
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-17 15:30:21 +08:00
5005d8ac2a stylist 传参变更 2025-12-17 15:26:41 +08:00
0eb5128b6f Merge remote-tracking branch 'origin/prod/release_1.0' into prod/release_1.0
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-17 11:34:43 +08:00
acf4c6a307 Merge branch 'dev/dev-xp' into prod/release_1.0 2025-12-17 11:34:25 +08:00
3561cd098a Merge branch 'dev/dev-xp' into dev/dev 2025-12-17 11:33:00 +08:00
a2ed179fbb 添加参数batch_sources 2025-12-17 11:32:37 +08:00
faa655bc9d 上传文件至「.gitea/workflows」
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-11-28 16:40:51 +08:00
b0bf6dc338 更新 docker-compose.yml
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-11-28 16:26:17 +08:00
316702a8cf 上传文件至「.gitea/workflows」
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-11-28 16:14:59 +08:00
8482a88870 更新 .gitea/workflows/prod_build_commit.yaml
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-11-28 16:11:34 +08:00
eda8e74b1a 添加 .gitea/workflows/prod_build_commit.yaml
All checks were successful
git commit 控制 AiDA back-java Develop 分支构建部署 / build_and_deploy (push) Has been skipped
2025-11-28 16:10:17 +08:00
8557335cd2 顾客checkIn修改为只提供vipId,添加判空 2025-11-20 14:28:50 +08:00
a16cb37c7f 顾客checkIn修改为只提供vipId 2025-11-20 14:18:27 +08:00
dbf6c45ec8 Merge branch 'dev/dev-xp' into dev/dev 2025-11-19 15:32:50 +08:00
d38a439e3c max_len 9->5 2025-11-19 15:32:06 +08:00
37 changed files with 1282 additions and 162 deletions

View 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 "✅ 部署完成!"

View 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 "✅ 部署完成!"

View 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 "✅ 部署完成!"

View File

@@ -4,6 +4,9 @@ services:
build: .
volumes:
# 日志目录映射
- ./log:/log
- ./log:/app/log
ports:
- '10010:8080'
- '10095:8080'
networks:
back_default:
driver: bridge

View File

@@ -10,5 +10,9 @@ public class CommonConstants {
public static final int CONN_TIMEOUT = 30000; // milliseconds
public static final String OUTFIT = "Outfit";
public static final String TRYON = "Try-on";
public static final String GENAI = "Gen-AI";
}

View File

@@ -21,7 +21,13 @@ public enum StatusEnum {
FAILED(2),
@Schema(description = "运行中")
RUNNING(3);
RUNNING(3),
@Schema(description = "重试中")
RETRYING(4),
@Schema(description = "生成即将结束")
ALMOST_DONE(5);
private int code;

View File

@@ -11,7 +11,11 @@ public enum StylistPathEnum {
STYLIST_ONE("crystal", "lanecarford/stylist_guide/latest/crystal_en.md"),
STYLIST_TWO("mini", "lanecarford/stylist_guide/latest/mini_en.md");
STYLIST_TWO("mini", "lanecarford/stylist_guide/latest/mini_en.md"),
STYLIST_THREE("vera", "lanecarford/stylist_guide/latest/mini_en.md"),
STYLIST_FOUR("edi", "lanecarford/stylist_guide/latest/mini_en.md");
private String name;

View File

@@ -2,7 +2,6 @@ package com.aida.lanecarford.common.security;
import com.aida.lanecarford.common.security.config.JwtProperties;
import com.aida.lanecarford.common.security.context.UserContext;
import com.aida.lanecarford.exception.BusinessException;
import com.aida.lanecarford.util.CacheUtil;
import com.aida.lanecarford.vo.AuthPrincipalVO;
import com.alibaba.fastjson.JSONObject;
@@ -25,7 +24,7 @@ public class JwtInterceptor implements HandlerInterceptor {
private final JwtProperties jwtProperties;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
return true;
}
@@ -41,7 +40,8 @@ public class JwtInterceptor implements HandlerInterceptor {
String extracted = jwtUtil.extractUserinfo(jwtToken);
if (StringUtil.isNullOrEmpty(extracted)) {
log.warn("TOKEN已过期请重新登录(token without userInfo)");
throw new BusinessException("Token has expired, please log in again.");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
// throw new BusinessException("Token has expired, please log in again.");
}
AuthPrincipalVO authPrincipalVO = JSONObject.parseObject(extracted, AuthPrincipalVO.class);
@@ -54,10 +54,12 @@ public class JwtInterceptor implements HandlerInterceptor {
if (Objects.isNull(token)) {
log.warn("TOKEN已过期请重新登录(local cache empty)");
throw new BusinessException("Token has expired, please log in again.");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
// throw new BusinessException("Token has expired, please log in again.");
} else if (!token.toString().equals(jwtToken)) {
log.warn("TOKEN已过期请重新登录(token not match local cache)");
throw new BusinessException("Token has expired, please log in again.");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
// throw new BusinessException("Token has expired, please log in again.");
}
return true;
}

View File

@@ -2,6 +2,7 @@ package com.aida.lanecarford.controller;
import com.aida.lanecarford.common.ApiResponse;
import com.aida.lanecarford.dto.BaseRequest;
import com.aida.lanecarford.entity.Customer;
import com.aida.lanecarford.service.CustomerService;
import com.aida.lanecarford.vo.CustomerCheckInVO;
import com.aida.lanecarford.vo.CustomerVO;
@@ -25,11 +26,11 @@ public class CustomerController {
@Operation(
summary = "顾客入店登记",
description = "验证顾客身份并创建入店记录,如果是新顾客则自动注册到系统中。"
description = "验证顾客身份并创建入店记录"
)
@GetMapping("/checkIn")
public ApiResponse<CustomerCheckInVO> customerCheckIn(@RequestParam String name, @RequestParam String email) {
return ApiResponse.success(customerService.customerCheckIn(name, email));
public ApiResponse<CustomerCheckInVO> customerCheckIn(@RequestParam String nickname) {
return ApiResponse.success(customerService.customerCheckIn(nickname));
}
@PostMapping("/getAllCustomer")
@@ -37,4 +38,15 @@ public class CustomerController {
return ApiResponse.success(customerService.getAllCustomer(request));
}
@Operation(
summary = "新增顾客",
description = "根据用户提供的vipId和昵称与当前sales绑定创建账号"
)
@GetMapping("/createCustomer")
public ApiResponse<Customer> createCustomer(@RequestParam String vipId, @RequestParam String nickname) {
return ApiResponse.success(customerService.createCustomer(vipId, nickname));
}
}

View File

@@ -4,6 +4,7 @@ import com.aida.lanecarford.common.ApiResponse;
import com.aida.lanecarford.dto.CustomerPhotoDto;
import com.aida.lanecarford.entity.CustomerPhoto;
import com.aida.lanecarford.service.CustomerPhotoService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
@@ -24,7 +25,7 @@ public class CustomerPhotoController {
private final CustomerPhotoService customerPhotoService;
@PostMapping("/upload")
public ApiResponse<CustomerPhoto> upload(@ModelAttribute CustomerPhotoDto customerPhotoDto) {
public ApiResponse<CustomerPhoto> upload(@Valid @ModelAttribute CustomerPhotoDto customerPhotoDto) {
CustomerPhoto customerPhoto = customerPhotoService.upload(customerPhotoDto);
return ApiResponse.success(customerPhoto);
}

View File

@@ -121,4 +121,12 @@ public class LoginController {
return ApiResponse.success(loginService.parseGoogleAccessToken(accessToken));
}
//修改用户信息
@Operation(summary = "修改用户信息",
description = "传usernameemailpassword三个值password要加密")
@PostMapping("/updateUserInfo")
public ApiResponse<String> updateUserInfo(@RequestBody User user) {
return ApiResponse.success(loginService.updateUserInfo(user));
}
}

View File

@@ -78,4 +78,41 @@ public class StyleController {
return ApiResponse.success(styleService.getOutfitResult(requestIDs));
}
/**
* 设置喜欢的风格
*/
@Operation(summary = "设置喜欢的outfit", description = "将指定风格设置为收藏")
@PostMapping("/set-favorite/{styleId}")
public ApiResponse<Void> setFavoriteStyle(
@Parameter(description = "风格ID", required = true)
@PathVariable Long styleId) {
styleService.setFavoriteStyle(styleId);
return ApiResponse.success();
}
/**
* 取消喜欢的风格
*/
@Operation(summary = "取消喜欢的outfit", description = "取消指定风格的收藏")
@PostMapping("/cancel-favorite/{styleId}")
public ApiResponse<Void> cancelFavoriteStyle(
@Parameter(description = "风格ID", required = true)
@PathVariable Long styleId) {
styleService.cancelFavoriteStyle(styleId);
return ApiResponse.success();
}
@Operation(
summary = "回溯历史对话,重新生成搭配图",
description = "根据当前的穿搭结果,回溯历史穿搭请求数据及历史对话,重新生成搭配"
)
@GetMapping("/retrieveAndRegenerate")
public ApiResponse<List<String>> retrieveAndRegenerate(
@Parameter(description = "tryOn后的图片id", required = true, example = "1369")
@RequestParam Long tryOnEffectsId,
@Parameter(description = "用户进店记录", required = true, example = "3")
@RequestParam Long checkInId ) {
return ApiResponse.success(styleService.retrieveAndRegenerate(tryOnEffectsId, checkInId));
}
}

View File

@@ -1,10 +1,15 @@
package com.aida.lanecarford.controller;
import com.aida.lanecarford.common.ApiResponse;
import com.aida.lanecarford.common.PageResult;
import com.aida.lanecarford.common.constant.CommonConstants;
import com.aida.lanecarford.dto.HistoricalDTO;
import com.aida.lanecarford.entity.Suggestion;
import com.aida.lanecarford.entity.TryOnEffect;
import com.aida.lanecarford.service.TryOnEffectService;
import com.aida.lanecarford.vo.TryOnResultVo;
import com.aida.lanecarford.vo.BaseVO;
import com.aida.lanecarford.vo.OutfitHisVO;
import com.aida.lanecarford.vo.TryOnResultVO;
import io.netty.util.internal.StringUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -32,29 +37,25 @@ public class TryOnEffectController {
@Operation(summary = "生成试穿效果", description = "根据服装模特照片生成试穿效果其中styleId是必选当二次生成时要带上相关参数比如顾客照片")
@PostMapping("/generate")
public ApiResponse<TryOnResultVo> generateTryOnEffect(
public ApiResponse<TryOnResultVO> generateTryOnEffect(
@Parameter(description = "试穿效果请求参数", required = true)
@Valid @RequestBody TryOnEffect tryOnEffectDto) {
TryOnResultVo tryOnResultVo = tryOnEffectService.generateTryOnEffect(tryOnEffectDto);
TryOnResultVO tryOnResultVo = tryOnEffectService.generateTryOnEffect(tryOnEffectDto);
return ApiResponse.success(tryOnResultVo);
}
@Operation(summary = "获取收藏的试穿效果", description = "对应library页面点击details后的显示参数为进店记录id")
@GetMapping("/favorites/{visitRecordId}")
public ApiResponse<List<TryOnResultVo>> getFavoriteTryOnEffects(
@Parameter(description = "进店记录ID", required = true)
@PathVariable Long visitRecordId) {
List<TryOnResultVo> tryOnResultVos = tryOnEffectService.getFavoriteTryOnEffects(visitRecordId);
@Operation(summary = "获取历史生成记录", description = "根据type进店记录id是否收藏来决定返回的数据支持分页")
@GetMapping("/getHistoricals")
public ApiResponse<PageResult<? extends BaseVO>> getHistoricals(
@Parameter(description = "历史记录查询参数", required = true)
@ModelAttribute HistoricalDTO historicalDTO) {
if (CommonConstants.OUTFIT.equals(historicalDTO.getType())) {
PageResult<OutfitHisVO> outfitHisVOS = tryOnEffectService.getOutfitHistoricals(historicalDTO);
return ApiResponse.success(outfitHisVOS);
} else {
PageResult<TryOnResultVO> tryOnResultVos = tryOnEffectService.getTryOnHistoricals(historicalDTO);
return ApiResponse.success(tryOnResultVos);
}
@GetMapping("/style/{styleId}")
@Operation(summary = "获取某套服装的所有生成结果", description = "对应customize your look页面点击finish后的显示")
public ApiResponse<List<TryOnResultVo>> getTryOnEffectsByStyleId(
@Parameter(description = "服装ID", required = true)
@PathVariable Long styleId) {
List<TryOnResultVo> tryOnResultVos = tryOnEffectService.getTryOnEffectsByStyleId(styleId);
return ApiResponse.success(tryOnResultVos);
}
/**
@@ -91,28 +92,28 @@ public class TryOnEffectController {
return ApiResponse.success();
}
/**
* 首页默认图换脸演示
*/
@Operation(summary = "首页点击换脸", description = "传入上传顾客照片后得到的ID")
@PostMapping("/reFace")
public ApiResponse<String> reFace(@Nullable @RequestParam Long customerPhotoId,
@Nullable @RequestParam String prompt,
@Nullable @RequestParam String tryonUrl) {
if (customerPhotoId == null&& StringUtil.isNullOrEmpty(prompt)&& StringUtil.isNullOrEmpty(tryonUrl)){
return ApiResponse.error("system error:Parameter null");
}
String result = "";
if (StringUtil.isNullOrEmpty(prompt)){
//换脸
result = tryOnEffectService.reFace(customerPhotoId);
}else {
if (StringUtil.isNullOrEmpty(tryonUrl)){
return ApiResponse.error("system error:Parameter null");
}
//根据提示词修改图像
result = tryOnEffectService.generateUrl(prompt,tryonUrl);
}
return ApiResponse.success("操作成功",result);
}
// /**
// * 首页默认图换脸演示
// */
// @Operation(summary = "首页点击换脸", description = "传入上传顾客照片后得到的ID")
// @PostMapping("/reFace")
// public ApiResponse<String> reFace(@Nullable @RequestParam Long customerPhotoId,
// @Nullable @RequestParam String prompt,
// @Nullable @RequestParam String tryonUrl) {
// if (customerPhotoId == null&& StringUtil.isNullOrEmpty(prompt)&& StringUtil.isNullOrEmpty(tryonUrl)){
// return ApiResponse.error("system error:Parameter null");
// }
// String result = "";
// if (StringUtil.isNullOrEmpty(prompt)){
// //换脸
// result = tryOnEffectService.reFace(customerPhotoId);
// }else {
// if (StringUtil.isNullOrEmpty(tryonUrl)){
// return ApiResponse.error("system error:Parameter null");
// }
// //根据提示词修改图像
// result = tryOnEffectService.generateUrl(prompt,tryonUrl);
// }
// return ApiResponse.success("操作成功",result);
// }
}

View File

@@ -0,0 +1,27 @@
package com.aida.lanecarford.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class HistoricalDTO {
@Schema(description = "顾客ID", example = "1")
private Long customerId;
@Schema(description = "进店记录ID", example = "1")
private Long visitRecordId;
@Schema(description = "类型", example = "Outfit , Try-on , Gen-AI")
private String type;
@Schema(description = "是否是收藏", example = "true")
private Boolean isLibrary;
@Schema(description = "当前页码从1开始", example = "1")
private Integer pageNum;
@Schema(description = "每页大小", example = "10")
private Integer pageSize;
}

View File

@@ -10,10 +10,14 @@ public class OutfitCallbackDTO {
private String outfit_id;
// 取值范围ok || failed || stop
// 取值范围ok || failed || stop || retrying || retry_failed
private String status;
private String path;
private List<Map<String, String>> items;
private String request_summary;
private List<String> occasions;
}

View File

@@ -1,9 +1,12 @@
package com.aida.lanecarford.dto;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
@Data
@Schema(description = "AI穿搭推荐请求参数")
@@ -59,4 +62,10 @@ public class RequestOutfitDTO {
)
private String sessionId;
@Hidden
private String summary;
@Hidden
private List<String> occasion;
}

View File

@@ -20,6 +20,18 @@ import java.time.LocalDateTime;
@TableName("customers")
public class Customer extends BaseEntity {
/**
* 导购id,即user表的主键id
*/
@TableField("user_id")
private Long salesId;
/**
* vip ID
*/
@TableField("vip_id")
private String vipId;
/**
* 顾客姓名
*/

View File

@@ -31,4 +31,9 @@ public class OutfitRequest extends BaseEntity{
* 当前任务状态
*/
private int status;
/**
* 会话记录id
*/
private Long sessionRecordId;
}

View File

@@ -0,0 +1,51 @@
package com.aida.lanecarford.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@TableName("session_record")
public class SessionRecord extends BaseEntity{
private Long visitRecordId;
private String sessionId;
private String requestSummary;
private String occasions;
// 获取时转换为List
@JsonIgnore
public List<String> getOccasionsList() {
if (StringUtils.isBlank(this.occasions)) {
return new ArrayList<>();
}
// 使用特定分隔符,确保不会出现在内容中
return Arrays.asList(this.occasions.split("\\|\\|"));
}
// 设置时转换为String
public void setOccasionsList(List<String> occasionsList) {
if (occasionsList == null || occasionsList.isEmpty()) {
this.occasions = null;
} else {
this.occasions = String.join("||", occasionsList);
}
}
}

View File

@@ -1,6 +1,7 @@
package com.aida.lanecarford.entity;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -76,4 +77,11 @@ public class Style extends BaseEntity {
private String errorMessage;
// 注意createdTime、updatedTime 字段已在 BaseEntity 中定义
/**
* 是否喜欢(0-否,1-是)
*/
@Schema(description = "是否喜欢(0-否,1-是)", example = "1", required = false)
@TableField("is_favorite")
private Integer isFavorite;
}

View File

@@ -88,6 +88,12 @@ public class GlobalExceptionHandler {
logger.error("MinIO异常: {}", e.getMessage(), e);
// 如果是文件为空等参数错误,返回参数错误码
String message = e.getMessage();
if (message != null && (message.contains("文件不能为空") || message.contains("不能为空"))) {
return ApiResponse.error(ResultEnum.PARAMETER_ERROR.getCode(), "File cannot be empty");
}
return ApiResponse.error(ResultEnum.ERROR.getCode(), "File storage service error");
}

View File

@@ -0,0 +1,9 @@
package com.aida.lanecarford.mapper;
import com.aida.lanecarford.entity.SessionRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SessionRecordMapper extends BaseMapper<SessionRecord> {
}

View File

@@ -12,8 +12,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface CustomerService extends IService<Customer> {
CustomerCheckInVO customerCheckIn(String name, String email);
CustomerCheckInVO customerCheckIn(String vipId);
IPage<CustomerVO> getAllCustomer(BaseRequest request);
Customer createCustomer(String vipId, String nickname);
}

View File

@@ -36,4 +36,6 @@ public interface LoginService extends IService<User> {
LoginVO parseGoogleCredential(String credential) throws ParseException, JOSEException, IOException;
LoginVO parseGoogleAccessToken(String accessToken);
String updateUserInfo(User user);
}

View File

@@ -19,4 +19,18 @@ public interface StyleService extends IService<Style> {
List<OutfitResultVO> getOutfitResult(List<String> requestIDs);
/**
* 设置风格为收藏
* @param styleId 风格ID
*/
void setFavoriteStyle(Long styleId);
/**
* 取消风格的收藏
* @param styleId 风格ID
*/
void cancelFavoriteStyle(Long styleId);
List<String> retrieveAndRegenerate(Long tryOnEffectsId, Long checkInId);
}

View File

@@ -1,8 +1,11 @@
package com.aida.lanecarford.service;
import com.aida.lanecarford.common.PageResult;
import com.aida.lanecarford.dto.HistoricalDTO;
import com.aida.lanecarford.entity.Suggestion;
import com.aida.lanecarford.entity.TryOnEffect;
import com.aida.lanecarford.vo.TryOnResultVo;
import com.aida.lanecarford.vo.OutfitHisVO;
import com.aida.lanecarford.vo.TryOnResultVO;
import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.validation.Valid;
@@ -16,9 +19,9 @@ import java.util.List;
*/
public interface TryOnEffectService extends IService<TryOnEffect> {
TryOnResultVo generateTryOnEffect(@Valid TryOnEffect tryOnEffectDto);
TryOnResultVO generateTryOnEffect(@Valid TryOnEffect tryOnEffectDto);
List<TryOnResultVo> getFavoriteTryOnEffects(Long visitRecordId);
List<TryOnResultVO> getFavoriteTryOnEffects(Long visitRecordId);
/**
* 设置试穿效果为收藏
@@ -32,7 +35,7 @@ public interface TryOnEffectService extends IService<TryOnEffect> {
*/
void cancelFavoriteTryOnEffect(Long tryOnId);
List<TryOnResultVo> getTryOnEffectsByStyleId(Long styleId);
List<TryOnResultVO> getTryOnEffectsByStyleId(Long styleId);
/**
* 添加意见建议
@@ -41,7 +44,11 @@ public interface TryOnEffectService extends IService<TryOnEffect> {
*/
boolean addComment(Suggestion suggestion);
//已废弃
String reFace(Long customerPhotoId);
String generateUrl(String prompt, String tryonUrl);
PageResult<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO);
PageResult<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO);
}

View File

@@ -1,9 +1,11 @@
package com.aida.lanecarford.service.impl;
import com.aida.lanecarford.common.constant.MinioFileConstants;
import com.aida.lanecarford.common.response.ResultEnum;
import com.aida.lanecarford.config.MinioConfig;
import com.aida.lanecarford.dto.CustomerPhotoDto;
import com.aida.lanecarford.entity.CustomerPhoto;
import com.aida.lanecarford.exception.BusinessException;
import com.aida.lanecarford.mapper.CustomerPhotoMapper;
import com.aida.lanecarford.service.CustomerPhotoService;
import com.aida.lanecarford.util.CopyUtil;
@@ -11,6 +13,7 @@ import com.aida.lanecarford.util.MinioUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
/**
* 顾客照片服务实现类
@@ -26,9 +29,14 @@ public class CustomerPhotoServiceImpl extends ServiceImpl<CustomerPhotoMapper, C
@Override
public CustomerPhoto upload(CustomerPhotoDto customerPhotoDto) {
// 验证文件是否为空
MultipartFile file = customerPhotoDto.getFile();
if (file == null || file.isEmpty()) {
throw new BusinessException(ResultEnum.PARAMETER_ERROR, "File cannot be empty", "文件不能为空");
}
String logicalUrl = minioUtil.uploadFile(
customerPhotoDto.getFile(),
file,
MinioFileConstants.FileType.CUSTOMER_PHOTO,
minioConfig.getBucketName()
);

View File

@@ -1,9 +1,11 @@
package com.aida.lanecarford.service.impl;
import com.aida.lanecarford.common.response.ResultEnum;
import com.aida.lanecarford.common.security.context.UserContext;
import com.aida.lanecarford.dto.BaseRequest;
import com.aida.lanecarford.entity.Customer;
import com.aida.lanecarford.entity.VisitRecord;
import com.aida.lanecarford.exception.BusinessException;
import com.aida.lanecarford.mapper.CustomerMapper;
import com.aida.lanecarford.service.CustomerService;
import com.aida.lanecarford.service.VisitRecordService;
@@ -15,6 +17,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@@ -30,10 +33,16 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
private final VisitRecordService visitRecordService;
// 选择顾客登录并添加入店记录
public CustomerCheckInVO customerCheckIn(String name, String email) {
public CustomerCheckInVO customerCheckIn(String nickname) {
// sales ID即当前的用户id
Long salesId = UserContext.getUserHolder().getId();
if (StringUtils.isBlank(nickname)) {
throw new BusinessException("Please enter a nickname.", ResultEnum.PROMPT.getCode());
}
// 1. 判断当前顾客信息在数据库中是否有存储
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Customer::getName, name).eq(Customer::getEmail, email);
queryWrapper.eq(Customer::getName, nickname)
.eq(Customer::getSalesId, salesId);
Customer customer = getOne(queryWrapper);
@@ -41,27 +50,28 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
if (Objects.isNull(customer)) {
// todo 从连卡佛数据库查数据
// 先假设都找不到
// throw new BusinessException("This customer does not currently have a registered VIP account.");
throw new BusinessException("This customer does not currently have a registered VIP account.");
// 如果找到了,则添加到数据库
// 3. 添加当前顾客到本系统数据库
customer = new Customer();
customer.setName(name);
customer.setEmail(email);
customer.setCreatedTime(LocalDateTime.now());
save(customer);
// customer = new Customer();
// customer.setVipId(vipId);
// customer.setCreatedTime(LocalDateTime.now());
//
// save(customer);
}
// 4. 添加入店记录
VisitRecord visitRecord = visitRecordService.addRecord(customer.getId(), UserContext.getUserHolder().getId());
VisitRecord visitRecord = visitRecordService.addRecord(customer.getId(), salesId);
return new CustomerCheckInVO(customer.getId(), visitRecord.getId());
}
// 获取所有的顾客名单
public IPage<CustomerVO> getAllCustomer(BaseRequest request) {
Long salesId = UserContext.getUserHolder().getId();
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(Customer::getName, Customer::getEmail);
queryWrapper.eq(Customer::getSalesId, salesId);
queryWrapper.select(Customer::getName, Customer::getVipId);
Page<Customer> page = page(new Page<>(request.getCurrent(), request.getSize()), queryWrapper);
@@ -73,4 +83,36 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
});
}
public Customer createCustomer(String vipId, String nickname) {
Long salesId = UserContext.getUserHolder().getId();
// 1. 确认nickname是否有重复返回提示信息
boolean nicknameExists = lambdaQuery().eq(Customer::getName, nickname)
.eq(Customer::getSalesId, salesId).count() > 0;
if (nicknameExists) {
throw new BusinessException("'" + nickname + "' already exists. Please choose a different nickname.");
}
// 2. 确认输入的vipId是否已存在账号
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Customer::getVipId, vipId)
.eq(Customer::getSalesId, salesId);
Customer customer = getOne(queryWrapper);
// 3. 不存在则新建
if (Objects.isNull(customer)) {
customer = new Customer();
customer.setVipId(vipId);
customer.setName(nickname);
customer.setSalesId(salesId);
customer.setCreatedTime(LocalDateTime.now());
save(customer);
} else {
throw new BusinessException("VIP ID'" + vipId + "' already exists.Please proceed directly to check-in.");
}
return customer;
}
}

View File

@@ -353,6 +353,66 @@ public class LoginServiceImpl extends ServiceImpl<UserMapper, User> implements L
}
}
@Override
public String updateUserInfo(User user) {
// 1. 获取当前登录用户ID
AuthPrincipalVO userHolder = UserContext.getUserHolder();
if (Objects.isNull(userHolder)) {
throw new BusinessException("User not logged in", "用户未登录", ResultEnum.ERROR.getCode());
}
Long userId = userHolder.getId();
// 2. 验证用户是否存在
User existingUser = getById(userId);
if (Objects.isNull(existingUser)) {
throw new BusinessException("User not found", "用户不存在", ResultEnum.ERROR.getCode());
}
// 3. 构建更新条件,只更新有值的字段
UpdateWrapper<User> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda().eq(User::getId, userId);
boolean hasUpdate = false;
// 如果username有值则更新
if (!StringUtil.isNullOrEmpty(user.getUsername())) {
updateWrapper.lambda().set(User::getUsername, user.getUsername());
hasUpdate = true;
}
// 如果email有值则更新
if (!StringUtil.isNullOrEmpty(user.getEmail())) {
updateWrapper.lambda().set(User::getEmail, user.getEmail());
hasUpdate = true;
}
// 如果password有值则更新
if (!StringUtil.isNullOrEmpty(user.getPassword())) {
updateWrapper.lambda().set(User::getPassword, user.getPassword());
hasUpdate = true;
}
// 4. 如果没有需要更新的字段,返回提示信息
if (!hasUpdate) {
return "No fields to update";
}
// 5. 执行更新
boolean updated = update(updateWrapper);
if (updated) {
log.info("用户信息更新成功 userId={}, updatedFields=username:{}, email:{}, password:{}",
userId,
!StringUtil.isNullOrEmpty(user.getUsername()),
!StringUtil.isNullOrEmpty(user.getEmail()),
!StringUtil.isNullOrEmpty(user.getPassword()));
return "User information updated successfully";
} else {
throw new BusinessException("Failed to update user information", "更新用户信息失败", ResultEnum.ERROR.getCode());
}
}
private static final String TOKEN_URL = "https://oauth2.googleapis.com/token";
public GoogleUser getGoogleUserFromCode(String code) {

View File

@@ -4,13 +4,18 @@ import com.aida.lanecarford.common.constant.CommonConstants;
import com.aida.lanecarford.common.constant.RedisURIConstants;
import com.aida.lanecarford.common.enums.StatusEnum;
import com.aida.lanecarford.common.enums.StylistPathEnum;
import com.aida.lanecarford.common.response.ResultEnum;
import com.aida.lanecarford.dto.OutfitCallbackDTO;
import com.aida.lanecarford.dto.RequestOutfitDTO;
import com.aida.lanecarford.entity.OutfitRequest;
import com.aida.lanecarford.entity.SessionRecord;
import com.aida.lanecarford.entity.Style;
import com.aida.lanecarford.entity.TryOnEffect;
import com.aida.lanecarford.exception.BusinessException;
import com.aida.lanecarford.mapper.OutfitRequestMapper;
import com.aida.lanecarford.mapper.SessionRecordMapper;
import com.aida.lanecarford.mapper.StyleMapper;
import com.aida.lanecarford.mapper.TryOnEffectMapper;
import com.aida.lanecarford.service.StyleService;
import com.aida.lanecarford.util.CacheUtil;
import com.aida.lanecarford.util.MinioUtil;
@@ -20,12 +25,15 @@ import com.aida.lanecarford.vo.OutfitResultVO;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.*;
@@ -41,6 +49,8 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
private final CacheUtil cacheUtil;
private final MinioUtil minioUtil;
private final OutfitRequestMapper outfitRequestMapper;
private final SessionRecordMapper sessionRecordMapper;
private final TryOnEffectMapper tryOnEffectMapper;
@Value("${webhook.domain}")
private String webhookDomain;
@@ -51,14 +61,20 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
// 请求需要顾客id, 生成的数量,风格
StylistPathEnum stylistPathEnum = StylistPathEnum.of(requestOutfitDTO.getStylist());
Map<String, Object> params = setRequestOutfitParams(requestOutfitDTO.getCustomerId(), requestOutfitDTO.getNum(),
stylistPathEnum.getPath(), requestOutfitDTO.getGender(), requestOutfitDTO.getSessionId());
if (Objects.isNull(stylistPathEnum)) {
log.error("未知设计师: {}",requestOutfitDTO.getStylist() );
stylistPathEnum = StylistPathEnum.STYLIST_ONE;
}
Map<String, Object> params = setRequestOutfitParams(requestOutfitDTO, stylistPathEnum);
SessionRecord sessionRecord = saveOrUpdateSession(requestOutfitDTO.getSessionId(), requestOutfitDTO.getCheckInId(), null, null);
OutfitRequest outfitRequest = new OutfitRequest();
outfitRequest.setCustomerId(requestOutfitDTO.getCustomerId());
outfitRequest.setVisitRecordId(requestOutfitDTO.getCheckInId());
outfitRequest.setStylist(requestOutfitDTO.getStylist());
outfitRequest.setGender(requestOutfitDTO.getGender());
outfitRequest.setSessionRecordId(sessionRecord.getId());
outfitRequestMapper.insert(outfitRequest);
log.info("agent request params: {}", JSON.toJSONString(params));
@@ -88,38 +104,50 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
String key = RedisURIConstants.outfitResultCache + requestId;
OutfitResultVO outfitResultVO = new OutfitResultVO(style.getId(), requestId, StatusEnum.PENDING.name());
outfitResultVO.setCreateTimeStamp(System.currentTimeMillis());
cacheUtil.setCache(key, outfitResultVO, RedisURIConstants.verifyCodeTimeout);
}
return requestIds;
}
private Map<String, Object> setRequestOutfitParams(Long customerId, int num, String stylistPath, String gender, String sessionId) {
private Map<String, Object> setRequestOutfitParams(RequestOutfitDTO requestOutfitDTO, StylistPathEnum stylistPathEnum) {
HashMap<String, Object> params = new HashMap<>();
params.put("user_id", customerId.toString());
params.put("num_outfits", num);
params.put("stylist_path", stylistPath);
params.put("user_id", requestOutfitDTO.getCustomerId().toString());
params.put("num_outfits", requestOutfitDTO.getNum());
params.put("stylist_path", stylistPathEnum.getName());
params.put("callback_url", webhookDomain);
params.put("gender", gender);
params.put("max_len", 9);
params.put("session_id", sessionId);
params.put("gender", requestOutfitDTO.getGender());
// params.put("max_len", 5);
params.put("session_id", requestOutfitDTO.getSessionId());
params.put("batch_sources", Collections.singleton("2025_q4"));
if (StringUtils.isNotBlank(requestOutfitDTO.getSummary())) {
params.put("request_summary", requestOutfitDTO.getSummary());
}
if (!CollectionUtils.isEmpty(requestOutfitDTO.getOccasion())) {
params.put("occasions", requestOutfitDTO.getOccasion());
}
return params;
}
// 搭配完成后的回调通知处理
public void callback(OutfitCallbackDTO callbackDTO) {
if (Objects.isNull(callbackDTO.getStatus())) {
if (Objects.isNull(callbackDTO.getStatus())
|| callbackDTO.getStatus().equals("failed")
|| callbackDTO.getStatus().equals("continue")) {
return;
}
if ("ok".equals(callbackDTO.getStatus()) || "stop".equals(callbackDTO.getStatus())) {
// 1. 判断path是否为空是 -> 不做任何处理
if (StringUtil.isNullOrEmpty(callbackDTO.getPath())) {
if (("ok".equals(callbackDTO.getStatus())
|| "stop".equals(callbackDTO.getStatus()))
&& StringUtils.isBlank(callbackDTO.getPath())) {
log.error("状态为ok || stop时path为空");
return;
}
if (StringUtil.isNullOrEmpty(callbackDTO.getOutfit_id())) {
if (StringUtils.isBlank(callbackDTO.getOutfit_id())) {
log.error("回调参数中outfit_id为空");
return;
}
@@ -137,16 +165,42 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
// 3.更新path, items, 状态
// 由于数据变化较频繁考虑存到redis
if (outfitResult instanceof OutfitResultVO) {
String status;
switch(callbackDTO.getStatus()) {
case "ok":
status = StatusEnum.RUNNING.name();
((OutfitResultVO) outfitResult).setPath(minioUtil.getPresignedUrl(callbackDTO.getPath(), CommonConstants.MINIO_PATH_TIMEOUT));
String status = "ok".equals(callbackDTO.getStatus()) ? StatusEnum.RUNNING.name() : StatusEnum.SUCCEEDED.name();
break;
case "stop":
status = StatusEnum.SUCCEEDED.name();
((OutfitResultVO) outfitResult).setPath(minioUtil.getPresignedUrl(callbackDTO.getPath(), CommonConstants.MINIO_PATH_TIMEOUT));
break;
case "retrying":
status = StatusEnum.PENDING.name();
((OutfitResultVO) outfitResult).setCreateTimeStamp(System.currentTimeMillis());
((OutfitResultVO) outfitResult).setPath(null);
break;
case "almost_done":
// 此时是没有更新path的
status = StatusEnum.ALMOST_DONE.name();
break;
case /*"failed",*/ "retry_failed":
status = StatusEnum.FAILED.name();
break;
default:
log.error("outfit_id为{},回调状态未知{}", requestId, callbackDTO.getStatus());
status = StatusEnum.FAILED.name();
}
((OutfitResultVO) outfitResult).setStatus(status);
cacheUtil.setCache(key, outfitResult, RedisURIConstants.outfitResultTimeout);
}
}
// 生成结束或失败时更新数据库
if ("stop".equals(callbackDTO.getStatus()) || "failed".equals(callbackDTO.getStatus())) {
String requestId = callbackDTO.getOutfit_id();
if ("stop".equals(callbackDTO.getStatus())
/*|| "failed".equals(callbackDTO.getStatus())*/
|| "retry_failed".equals(callbackDTO.getStatus())) {
// String requestId = callbackDTO.getOutfit_id();
LambdaQueryWrapper<Style> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Style::getPythonRequestId, requestId);
@@ -165,12 +219,20 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
outfit.setItems(itemsJson);
updateById(outfit);
OutfitRequest outfitRequest = outfitRequestMapper.selectById(outfit.getOutfitRequestId());
if (Objects.nonNull(outfitRequest) && Objects.nonNull(outfitRequest.getSessionRecordId())) {
SessionRecord sessionRecord = sessionRecordMapper.selectById(outfitRequest.getSessionRecordId());
saveOrUpdateSession(sessionRecord.getSessionId(), sessionRecord.getVisitRecordId(),
callbackDTO.getRequest_summary(), callbackDTO.getOccasions());
}
}
}
public List<OutfitResultVO> getOutfitResult(List<String> requestIDs) {
ArrayList<OutfitResultVO> resultVOS = new ArrayList<>();
ArrayList<String> reQueryIds = new ArrayList<>();
List<String> expiredIds = new ArrayList<>();
// 优先从redis中获取结果没有再从数据库中查询
for (String requestID : requestIDs) {
String key = RedisURIConstants.outfitResultCache + requestID;
@@ -180,8 +242,26 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
reQueryIds.add(requestID);
continue;
}
// 判断这条记录的状态是否为成功或者失败判断这条记录的创建时间是否超过3分钟继续往后设置为失败并更新数据库
if (outfit instanceof OutfitResultVO) {
if ((((OutfitResultVO) outfit).getStatus().equals(StatusEnum.PENDING.name())
|| ((OutfitResultVO) outfit).getStatus().equals(StatusEnum.RUNNING.name())
|| ((OutfitResultVO) outfit).getStatus().equals(StatusEnum.ALMOST_DONE.name()))
&& isExpired(((OutfitResultVO) outfit).getCreateTimeStamp())) {
// 设置状态为失败
((OutfitResultVO) outfit).setStatus(StatusEnum.FAILED.name());
// 更新redis和数据库状态
expiredIds.add(requestID);
cacheUtil.setCache(key, outfit, RedisURIConstants.outfitResultTimeout);
}
resultVOS.add((OutfitResultVO) outfit);
}
}
if (!expiredIds.isEmpty()) {
batchUpdateExpiredRecords(expiredIds);
}
if (!reQueryIds.isEmpty()) {
LambdaQueryWrapper<Style> queryWrapper = new LambdaQueryWrapper<>();
@@ -189,12 +269,13 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
List<Style> list = list(queryWrapper);
if (!list.isEmpty()) {
// 在数据库中的数据,都是处于成功或失败的状态
for (Style style : list) {
OutfitResultVO outfitResultVO = new OutfitResultVO();
outfitResultVO.setId(style.getId());
outfitResultVO.setRequestId(style.getPythonRequestId());
outfitResultVO.setStatus(StatusEnum.of(style.getGenerationStatus()).name());
if (!StringUtil.isNullOrEmpty(style.getStyleImageUrl())) {
if (!StringUtils.isBlank(style.getStyleImageUrl())) {
outfitResultVO.setPath(minioUtil.getPresignedUrl(style.getStyleImageUrl(), CommonConstants.MINIO_PATH_TIMEOUT));
}
resultVOS.add(outfitResultVO);
@@ -205,4 +286,143 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
return resultVOS;
}
// 3分钟的毫秒数
private static final long THREE_MINUTES_IN_MILLIS = 3 * 60 * 1000;
private boolean isExpired(long createTimeMillis) {
long currentTimeMillis = System.currentTimeMillis();
return (currentTimeMillis - createTimeMillis) >= THREE_MINUTES_IN_MILLIS;
}
private void batchUpdateExpiredRecords(List<String> expiredIds) {
try {
if (CollectionUtils.isEmpty(expiredIds)) {
return;
}
// 批量更新,减少数据库压力
lambdaUpdate()
.in(Style::getPythonRequestId, expiredIds)
.set(Style::getGenerationStatus, StatusEnum.FAILED.getCode())
.set(Style::getUpdatedTime, LocalDateTime.now())
.update();
log.info("批量更新过期记录为失败状态,数量:{}", expiredIds.size());
} catch (Exception e) {
log.error("批量更新过期记录失败", e);
}
}
@Override
public void setFavoriteStyle(Long styleId) {
if (styleId == null) {
throw new BusinessException("Style ID is required", "风格ID不能为空", ResultEnum.PARAMETER_ERROR.getCode());
}
Style style = this.getById(styleId);
if (style == null) {
throw new BusinessException("Style not found", "风格不存在", ResultEnum.FAIL.getCode());
}
// 设置为收藏
style.setIsFavorite(1);
this.updateById(style);
log.info("风格ID: {} 已设置为收藏", styleId);
}
@Override
public void cancelFavoriteStyle(Long styleId) {
if (styleId == null) {
throw new BusinessException("Style ID is required", "风格ID不能为空", ResultEnum.PARAMETER_ERROR.getCode());
}
Style style = this.getById(styleId);
if (style == null) {
throw new BusinessException("Style not found", "风格不存在", ResultEnum.FAIL.getCode());
}
// 取消收藏
style.setIsFavorite(0);
this.updateById(style);
log.info("风格ID: {} 已取消收藏", styleId);
}
public SessionRecord saveOrUpdateSession(String sessionId, Long visitsId, String summary, List<String> occasion) {
// 判断同一次进店记录中当前会话id是否已存在
QueryWrapper<SessionRecord> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SessionRecord::getVisitRecordId, visitsId)
.eq(SessionRecord::getSessionId, sessionId);
SessionRecord sessionRecord = sessionRecordMapper.selectOne(queryWrapper);
if (Objects.isNull(sessionRecord)) {
sessionRecord = new SessionRecord();
sessionRecord.setVisitRecordId(visitsId);
sessionRecord.setSessionId(sessionId);
sessionRecord.setRequestSummary(summary);
sessionRecord.setOccasionsList(occasion);
sessionRecord.setCreatedTime(LocalDateTime.now());
int insert = sessionRecordMapper.insert(sessionRecord);
log.info("新增session record影响{}条记录", insert);
} else {
sessionRecord.setRequestSummary(summary);
sessionRecord.setOccasionsList(occasion);
sessionRecord.setUpdatedTime(LocalDateTime.now());
int row = sessionRecordMapper.updateById(sessionRecord);
log.info("更新session record影响{}条记录", row);
}
return sessionRecord;
}
public List<String> retrieveAndRegenerate(Long tryOnEffectsId, Long checkInId) {
// 1. 判断id是否有效
TryOnEffect tryOnEffect = tryOnEffectMapper.selectById(tryOnEffectsId);
if (Objects.isNull(tryOnEffect)) {
log.error("无效id: {}", tryOnEffectsId);
throw new BusinessException("Error: Invalid ID.");
}
if (Objects.isNull(tryOnEffect.getStyleId())) {
log.error("Id 为:{} 的tryOnEffects记录,没有style_id", tryOnEffectsId);
throw new BusinessException("Cannot recreate outfit from past data.");
}
if (Objects.isNull(checkInId)) {
log.error("checkInId 为空");
throw new BusinessException("'checkInId' cannot be empty");
}
// 2. 组装参数
Style style = baseMapper.selectById(tryOnEffect.getStyleId());
if (Objects.nonNull(style)) {
OutfitRequest outfitRequest = outfitRequestMapper.selectById(style.getOutfitRequestId());
if (Objects.isNull(outfitRequest)){
log.error("找不到Id 为:{} 的OutfitRequest记录", style.getOutfitRequestId());
throw new BusinessException("Cannot recreate outfit from past data.");
}
SessionRecord sessionRecord = sessionRecordMapper.selectById(outfitRequest.getSessionRecordId());
if (Objects.isNull(sessionRecord)){
log.error("找不到Id 为:{} 的SessionRecord记录", outfitRequest.getSessionRecordId());
throw new BusinessException("Cannot recreate outfit from past data.");
}
RequestOutfitDTO requestOutfitDTO = getRequestOutfitDTO(outfitRequest, sessionRecord, checkInId);
return requestOutfit(requestOutfitDTO);
} else {
log.error("找不到Id 为:{} 的Style记录", tryOnEffect.getStyleId());
throw new BusinessException("Cannot recreate outfit from past data.");
}
}
@NotNull
private static RequestOutfitDTO getRequestOutfitDTO(OutfitRequest outfitRequest, SessionRecord sessionRecord, Long checkInId) {
RequestOutfitDTO requestOutfitDTO = new RequestOutfitDTO();
requestOutfitDTO.setCustomerId(outfitRequest.getCustomerId());
requestOutfitDTO.setCheckInId(checkInId);
requestOutfitDTO.setStylist(outfitRequest.getStylist());
requestOutfitDTO.setGender(outfitRequest.getGender());
requestOutfitDTO.setNum(1);
requestOutfitDTO.setSessionId(sessionRecord.getSessionId());
requestOutfitDTO.setSummary(sessionRecord.getRequestSummary());
requestOutfitDTO.setOccasion(sessionRecord.getOccasionsList());
return requestOutfitDTO;
}
}

View File

@@ -1,11 +1,13 @@
package com.aida.lanecarford.service.impl;
import cn.hutool.json.JSONObject;
import com.aida.lanecarford.common.PageResult;
import com.aida.lanecarford.common.constant.CommonConstants;
import com.aida.lanecarford.config.MinioConfig;
import com.aida.lanecarford.config.FaceSwapConfig;
import com.aida.lanecarford.common.response.ResultEnum;
import com.aida.lanecarford.common.constant.MinioFileConstants;
import com.aida.lanecarford.dto.HistoricalDTO;
import com.aida.lanecarford.entity.*;
import com.aida.lanecarford.exception.BusinessException;
import com.aida.lanecarford.mapper.CustomerMapper;
@@ -16,10 +18,13 @@ import com.aida.lanecarford.service.*;
import com.aida.lanecarford.entity.Suggestion;
import com.aida.lanecarford.util.MinioUtil;
import com.aida.lanecarford.util.StringListConverter;
import com.aida.lanecarford.vo.TryOnResultVo;
import com.aida.lanecarford.vo.OutfitHisVO;
import com.aida.lanecarford.vo.TryOnResultVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.auth.oauth2.GoogleCredentials;
import lombok.RequiredArgsConstructor;
@@ -38,7 +43,7 @@ import java.util.concurrent.TimeUnit;
*
* @author AI Assistant
* @since 2024-01-01
/**
* /**
* 试穿效果服务实现类
*/
@Service
@@ -46,12 +51,7 @@ import java.util.concurrent.TimeUnit;
public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOnEffect> implements TryOnEffectService {
private static final Logger log = LoggerFactory.getLogger(TryOnEffectServiceImpl.class);
private final StyleService styleService;
private final ModelPhotoService modelPhotoService;
private final CustomerPhotoService customerPhotoService;
private final ImageCompositionService imageCompositionService;
private final CustomerMapper customerMapper;
private final MinioUtil minioUtil;
private final MinioConfig minioConfig;
private final FaceSwapConfig faceSwapConfig;
@@ -59,7 +59,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
private final OutfitRequestMapper outfitRequestMapper;
@Override
public TryOnResultVo generateTryOnEffect(TryOnEffect tryOnEffectDto) {
public TryOnResultVO generateTryOnEffect(TryOnEffect tryOnEffectDto) {
Integer isRegenerated = tryOnEffectDto.getIsRegenerated();
String toAIlogicalUrl = null;
String prompt = null;
@@ -74,7 +74,13 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
throw BusinessException.parameterRequired("originalTryOnId");
}
TryOnEffect originalTryOn = this.getById(originalTryOnId);
if (tryOnEffectDto.getStyleId()==null){
tryOnEffectDto.setStyleId(originalTryOn.getStyleId());
}
String resultImageUrl = originalTryOn.getResultImageUrl();
if (tryOnEffectDto.getStyleId()==null){
tryOnEffectDto.setStyleId(originalTryOn.getStyleId());
}
imageUrls.add(resultImageUrl);
Long customerPhotoId = tryOnEffectDto.getCustomerPhotoId();
@@ -83,7 +89,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
CustomerPhoto customerPhoto = customerPhotoService.getById(customerPhotoId);
String customerPhotoUrl = customerPhoto.getPhotoUrl();
if (customerPhotoUrl != null && !customerPhotoUrl.trim().isEmpty()) {
if (imageUrls.isEmpty()){
if (imageUrls.isEmpty()) {
throw BusinessException.parameterRequired("TryOn result");
}
//先放tryon图片后放脸
@@ -114,24 +120,24 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
for (Map<String, String> map : maps) {
String category = map.get("category");
sb.append("a ");
sb.append( category);
sb.append(category);
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" +
"\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" +
"**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" +
"**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, All items must be worn on the person; they must not be displayed anywhere else except on the model.** **CRITICAL: NO cropping of the head or face.**";
aiRreultlogicalUrl = AITryOnEffect(prompt, imageUrls);
}else if (tryOnEffectDto.getIsRegenerated() == 1 && imageUrls.size() == 1){
} else if (tryOnEffectDto.getIsRegenerated() == 1 && imageUrls.size() == 1) {
//根据提示词修改图像
aiRreultlogicalUrl = AITryOnEffect(prompt, imageUrls);
}else if (tryOnEffectDto.getIsRegenerated() == 1 && imageUrls.size() > 1){
} else if (tryOnEffectDto.getIsRegenerated() == 1 && imageUrls.size() > 1) {
//换脸
aiRreultlogicalUrl = callFaceSwapAPI(imageUrls);
}
@@ -140,8 +146,8 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
tryOnEffectDto.setGenerationStatus("completed");
this.saveOrUpdate(tryOnEffectDto);
TryOnResultVo tryOnResultVo = new TryOnResultVo();
tryOnResultVo.setTryOnId(tryOnEffectDto.getId());
TryOnResultVO tryOnResultVo = new TryOnResultVO();
tryOnResultVo.setId(tryOnEffectDto.getId());
tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl(aiRreultlogicalUrl, CommonConstants.MINIO_PATH_TIMEOUT));
@@ -150,15 +156,15 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
//library页面点击details后的显示
@Override
public List<TryOnResultVo> getFavoriteTryOnEffects(Long visitRecordId) {
public List<TryOnResultVO> getFavoriteTryOnEffects(Long visitRecordId) {
List<TryOnEffect> tryOnEffects = this.list(new LambdaQueryWrapper<TryOnEffect>()
.eq(TryOnEffect::getVisitRecordId, visitRecordId)
.eq(TryOnEffect::getIsFavorite, 1)
.orderByAsc(TryOnEffect::getCreatedTime));
List<TryOnResultVo> tryOnResultVos = new ArrayList<>();
.orderByDesc(TryOnEffect::getCreatedTime));
List<TryOnResultVO> tryOnResultVos = new ArrayList<>();
for (TryOnEffect tryOnEffect : tryOnEffects) {
TryOnResultVo tryOnResultVo = new TryOnResultVo();
tryOnResultVo.setTryOnId(tryOnEffect.getId());
TryOnResultVO tryOnResultVo = new TryOnResultVO();
tryOnResultVo.setId(tryOnEffect.getId());
// 使用新的API获取预签名URL数据库存储的是逻辑URL
tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl(
tryOnEffect.getResultImageUrl(),
@@ -184,6 +190,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
/**
* 添加意见建议
*
* @param suggestion 意见建议实体
* @return 是否添加成功
*/
@@ -206,6 +213,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
}
}
//已废弃
@Override
public String reFace(Long customerPhotoId) {
@@ -255,16 +263,96 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
return minioUtil.convertToPresignedUrl(aiRreultlogicalUrl, CommonConstants.MINIO_PATH_TIMEOUT);
}
@Override
public PageResult<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO) {
LambdaQueryWrapper<TryOnEffect> tryOnEffectLambdaQueryWrapper = new LambdaQueryWrapper<TryOnEffect>()
.eq(TryOnEffect::getCustomerId, historicalDTO.getCustomerId())
.orderByDesc(TryOnEffect::getCreatedTime);
if (historicalDTO.getVisitRecordId() != null) {
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getVisitRecordId, historicalDTO.getVisitRecordId());
}
if (historicalDTO.getIsLibrary() != null && historicalDTO.getIsLibrary()) {
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsFavorite, 1);
}
if (CommonConstants.TRYON.equals(historicalDTO.getType())) {
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 0);
} else if (CommonConstants.GENAI.equals(historicalDTO.getType())) {
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 1);
}
long current = historicalDTO.getPageNum() == null || historicalDTO.getPageNum() <= 0 ? 1L : historicalDTO.getPageNum();
long size = historicalDTO.getPageSize() == null || historicalDTO.getPageSize() <= 0 ? 10L : historicalDTO.getPageSize();
IPage<TryOnEffect> page = this.page(new Page<>(current, size), tryOnEffectLambdaQueryWrapper);
List<TryOnResultVO> tryOnResultVos = new ArrayList<>();
for (TryOnEffect tryOnEffect : page.getRecords()) {
TryOnResultVO tryOnResultVo = new TryOnResultVO();
tryOnResultVo.setId(tryOnEffect.getId());
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
));
}
tryOnResultVo.setIsRegenerated(tryOnEffect.getIsRegenerated());
tryOnResultVo.setIsFavorite(tryOnEffect.getIsFavorite());
tryOnResultVos.add(tryOnResultVo);
}
return new PageResult<>(tryOnResultVos, page.getTotal(), page.getCurrent(), page.getSize());
}
@Override
public PageResult<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO) {
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<Style>()
.eq(Style::getCustomerId, historicalDTO.getCustomerId())
.eq(Style::getGenerationStatus, 1)
.orderByDesc(Style::getCreatedTime);
if (historicalDTO.getVisitRecordId() != null) {
styleLambdaQueryWrapper.eq(Style::getVisitRecordId, historicalDTO.getVisitRecordId());
}
if (historicalDTO.getIsLibrary() != null && historicalDTO.getIsLibrary()) {
styleLambdaQueryWrapper.eq(Style::getIsFavorite, 1);
}
long current = historicalDTO.getPageNum() == null || historicalDTO.getPageNum() <= 0 ? 1L : historicalDTO.getPageNum();
long size = historicalDTO.getPageSize() == null || historicalDTO.getPageSize() <= 0 ? 10L : historicalDTO.getPageSize();
IPage<Style> page = styleService.page(new Page<>(current, size), styleLambdaQueryWrapper);
List<OutfitHisVO> outfitHisVos = new ArrayList<>();
for (Style style : page.getRecords()) {
OutfitHisVO outfitHisVo = new OutfitHisVO();
outfitHisVo.setId(style.getId());
outfitHisVo.setUrl(minioUtil.convertToPresignedUrl(
style.getStyleImageUrl(),
CommonConstants.MINIO_PATH_TIMEOUT
));
outfitHisVo.setIsFavorite(style.getIsFavorite());
outfitHisVos.add(outfitHisVo);
}
return new PageResult<>(outfitHisVos, page.getTotal(), page.getCurrent(), page.getSize());
}
//目前用于customize your look页面点击finish后的显示
@Override
public List<TryOnResultVo> getTryOnEffectsByStyleId(Long styleId) {
public List<TryOnResultVO> getTryOnEffectsByStyleId(Long styleId) {
List<TryOnEffect> tryOnEffects = this.list(new LambdaQueryWrapper<TryOnEffect>()
.eq(TryOnEffect::getStyleId, styleId)
.orderByAsc(TryOnEffect::getCreatedTime));
List<TryOnResultVo> tryOnResultVos = new ArrayList<>();
.orderByDesc(TryOnEffect::getCreatedTime));
List<TryOnResultVO> tryOnResultVos = new ArrayList<>();
for (TryOnEffect tryOnEffect : tryOnEffects) {
TryOnResultVo tryOnResultVo = new TryOnResultVo();
tryOnResultVo.setTryOnId(tryOnEffect.getId());
TryOnResultVO tryOnResultVo = new TryOnResultVO();
tryOnResultVo.setId(tryOnEffect.getId());
// 使用新的API获取预签名URL数据库存储的是逻辑URL
tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl(
tryOnEffect.getResultImageUrl(),
@@ -569,7 +657,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
String finishReason = candidate.getString("finishReason");
if (!"STOP".equals(finishReason)) {
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")) {
finishMessage = "Try rephrasing the prompt.If you think this was an error, send feedback.";
throw new BusinessException(finishMessage, "请尝试重新表述提示词。若您认为这是误判,可提交反馈。", ResultEnum.ERROR.getCode());
@@ -616,6 +704,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
/**
* 调用换脸API
*
* @param imageUrls 图片URL列表第一个为源图片第二个为目标图片
* @return 换脸后的图片URL
*/
@@ -638,9 +727,11 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
requestBody.put("input_face", inputFaceUrl);
requestBody.put("threshold", 0.2);
log.info("换脸API请求体: {}", requestBody.toString());
// 调用换脸API
String response = sendFaceSwapRequest(faceSwapConfig.getRefaceUrl(), requestBody.toString());
// 处理响应
return processFaceSwapResponse(response);
@@ -733,7 +824,6 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
log.info("换脸成功,图片路径: {}", imagePath);
// 下载图片并上传到MinIO
return imagePath;
} else {
@@ -744,7 +834,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
log.error("output字段不是数组格式: {}", outputObj);
throw new BusinessException("Invalid output format", "output字段格式不正确", ResultEnum.ERROR.getCode());
}
}else {
} else {
log.error("换脸API响应失败: {}", response);
throw new BusinessException("reface error", "换脸失败", ResultEnum.ERROR.getCode());
}

View File

@@ -0,0 +1,15 @@
package com.aida.lanecarford.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
@Data
public class BaseVO implements Serializable {
private static final long serialVersionUID = 10007L;
@Schema(description = "ID")
private Long id;
}

View File

@@ -16,12 +16,15 @@ public class CustomerVO {
/**
* 顾客姓名
*/
@Schema(description = "顾客姓名", example = "张三", required = true)
@Schema(description = "顾客姓名", example = "张三")
private String name;
/**
* 顾客邮箱
*/
@Schema(description = "顾客邮箱地址", example = "zhangsan@example.com", required = true)
@Schema(description = "顾客邮箱地址", example = "zhangsan@example.com")
private String email;
@Schema(description = "顾客vipId", example = "1")
private String vipId;
}

View File

@@ -0,0 +1,11 @@
package com.aida.lanecarford.vo;
import lombok.Data;
@Data
public class OutfitHisVO extends BaseVO {
private String url;
private Integer isFavorite;
}

View File

@@ -26,6 +26,8 @@ public class OutfitResultVO {
)
private String status;
private Long createTimeStamp;
public OutfitResultVO(Long id, String requestId, String status) {
this.id = id;
this.requestId = requestId;

View File

@@ -3,9 +3,7 @@ package com.aida.lanecarford.vo;
import lombok.Data;
@Data
public class TryOnResultVo {
private Long tryOnId;
public class TryOnResultVO extends BaseVO {
private String tryOnUrl;

View File

@@ -71,6 +71,7 @@ CREATE TABLE `styles` (
`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',
`generation_status` tinyint DEFAULT '0' COMMENT '生成状态(0-处理中,1-已完成,2-失败)',
`is_favorite` tinyint NOT NULL DEFAULT '0' COMMENT '是否喜欢(0-否,1-是)',
`items` json DEFAULT NULL COMMENT '单品唯一标识',
`error_message` text COLLATE utf8mb4_unicode_ci COMMENT '错误信息',
`created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',