Compare commits
25 Commits
3df8767c47
...
dev/dev-xp
| Author | SHA1 | Date | |
|---|---|---|---|
| 91eb21aa84 | |||
| 2972ab1dca | |||
| 5e6e9a8787 | |||
| 5005d8ac2a | |||
| 0eb5128b6f | |||
| acf4c6a307 | |||
| faa655bc9d | |||
| b0bf6dc338 | |||
| 316702a8cf | |||
| 8482a88870 | |||
| eda8e74b1a | |||
| 8557335cd2 | |||
| a16cb37c7f | |||
| dbf6c45ec8 | |||
|
|
adde1b007e | ||
|
|
9fb7f3128b | ||
|
|
e285b252df | ||
|
|
61faf40ca4 | ||
|
|
002e39a99f | ||
|
|
e08517cdcc | ||
|
|
8fb082d5bc | ||
|
|
e665b50bb4 | ||
| 71343010d5 | |||
| 5a4201595b | |||
| 8d48ba94f5 |
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'
|
||||||
@@ -2,7 +2,6 @@ package com.aida.lanecarford.common.security;
|
|||||||
|
|
||||||
import com.aida.lanecarford.common.security.config.JwtProperties;
|
import com.aida.lanecarford.common.security.config.JwtProperties;
|
||||||
import com.aida.lanecarford.common.security.context.UserContext;
|
import com.aida.lanecarford.common.security.context.UserContext;
|
||||||
import com.aida.lanecarford.exception.BusinessException;
|
|
||||||
import com.aida.lanecarford.util.CacheUtil;
|
import com.aida.lanecarford.util.CacheUtil;
|
||||||
import com.aida.lanecarford.vo.AuthPrincipalVO;
|
import com.aida.lanecarford.vo.AuthPrincipalVO;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@@ -25,7 +24,7 @@ public class JwtInterceptor implements HandlerInterceptor {
|
|||||||
private final JwtProperties jwtProperties;
|
private final JwtProperties jwtProperties;
|
||||||
|
|
||||||
@Override
|
@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())) {
|
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -41,7 +40,8 @@ public class JwtInterceptor implements HandlerInterceptor {
|
|||||||
String extracted = jwtUtil.extractUserinfo(jwtToken);
|
String extracted = jwtUtil.extractUserinfo(jwtToken);
|
||||||
if (StringUtil.isNullOrEmpty(extracted)) {
|
if (StringUtil.isNullOrEmpty(extracted)) {
|
||||||
log.warn("TOKEN已过期,请重新登录!(token without userInfo)");
|
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);
|
AuthPrincipalVO authPrincipalVO = JSONObject.parseObject(extracted, AuthPrincipalVO.class);
|
||||||
@@ -54,10 +54,12 @@ public class JwtInterceptor implements HandlerInterceptor {
|
|||||||
|
|
||||||
if (Objects.isNull(token)) {
|
if (Objects.isNull(token)) {
|
||||||
log.warn("TOKEN已过期,请重新登录!(local cache empty)");
|
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)) {
|
} else if (!token.toString().equals(jwtToken)) {
|
||||||
log.warn("TOKEN已过期,请重新登录!(token not match local cache)");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.aida.lanecarford.controller;
|
|||||||
|
|
||||||
import com.aida.lanecarford.common.ApiResponse;
|
import com.aida.lanecarford.common.ApiResponse;
|
||||||
import com.aida.lanecarford.dto.BaseRequest;
|
import com.aida.lanecarford.dto.BaseRequest;
|
||||||
|
import com.aida.lanecarford.entity.Customer;
|
||||||
import com.aida.lanecarford.service.CustomerService;
|
import com.aida.lanecarford.service.CustomerService;
|
||||||
import com.aida.lanecarford.vo.CustomerCheckInVO;
|
import com.aida.lanecarford.vo.CustomerCheckInVO;
|
||||||
import com.aida.lanecarford.vo.CustomerVO;
|
import com.aida.lanecarford.vo.CustomerVO;
|
||||||
@@ -25,11 +26,11 @@ public class CustomerController {
|
|||||||
|
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "顾客入店登记",
|
summary = "顾客入店登记",
|
||||||
description = "验证顾客身份并创建入店记录,如果是新顾客则自动注册到系统中。"
|
description = "验证顾客身份并创建入店记录"
|
||||||
)
|
)
|
||||||
@GetMapping("/checkIn")
|
@GetMapping("/checkIn")
|
||||||
public ApiResponse<CustomerCheckInVO> customerCheckIn(@RequestParam String name, @RequestParam String email) {
|
public ApiResponse<CustomerCheckInVO> customerCheckIn(@RequestParam String nickname) {
|
||||||
return ApiResponse.success(customerService.customerCheckIn(name, email));
|
return ApiResponse.success(customerService.customerCheckIn(nickname));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/getAllCustomer")
|
@PostMapping("/getAllCustomer")
|
||||||
@@ -37,4 +38,15 @@ public class CustomerController {
|
|||||||
return ApiResponse.success(customerService.getAllCustomer(request));
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -78,4 +78,15 @@ public class StyleController {
|
|||||||
return ApiResponse.success(styleService.getOutfitResult(requestIDs));
|
return ApiResponse.success(styleService.getOutfitResult(requestIDs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "回溯历史对话,重新生成搭配图",
|
||||||
|
description = "根据当前的穿搭结果,回溯历史穿搭请求数据及历史对话,重新生成搭配"
|
||||||
|
)
|
||||||
|
@GetMapping("/retrieveAndRegenerate")
|
||||||
|
public ApiResponse<List<String>> retrieveAndRegenerate(
|
||||||
|
@Parameter(description = "tryOn后的图片id", required = true, example = "1369")
|
||||||
|
@RequestParam Long tryOnEffectsId) {
|
||||||
|
return ApiResponse.success(styleService.retrieveAndRegenerate(tryOnEffectsId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.aida.lanecarford.controller;
|
package com.aida.lanecarford.controller;
|
||||||
|
|
||||||
import com.aida.lanecarford.common.ApiResponse;
|
import com.aida.lanecarford.common.ApiResponse;
|
||||||
|
import com.aida.lanecarford.entity.Suggestion;
|
||||||
import com.aida.lanecarford.entity.TryOnEffect;
|
import com.aida.lanecarford.entity.TryOnEffect;
|
||||||
import com.aida.lanecarford.service.TryOnEffectService;
|
import com.aida.lanecarford.service.TryOnEffectService;
|
||||||
import com.aida.lanecarford.vo.TryOnResultVo;
|
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.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@@ -11,6 +13,7 @@ import jakarta.validation.Valid;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,4 +80,39 @@ public class TryOnEffectController {
|
|||||||
tryOnEffectService.cancelFavoriteTryOnEffect(tryOnId);
|
tryOnEffectService.cancelFavoriteTryOnEffect(tryOnId);
|
||||||
return ApiResponse.success();
|
return ApiResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为生成结果添加意见和建议
|
||||||
|
*/
|
||||||
|
@Operation(summary = "为生成结果添加意见和建议", description = "为指定试穿效果添加意见和建议")
|
||||||
|
@PostMapping("/add-comment")
|
||||||
|
public ApiResponse<Void> addComment(@RequestBody Suggestion suggestion) {
|
||||||
|
tryOnEffectService.addComment(suggestion);
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -16,4 +16,8 @@ public class OutfitCallbackDTO {
|
|||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
private List<Map<String, String>> items;
|
private List<Map<String, String>> items;
|
||||||
|
|
||||||
|
private String request_summary;
|
||||||
|
|
||||||
|
private List<String> occasions;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.aida.lanecarford.dto;
|
package com.aida.lanecarford.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Hidden;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "AI穿搭推荐请求参数")
|
@Schema(description = "AI穿搭推荐请求参数")
|
||||||
@@ -59,4 +62,10 @@ public class RequestOutfitDTO {
|
|||||||
)
|
)
|
||||||
private String sessionId;
|
private String sessionId;
|
||||||
|
|
||||||
|
@Hidden
|
||||||
|
private String summary;
|
||||||
|
|
||||||
|
@Hidden
|
||||||
|
private List<String> occasion;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,18 @@ import java.time.LocalDateTime;
|
|||||||
@TableName("customers")
|
@TableName("customers")
|
||||||
public class Customer extends BaseEntity {
|
public class Customer extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导购id,即user表的主键id
|
||||||
|
*/
|
||||||
|
@TableField("user_id")
|
||||||
|
private Long salesId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vip ID
|
||||||
|
*/
|
||||||
|
@TableField("vip_id")
|
||||||
|
private String vipId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 顾客姓名
|
* 顾客姓名
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -31,4 +31,9 @@ public class OutfitRequest extends BaseEntity{
|
|||||||
* 当前任务状态
|
* 当前任务状态
|
||||||
*/
|
*/
|
||||||
private int status;
|
private int status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会话记录id
|
||||||
|
*/
|
||||||
|
private Long sessionRecordId;
|
||||||
}
|
}
|
||||||
|
|||||||
51
src/main/java/com/aida/lanecarford/entity/SessionRecord.java
Normal file
51
src/main/java/com/aida/lanecarford/entity/SessionRecord.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
53
src/main/java/com/aida/lanecarford/entity/Suggestion.java
Normal file
53
src/main/java/com/aida/lanecarford/entity/Suggestion.java
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package com.aida.lanecarford.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 意见建议实体类
|
||||||
|
*
|
||||||
|
* @author AI Assistant
|
||||||
|
* @since 2024-01-01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("suggestions")
|
||||||
|
public class Suggestion extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 顾客ID
|
||||||
|
*/
|
||||||
|
@Schema(description = "顾客ID", example = "1", required = true)
|
||||||
|
@TableField("customer_id")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进店记录ID
|
||||||
|
*/
|
||||||
|
@Schema(description = "进店记录ID", example = "1", required = true)
|
||||||
|
@TableField("visit_record_id")
|
||||||
|
private Long visitRecordId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 试穿效果ID
|
||||||
|
*/
|
||||||
|
@Schema(description = "试穿效果ID", example = "1", required = true)
|
||||||
|
@TableField("try_on_effects_id")
|
||||||
|
private Long tryOnEffectsId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 意见建议内容
|
||||||
|
*/
|
||||||
|
@Schema(description = "意见建议内容", example = "这件衣服颜色不太合适,建议换成浅色系", required = true)
|
||||||
|
@TableField("suggestion")
|
||||||
|
private String suggestion;
|
||||||
|
}
|
||||||
@@ -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> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.aida.lanecarford.mapper;
|
||||||
|
|
||||||
|
import com.aida.lanecarford.entity.Suggestion;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 意见建议Mapper接口
|
||||||
|
*
|
||||||
|
* @author AI Assistant
|
||||||
|
* @since 2024-01-01
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SuggestionMapper extends BaseMapper<Suggestion> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,8 +12,10 @@ 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);
|
||||||
|
|
||||||
|
Customer createCustomer(String vipId, String nickname);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,4 +19,6 @@ public interface StyleService extends IService<Style> {
|
|||||||
|
|
||||||
List<OutfitResultVO> getOutfitResult(List<String> requestIDs);
|
List<OutfitResultVO> getOutfitResult(List<String> requestIDs);
|
||||||
|
|
||||||
|
List<String> retrieveAndRegenerate(Long tryOnEffectsId);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.aida.lanecarford.service;
|
package com.aida.lanecarford.service;
|
||||||
|
|
||||||
|
import com.aida.lanecarford.entity.Suggestion;
|
||||||
import com.aida.lanecarford.entity.TryOnEffect;
|
import com.aida.lanecarford.entity.TryOnEffect;
|
||||||
import com.aida.lanecarford.vo.TryOnResultVo;
|
import com.aida.lanecarford.vo.TryOnResultVo;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
@@ -32,4 +33,15 @@ public interface TryOnEffectService extends IService<TryOnEffect> {
|
|||||||
void cancelFavoriteTryOnEffect(Long tryOnId);
|
void cancelFavoriteTryOnEffect(Long tryOnId);
|
||||||
|
|
||||||
List<TryOnResultVo> getTryOnEffectsByStyleId(Long styleId);
|
List<TryOnResultVo> getTryOnEffectsByStyleId(Long styleId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加意见建议
|
||||||
|
* @param suggestion 意见建议实体
|
||||||
|
* @return 是否添加成功
|
||||||
|
*/
|
||||||
|
boolean addComment(Suggestion suggestion);
|
||||||
|
|
||||||
|
String reFace(Long customerPhotoId);
|
||||||
|
|
||||||
|
String generateUrl(String prompt, String tryonUrl);
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.aida.lanecarford.service.impl;
|
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.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;
|
||||||
@@ -15,6 +17,7 @@ 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 lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -30,10 +33,16 @@ 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 nickname) {
|
||||||
|
// sales ID即当前的用户id
|
||||||
|
Long salesId = UserContext.getUserHolder().getId();
|
||||||
|
if (StringUtils.isBlank(nickname)) {
|
||||||
|
throw new BusinessException("Please enter a nickname.", ResultEnum.PROMPT.getCode());
|
||||||
|
}
|
||||||
// 1. 判断当前顾客信息在数据库中是否有存储
|
// 1. 判断当前顾客信息在数据库中是否有存储
|
||||||
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
|
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);
|
Customer customer = getOne(queryWrapper);
|
||||||
|
|
||||||
@@ -41,27 +50,28 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||||||
if (Objects.isNull(customer)) {
|
if (Objects.isNull(customer)) {
|
||||||
// todo 从连卡佛数据库查数据
|
// 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. 添加当前顾客到本系统数据库
|
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 添加入店记录
|
// 4. 添加入店记录
|
||||||
VisitRecord visitRecord = visitRecordService.addRecord(customer.getId(), UserContext.getUserHolder().getId());
|
VisitRecord visitRecord = visitRecordService.addRecord(customer.getId(), salesId);
|
||||||
|
|
||||||
return new CustomerCheckInVO(customer.getId(), visitRecord.getId());
|
return new CustomerCheckInVO(customer.getId(), visitRecord.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取所有的顾客名单
|
// 获取所有的顾客名单
|
||||||
public IPage<CustomerVO> getAllCustomer(BaseRequest request) {
|
public IPage<CustomerVO> getAllCustomer(BaseRequest request) {
|
||||||
|
Long salesId = UserContext.getUserHolder().getId();
|
||||||
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
|
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);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,10 +7,14 @@ import com.aida.lanecarford.common.enums.StylistPathEnum;
|
|||||||
import com.aida.lanecarford.dto.OutfitCallbackDTO;
|
import com.aida.lanecarford.dto.OutfitCallbackDTO;
|
||||||
import com.aida.lanecarford.dto.RequestOutfitDTO;
|
import com.aida.lanecarford.dto.RequestOutfitDTO;
|
||||||
import com.aida.lanecarford.entity.OutfitRequest;
|
import com.aida.lanecarford.entity.OutfitRequest;
|
||||||
|
import com.aida.lanecarford.entity.SessionRecord;
|
||||||
import com.aida.lanecarford.entity.Style;
|
import com.aida.lanecarford.entity.Style;
|
||||||
|
import com.aida.lanecarford.entity.TryOnEffect;
|
||||||
import com.aida.lanecarford.exception.BusinessException;
|
import com.aida.lanecarford.exception.BusinessException;
|
||||||
import com.aida.lanecarford.mapper.OutfitRequestMapper;
|
import com.aida.lanecarford.mapper.OutfitRequestMapper;
|
||||||
|
import com.aida.lanecarford.mapper.SessionRecordMapper;
|
||||||
import com.aida.lanecarford.mapper.StyleMapper;
|
import com.aida.lanecarford.mapper.StyleMapper;
|
||||||
|
import com.aida.lanecarford.mapper.TryOnEffectMapper;
|
||||||
import com.aida.lanecarford.service.StyleService;
|
import com.aida.lanecarford.service.StyleService;
|
||||||
import com.aida.lanecarford.util.CacheUtil;
|
import com.aida.lanecarford.util.CacheUtil;
|
||||||
import com.aida.lanecarford.util.MinioUtil;
|
import com.aida.lanecarford.util.MinioUtil;
|
||||||
@@ -20,12 +24,16 @@ import com.aida.lanecarford.vo.OutfitResultVO;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import io.netty.util.internal.StringUtil;
|
import io.netty.util.internal.StringUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -41,6 +49,8 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
|
|||||||
private final CacheUtil cacheUtil;
|
private final CacheUtil cacheUtil;
|
||||||
private final MinioUtil minioUtil;
|
private final MinioUtil minioUtil;
|
||||||
private final OutfitRequestMapper outfitRequestMapper;
|
private final OutfitRequestMapper outfitRequestMapper;
|
||||||
|
private final SessionRecordMapper sessionRecordMapper;
|
||||||
|
private final TryOnEffectMapper tryOnEffectMapper;
|
||||||
|
|
||||||
@Value("${webhook.domain}")
|
@Value("${webhook.domain}")
|
||||||
private String webhookDomain;
|
private String webhookDomain;
|
||||||
@@ -51,14 +61,16 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
|
|||||||
// 请求需要顾客id, 生成的数量,风格
|
// 请求需要顾客id, 生成的数量,风格
|
||||||
|
|
||||||
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, stylistPathEnum);
|
||||||
stylistPathEnum.getPath(), requestOutfitDTO.getGender(), requestOutfitDTO.getSessionId());
|
|
||||||
|
SessionRecord sessionRecord = saveOrUpdateSession(requestOutfitDTO.getSessionId(), requestOutfitDTO.getCheckInId(), null, null);
|
||||||
|
|
||||||
OutfitRequest outfitRequest = new OutfitRequest();
|
OutfitRequest outfitRequest = new OutfitRequest();
|
||||||
outfitRequest.setCustomerId(requestOutfitDTO.getCustomerId());
|
outfitRequest.setCustomerId(requestOutfitDTO.getCustomerId());
|
||||||
outfitRequest.setVisitRecordId(requestOutfitDTO.getCheckInId());
|
outfitRequest.setVisitRecordId(requestOutfitDTO.getCheckInId());
|
||||||
outfitRequest.setStylist(requestOutfitDTO.getStylist());
|
outfitRequest.setStylist(requestOutfitDTO.getStylist());
|
||||||
outfitRequest.setGender(requestOutfitDTO.getGender());
|
outfitRequest.setGender(requestOutfitDTO.getGender());
|
||||||
|
outfitRequest.setSessionRecordId(sessionRecord.getId());
|
||||||
outfitRequestMapper.insert(outfitRequest);
|
outfitRequestMapper.insert(outfitRequest);
|
||||||
|
|
||||||
log.info("agent request params: {}", JSON.toJSONString(params));
|
log.info("agent request params: {}", JSON.toJSONString(params));
|
||||||
@@ -94,16 +106,22 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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<>();
|
HashMap<String, Object> params = new HashMap<>();
|
||||||
params.put("user_id", customerId.toString());
|
params.put("user_id", requestOutfitDTO.getCustomerId().toString());
|
||||||
params.put("num_outfits", num);
|
params.put("num_outfits", requestOutfitDTO.getNum());
|
||||||
params.put("stylist_path", stylistPath);
|
params.put("stylist_path", stylistPathEnum.getName());
|
||||||
params.put("callback_url", webhookDomain);
|
params.put("callback_url", webhookDomain);
|
||||||
params.put("gender", gender);
|
params.put("gender", requestOutfitDTO.getGender());
|
||||||
params.put("max_len", 5);
|
// params.put("max_len", 5);
|
||||||
params.put("session_id", sessionId);
|
params.put("session_id", requestOutfitDTO.getSessionId());
|
||||||
params.put("batch_sources", Collections.singleton("2025_q4"));
|
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;
|
return params;
|
||||||
}
|
}
|
||||||
@@ -166,6 +184,13 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
|
|||||||
outfit.setItems(itemsJson);
|
outfit.setItems(itemsJson);
|
||||||
|
|
||||||
updateById(outfit);
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,4 +231,77 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
|
|||||||
return resultVOS;
|
return resultVOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
// 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.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
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) {
|
||||||
|
RequestOutfitDTO requestOutfitDTO = new RequestOutfitDTO();
|
||||||
|
requestOutfitDTO.setCustomerId(outfitRequest.getCustomerId());
|
||||||
|
requestOutfitDTO.setCheckInId(outfitRequest.getVisitRecordId());
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,8 +10,10 @@ import com.aida.lanecarford.entity.*;
|
|||||||
import com.aida.lanecarford.exception.BusinessException;
|
import com.aida.lanecarford.exception.BusinessException;
|
||||||
import com.aida.lanecarford.mapper.CustomerMapper;
|
import com.aida.lanecarford.mapper.CustomerMapper;
|
||||||
import com.aida.lanecarford.mapper.OutfitRequestMapper;
|
import com.aida.lanecarford.mapper.OutfitRequestMapper;
|
||||||
|
import com.aida.lanecarford.mapper.SuggestionMapper;
|
||||||
import com.aida.lanecarford.mapper.TryOnEffectMapper;
|
import com.aida.lanecarford.mapper.TryOnEffectMapper;
|
||||||
import com.aida.lanecarford.service.*;
|
import com.aida.lanecarford.service.*;
|
||||||
|
import com.aida.lanecarford.entity.Suggestion;
|
||||||
import com.aida.lanecarford.util.MinioUtil;
|
import com.aida.lanecarford.util.MinioUtil;
|
||||||
import com.aida.lanecarford.util.StringListConverter;
|
import com.aida.lanecarford.util.StringListConverter;
|
||||||
import com.aida.lanecarford.vo.TryOnResultVo;
|
import com.aida.lanecarford.vo.TryOnResultVo;
|
||||||
@@ -53,6 +55,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
private final MinioUtil minioUtil;
|
private final MinioUtil minioUtil;
|
||||||
private final MinioConfig minioConfig;
|
private final MinioConfig minioConfig;
|
||||||
private final FaceSwapConfig faceSwapConfig;
|
private final FaceSwapConfig faceSwapConfig;
|
||||||
|
private final SuggestionMapper suggestionMapper;
|
||||||
private final OutfitRequestMapper outfitRequestMapper;
|
private final OutfitRequestMapper outfitRequestMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -115,7 +118,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
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, light white backdrop** **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.**" +
|
||||||
@@ -179,6 +182,79 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
return tryOnResultVos;
|
return tryOnResultVos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加意见建议
|
||||||
|
* @param suggestion 意见建议实体
|
||||||
|
* @return 是否添加成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean addComment(Suggestion suggestion) {
|
||||||
|
try {
|
||||||
|
// 保存意见建议
|
||||||
|
int result = suggestionMapper.insert(suggestion);
|
||||||
|
|
||||||
|
if (result > 0) {
|
||||||
|
log.info("意见建议添加成功 - id: {}", suggestion.getId());
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
log.error("意见建议添加失败");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("添加意见建议时发生异常: {}", e.getMessage(), e);
|
||||||
|
throw new BusinessException("Add suggestion failed", "添加意见建议失败", ResultEnum.ERROR.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String reFace(Long customerPhotoId) {
|
||||||
|
|
||||||
|
List<String> imageUrls = new ArrayList<>();
|
||||||
|
//默认展示图片
|
||||||
|
imageUrls.add("lanecarford/try_on_result/default.jpg");
|
||||||
|
|
||||||
|
if (customerPhotoId != null) {
|
||||||
|
//根据id查到对应customerurl
|
||||||
|
CustomerPhoto customerPhoto = customerPhotoService.getById(customerPhotoId);
|
||||||
|
String customerPhotoUrl = customerPhoto.getPhotoUrl();
|
||||||
|
if (customerPhotoUrl != null && !customerPhotoUrl.trim().isEmpty()) {
|
||||||
|
imageUrls.add(customerPhotoUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String aiRreultlogicalUrl = callFaceSwapAPI(imageUrls);
|
||||||
|
String presignedUrl = minioUtil.getPresignedUrl(aiRreultlogicalUrl, CommonConstants.MINIO_PATH_TIMEOUT);
|
||||||
|
return presignedUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String generateUrl(String prompt, String tryonUrl) {
|
||||||
|
int startIndex = tryonUrl.indexOf("lanecarford");
|
||||||
|
String aiRreultlogicalUrl = "";
|
||||||
|
if (startIndex != -1) {
|
||||||
|
// 支持jpg和png格式的图片识别
|
||||||
|
int jpgEndIndex = tryonUrl.indexOf(".jpg");
|
||||||
|
int pngEndIndex = tryonUrl.indexOf(".png");
|
||||||
|
|
||||||
|
int endIndex = -1;
|
||||||
|
|
||||||
|
if (jpgEndIndex != -1 && (pngEndIndex == -1 || jpgEndIndex < pngEndIndex)) {
|
||||||
|
// 找到jpg格式
|
||||||
|
endIndex = jpgEndIndex + ".jpg".length();
|
||||||
|
} else if (pngEndIndex != -1 && (jpgEndIndex == -1 || pngEndIndex < jpgEndIndex)) {
|
||||||
|
// 找到png格式
|
||||||
|
endIndex = pngEndIndex + ".png".length();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (endIndex != -1) {
|
||||||
|
String resultString = tryonUrl.substring(startIndex, endIndex);
|
||||||
|
aiRreultlogicalUrl = AITryOnEffect(prompt, Arrays.asList(resultString));
|
||||||
|
} else {
|
||||||
|
log.error("未找到jpg或png格式的图片,无法识别图片类型");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return minioUtil.convertToPresignedUrl(aiRreultlogicalUrl, CommonConstants.MINIO_PATH_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
//目前用于customize your look页面点击finish后的显示
|
//目前用于customize your look页面点击finish后的显示
|
||||||
@Override
|
@Override
|
||||||
public List<TryOnResultVo> getTryOnEffectsByStyleId(Long styleId) {
|
public List<TryOnResultVo> getTryOnEffectsByStyleId(Long styleId) {
|
||||||
|
|||||||
@@ -16,12 +16,15 @@ public class CustomerVO {
|
|||||||
/**
|
/**
|
||||||
* 顾客姓名
|
* 顾客姓名
|
||||||
*/
|
*/
|
||||||
@Schema(description = "顾客姓名", example = "张三", required = true)
|
@Schema(description = "顾客姓名", example = "张三")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 顾客邮箱
|
* 顾客邮箱
|
||||||
*/
|
*/
|
||||||
@Schema(description = "顾客邮箱地址", example = "zhangsan@example.com", required = true)
|
@Schema(description = "顾客邮箱地址", example = "zhangsan@example.com")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
|
@Schema(description = "顾客vipId", example = "1")
|
||||||
|
private String vipId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,4 +166,19 @@ CREATE TABLE `outfit_request` (
|
|||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='穿搭请求表';
|
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='穿搭请求表';
|
||||||
|
|
||||||
|
-- 9. 意见建议表
|
||||||
|
CREATE TABLE `suggestions` (
|
||||||
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '意见建议ID',
|
||||||
|
`customer_id` bigint NOT NULL COMMENT '顾客ID',
|
||||||
|
`visit_record_id` bigint NOT NULL COMMENT '进店记录ID',
|
||||||
|
`try_on_effects_id` bigint NOT NULL COMMENT '试穿效果ID',
|
||||||
|
`suggestion` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '意见建议内容',
|
||||||
|
`created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`updated_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`deleted` tinyint DEFAULT '0' COMMENT '逻辑删除标志(0-未删除,1-已删除)',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='意见建议表';
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user