Compare commits
21 Commits
3352bc82d9
...
f4bb4b27a2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4bb4b27a2 | ||
|
|
10d39ac0c4 | ||
|
|
6687d0b5ff | ||
|
|
8eb42c9364 | ||
|
|
658149639f | ||
|
|
3df8767c47 | ||
| 5e6e9a8787 | |||
| 5005d8ac2a | |||
| 0eb5128b6f | |||
| acf4c6a307 | |||
| 3561cd098a | |||
| a2ed179fbb | |||
| faa655bc9d | |||
| b0bf6dc338 | |||
| 316702a8cf | |||
| 8482a88870 | |||
| eda8e74b1a | |||
| 8557335cd2 | |||
| a16cb37c7f | |||
| dbf6c45ec8 | |||
| d38a439e3c |
147
.gitea/workflows/prod_build_commit.yaml
Normal file
147
.gitea/workflows/prod_build_commit.yaml
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
name: git commit 控制 连卡佛 back-java prod 分支构建部署
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- prod/release_1.0
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: "contains(github.event.head_commit.message, '[run build]')"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
REMOTE_DEPLOY_PATH: /workspace/workspace_lanecrawford/back
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 1.检出代码
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: prod/release_1.0
|
||||||
|
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '21'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: 2.设置JAVA Maven 环境
|
||||||
|
run: |
|
||||||
|
# 适配act的root用户和Gitea Runner普通用户
|
||||||
|
SUDO=""
|
||||||
|
[ "$(id -u)" != "0" ] && SUDO="sudo"
|
||||||
|
|
||||||
|
# 安装依赖
|
||||||
|
$SUDO apt update && $SUDO apt install -y wget tar --no-install-recommends
|
||||||
|
|
||||||
|
# 下载并安装Maven
|
||||||
|
MAVEN_VERSION="3.6.3"
|
||||||
|
MAVEN_TAR="apache-maven-${MAVEN_VERSION}-bin.tar.gz"
|
||||||
|
MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/${MAVEN_TAR}"
|
||||||
|
wget --no-verbose -O /tmp/${MAVEN_TAR} ${MAVEN_URL}
|
||||||
|
|
||||||
|
# 解压+软链接
|
||||||
|
$SUDO tar -xzf /tmp/${MAVEN_TAR} -C /usr/local/
|
||||||
|
$SUDO ln -sf /usr/local/apache-maven-${MAVEN_VERSION} /usr/local/maven
|
||||||
|
|
||||||
|
# 配置PATH
|
||||||
|
echo "/usr/local/maven/bin" >> $GITHUB_PATH
|
||||||
|
export PATH="/usr/local/maven/bin:$PATH"
|
||||||
|
|
||||||
|
# 验证
|
||||||
|
mvn -v
|
||||||
|
|
||||||
|
- name: 2.构建jar包
|
||||||
|
run:
|
||||||
|
mvn -B clean package -DskipTests --file pom.xml
|
||||||
|
|
||||||
|
- name: 3.检查 Runner 本地文件
|
||||||
|
run: |
|
||||||
|
echo "当前目录:$(pwd)"
|
||||||
|
echo "target 目录内容:"
|
||||||
|
ls -la ./target/
|
||||||
|
|
||||||
|
# 容错:处理通配符无匹配的情况
|
||||||
|
JAR_FILE=$(ls ./target/*.jar 2>/dev/null | head -n1)
|
||||||
|
if [ -z "$JAR_FILE" ] || [ ! -f "$JAR_FILE" ]; then
|
||||||
|
echo "❌ Runner 本地无有效 JAR 包!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查Docker配置文件
|
||||||
|
for FILE in Dockerfile docker-compose.yml; do
|
||||||
|
if [ ! -f "./$FILE" ]; then
|
||||||
|
echo "❌ 缺失文件:$FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "✅ 本地文件校验通过!"
|
||||||
|
|
||||||
|
- name: 4. 同步文件到远程服务器
|
||||||
|
uses: appleboy/scp-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
source: "./target/*.jar,./Dockerfile,./docker-compose.yml"
|
||||||
|
target: ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
ssh_options: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
||||||
|
strip_components: 0
|
||||||
|
|
||||||
|
- name: 5. 验证远程文件
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
echo "===== 远程部署目录文件列表 ====="
|
||||||
|
ls -la ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
|
||||||
|
# 容错:检查JAR包
|
||||||
|
REMOTE_JAR=$(ls ${{ env.REMOTE_DEPLOY_PATH }}/target/*.jar 2>/dev/null | head -n1)
|
||||||
|
if [ -z "$REMOTE_JAR" ] || [ ! -f "$REMOTE_JAR" ]; then
|
||||||
|
echo "❌ 远程服务器无有效 JAR 包!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查Docker文件
|
||||||
|
for FILE in Dockerfile docker-compose.yml; do
|
||||||
|
if [ ! -f "${{ env.REMOTE_DEPLOY_PATH }}/$FILE" ]; then
|
||||||
|
echo "❌ 远程缺失文件:$FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "✅ 远程文件校验通过!"
|
||||||
|
|
||||||
|
- name: 6. 部署和运行服务
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
echo "===== 开始部署服务 ====="
|
||||||
|
cd ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
|
||||||
|
# 容错:停止旧容器(不存在则跳过)
|
||||||
|
echo "停止旧容器..."
|
||||||
|
docker compose down || true
|
||||||
|
|
||||||
|
# 清理无效镜像(可选,释放空间)
|
||||||
|
docker system prune -f
|
||||||
|
|
||||||
|
# 构建并启动新容器
|
||||||
|
echo "构建Docker镜像..."
|
||||||
|
docker compose build --no-cache
|
||||||
|
echo "启动服务..."
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# 验证服务状态
|
||||||
|
echo "验证容器状态..."
|
||||||
|
docker compose ps
|
||||||
|
echo "✅ 部署完成!"
|
||||||
143
.gitea/workflows/prod_build_manual.yaml
Normal file
143
.gitea/workflows/prod_build_manual.yaml
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
name: 手动 连卡佛 back-java prod 分支构建部署
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
REMOTE_DEPLOY_PATH: /workspace/workspace_lanecrawford/back
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 1.检出代码
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: prod/release_1.0
|
||||||
|
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '21'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: 2.设置JAVA Maven 环境
|
||||||
|
run: |
|
||||||
|
# 适配act的root用户和Gitea Runner普通用户
|
||||||
|
SUDO=""
|
||||||
|
[ "$(id -u)" != "0" ] && SUDO="sudo"
|
||||||
|
|
||||||
|
# 安装依赖
|
||||||
|
$SUDO apt update && $SUDO apt install -y wget tar --no-install-recommends
|
||||||
|
|
||||||
|
# 下载并安装Maven
|
||||||
|
MAVEN_VERSION="3.6.3"
|
||||||
|
MAVEN_TAR="apache-maven-${MAVEN_VERSION}-bin.tar.gz"
|
||||||
|
MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/${MAVEN_TAR}"
|
||||||
|
wget --no-verbose -O /tmp/${MAVEN_TAR} ${MAVEN_URL}
|
||||||
|
|
||||||
|
# 解压+软链接
|
||||||
|
$SUDO tar -xzf /tmp/${MAVEN_TAR} -C /usr/local/
|
||||||
|
$SUDO ln -sf /usr/local/apache-maven-${MAVEN_VERSION} /usr/local/maven
|
||||||
|
|
||||||
|
# 配置PATH
|
||||||
|
echo "/usr/local/maven/bin" >> $GITHUB_PATH
|
||||||
|
export PATH="/usr/local/maven/bin:$PATH"
|
||||||
|
|
||||||
|
# 验证
|
||||||
|
mvn -v
|
||||||
|
|
||||||
|
- name: 2.构建jar包
|
||||||
|
run:
|
||||||
|
mvn -B clean package -DskipTests --file pom.xml
|
||||||
|
|
||||||
|
- name: 3.检查 Runner 本地文件
|
||||||
|
run: |
|
||||||
|
echo "当前目录:$(pwd)"
|
||||||
|
echo "target 目录内容:"
|
||||||
|
ls -la ./target/
|
||||||
|
|
||||||
|
# 容错:处理通配符无匹配的情况
|
||||||
|
JAR_FILE=$(ls ./target/*.jar 2>/dev/null | head -n1)
|
||||||
|
if [ -z "$JAR_FILE" ] || [ ! -f "$JAR_FILE" ]; then
|
||||||
|
echo "❌ Runner 本地无有效 JAR 包!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查Docker配置文件
|
||||||
|
for FILE in Dockerfile docker-compose.yml; do
|
||||||
|
if [ ! -f "./$FILE" ]; then
|
||||||
|
echo "❌ 缺失文件:$FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "✅ 本地文件校验通过!"
|
||||||
|
|
||||||
|
- name: 4. 同步文件到远程服务器
|
||||||
|
uses: appleboy/scp-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
source: "./target/*.jar,./Dockerfile,./docker-compose.yml"
|
||||||
|
target: ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
ssh_options: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
||||||
|
strip_components: 0
|
||||||
|
|
||||||
|
- name: 5. 验证远程文件
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
echo "===== 远程部署目录文件列表 ====="
|
||||||
|
ls -la ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
|
||||||
|
# 容错:检查JAR包
|
||||||
|
REMOTE_JAR=$(ls ${{ env.REMOTE_DEPLOY_PATH }}/target/*.jar 2>/dev/null | head -n1)
|
||||||
|
if [ -z "$REMOTE_JAR" ] || [ ! -f "$REMOTE_JAR" ]; then
|
||||||
|
echo "❌ 远程服务器无有效 JAR 包!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查Docker文件
|
||||||
|
for FILE in Dockerfile docker-compose.yml; do
|
||||||
|
if [ ! -f "${{ env.REMOTE_DEPLOY_PATH }}/$FILE" ]; then
|
||||||
|
echo "❌ 远程缺失文件:$FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "✅ 远程文件校验通过!"
|
||||||
|
|
||||||
|
- name: 6. 部署和运行服务
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
echo "===== 开始部署服务 ====="
|
||||||
|
cd ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
|
||||||
|
# 容错:停止旧容器(不存在则跳过)
|
||||||
|
echo "停止旧容器..."
|
||||||
|
docker compose down || true
|
||||||
|
|
||||||
|
# 清理无效镜像(可选,释放空间)
|
||||||
|
docker system prune -f
|
||||||
|
|
||||||
|
# 构建并启动新容器
|
||||||
|
echo "构建Docker镜像..."
|
||||||
|
docker compose build --no-cache
|
||||||
|
echo "启动服务..."
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# 验证服务状态
|
||||||
|
echo "验证容器状态..."
|
||||||
|
docker compose ps
|
||||||
|
echo "✅ 部署完成!"
|
||||||
146
.gitea/workflows/prod_build_schedule.yaml
Normal file
146
.gitea/workflows/prod_build_schedule.yaml
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
name: 定时 连卡佛 back-java prod 分支构建部署
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# cron为UTC时区,构建时间=部署时间-8小时 {*分 (-8)时 *日 *月 *周} ---
|
||||||
|
# 示例: 1月1日22点22分触发构建 cron写作 - '22 14 1 1 *'
|
||||||
|
- cron: '22 14 1 1 *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
REMOTE_DEPLOY_PATH: /workspace/workspace_lanecrawford/back
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 1.检出代码
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: prod/release_1.0
|
||||||
|
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '21'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: 2.设置JAVA Maven 环境
|
||||||
|
run: |
|
||||||
|
# 适配act的root用户和Gitea Runner普通用户
|
||||||
|
SUDO=""
|
||||||
|
[ "$(id -u)" != "0" ] && SUDO="sudo"
|
||||||
|
|
||||||
|
# 安装依赖
|
||||||
|
$SUDO apt update && $SUDO apt install -y wget tar --no-install-recommends
|
||||||
|
|
||||||
|
# 下载并安装Maven
|
||||||
|
MAVEN_VERSION="3.6.3"
|
||||||
|
MAVEN_TAR="apache-maven-${MAVEN_VERSION}-bin.tar.gz"
|
||||||
|
MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/${MAVEN_TAR}"
|
||||||
|
wget --no-verbose -O /tmp/${MAVEN_TAR} ${MAVEN_URL}
|
||||||
|
|
||||||
|
# 解压+软链接
|
||||||
|
$SUDO tar -xzf /tmp/${MAVEN_TAR} -C /usr/local/
|
||||||
|
$SUDO ln -sf /usr/local/apache-maven-${MAVEN_VERSION} /usr/local/maven
|
||||||
|
|
||||||
|
# 配置PATH
|
||||||
|
echo "/usr/local/maven/bin" >> $GITHUB_PATH
|
||||||
|
export PATH="/usr/local/maven/bin:$PATH"
|
||||||
|
|
||||||
|
# 验证
|
||||||
|
mvn -v
|
||||||
|
|
||||||
|
- name: 2.构建jar包
|
||||||
|
run:
|
||||||
|
mvn -B clean package -DskipTests --file pom.xml
|
||||||
|
|
||||||
|
- name: 3.检查 Runner 本地文件
|
||||||
|
run: |
|
||||||
|
echo "当前目录:$(pwd)"
|
||||||
|
echo "target 目录内容:"
|
||||||
|
ls -la ./target/
|
||||||
|
|
||||||
|
# 容错:处理通配符无匹配的情况
|
||||||
|
JAR_FILE=$(ls ./target/*.jar 2>/dev/null | head -n1)
|
||||||
|
if [ -z "$JAR_FILE" ] || [ ! -f "$JAR_FILE" ]; then
|
||||||
|
echo "❌ Runner 本地无有效 JAR 包!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查Docker配置文件
|
||||||
|
for FILE in Dockerfile docker-compose.yml; do
|
||||||
|
if [ ! -f "./$FILE" ]; then
|
||||||
|
echo "❌ 缺失文件:$FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "✅ 本地文件校验通过!"
|
||||||
|
|
||||||
|
- name: 4. 同步文件到远程服务器
|
||||||
|
uses: appleboy/scp-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
source: "./target/*.jar,./Dockerfile,./docker-compose.yml"
|
||||||
|
target: ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
ssh_options: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
||||||
|
strip_components: 0
|
||||||
|
|
||||||
|
- name: 5. 验证远程文件
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
echo "===== 远程部署目录文件列表 ====="
|
||||||
|
ls -la ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
|
||||||
|
# 容错:检查JAR包
|
||||||
|
REMOTE_JAR=$(ls ${{ env.REMOTE_DEPLOY_PATH }}/target/*.jar 2>/dev/null | head -n1)
|
||||||
|
if [ -z "$REMOTE_JAR" ] || [ ! -f "$REMOTE_JAR" ]; then
|
||||||
|
echo "❌ 远程服务器无有效 JAR 包!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查Docker文件
|
||||||
|
for FILE in Dockerfile docker-compose.yml; do
|
||||||
|
if [ ! -f "${{ env.REMOTE_DEPLOY_PATH }}/$FILE" ]; then
|
||||||
|
echo "❌ 远程缺失文件:$FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "✅ 远程文件校验通过!"
|
||||||
|
|
||||||
|
- name: 6. 部署和运行服务
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
echo "===== 开始部署服务 ====="
|
||||||
|
cd ${{ env.REMOTE_DEPLOY_PATH }}
|
||||||
|
|
||||||
|
# 容错:停止旧容器(不存在则跳过)
|
||||||
|
echo "停止旧容器..."
|
||||||
|
docker compose down || true
|
||||||
|
|
||||||
|
# 清理无效镜像(可选,释放空间)
|
||||||
|
docker system prune -f
|
||||||
|
|
||||||
|
# 构建并启动新容器
|
||||||
|
echo "构建Docker镜像..."
|
||||||
|
docker compose build --no-cache
|
||||||
|
echo "启动服务..."
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# 验证服务状态
|
||||||
|
echo "验证容器状态..."
|
||||||
|
docker compose ps
|
||||||
|
echo "✅ 部署完成!"
|
||||||
@@ -6,4 +6,4 @@ services:
|
|||||||
# 日志目录映射
|
# 日志目录映射
|
||||||
- ./log:/log
|
- ./log:/log
|
||||||
ports:
|
ports:
|
||||||
- '10010:8080'
|
- '10095:8080'
|
||||||
@@ -28,8 +28,8 @@ public class CustomerController {
|
|||||||
description = "验证顾客身份并创建入店记录,如果是新顾客则自动注册到系统中。"
|
description = "验证顾客身份并创建入店记录,如果是新顾客则自动注册到系统中。"
|
||||||
)
|
)
|
||||||
@GetMapping("/checkIn")
|
@GetMapping("/checkIn")
|
||||||
public ApiResponse<CustomerCheckInVO> customerCheckIn(@RequestParam String name, @RequestParam String email) {
|
public ApiResponse<CustomerCheckInVO> customerCheckIn(@RequestParam String vipId) {
|
||||||
return ApiResponse.success(customerService.customerCheckIn(name, email));
|
return ApiResponse.success(customerService.customerCheckIn(vipId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/getAllCustomer")
|
@PostMapping("/getAllCustomer")
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class TryOnEffectController {
|
|||||||
@GetMapping("/getHistoricals")
|
@GetMapping("/getHistoricals")
|
||||||
public ApiResponse<List<? extends BaseVO>> getHistoricals(
|
public ApiResponse<List<? extends BaseVO>> getHistoricals(
|
||||||
@Parameter(description = "服装ID", required = true)
|
@Parameter(description = "服装ID", required = true)
|
||||||
@RequestBody HistoricalDTO historicalDTO) {
|
@ModelAttribute HistoricalDTO historicalDTO) {
|
||||||
if (CommonConstants.OUTFIT.equals(historicalDTO.getType())){
|
if (CommonConstants.OUTFIT.equals(historicalDTO.getType())){
|
||||||
List<OutfitHisVO> outfitHisVOS = tryOnEffectService.getOutfitHistoricals(historicalDTO);
|
List<OutfitHisVO> outfitHisVOS = tryOnEffectService.getOutfitHistoricals(historicalDTO);
|
||||||
return ApiResponse.success(outfitHisVOS);
|
return ApiResponse.success(outfitHisVOS);
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import lombok.Data;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class HistoricalDTO {
|
public class HistoricalDTO {
|
||||||
|
|
||||||
|
@Schema(description = "顾客ID",example = "1")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
@Schema(description = "进店记录ID",example = "1")
|
@Schema(description = "进店记录ID",example = "1")
|
||||||
private Long visitRecordId;
|
private Long visitRecordId;
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ import java.time.LocalDateTime;
|
|||||||
@TableName("customers")
|
@TableName("customers")
|
||||||
public class Customer extends BaseEntity {
|
public class Customer extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vip ID
|
||||||
|
*/
|
||||||
|
@TableField("vip_id")
|
||||||
|
private String vipId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 顾客姓名
|
* 顾客姓名
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
*/
|
*/
|
||||||
public interface CustomerService extends IService<Customer> {
|
public interface CustomerService extends IService<Customer> {
|
||||||
|
|
||||||
CustomerCheckInVO customerCheckIn(String name, String email);
|
CustomerCheckInVO customerCheckIn(String vipId);
|
||||||
|
|
||||||
IPage<CustomerVO> getAllCustomer(BaseRequest request);
|
IPage<CustomerVO> getAllCustomer(BaseRequest request);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.aida.lanecarford.common.security.context.UserContext;
|
|||||||
import com.aida.lanecarford.dto.BaseRequest;
|
import com.aida.lanecarford.dto.BaseRequest;
|
||||||
import com.aida.lanecarford.entity.Customer;
|
import com.aida.lanecarford.entity.Customer;
|
||||||
import com.aida.lanecarford.entity.VisitRecord;
|
import com.aida.lanecarford.entity.VisitRecord;
|
||||||
|
import com.aida.lanecarford.exception.BusinessException;
|
||||||
import com.aida.lanecarford.mapper.CustomerMapper;
|
import com.aida.lanecarford.mapper.CustomerMapper;
|
||||||
import com.aida.lanecarford.service.CustomerService;
|
import com.aida.lanecarford.service.CustomerService;
|
||||||
import com.aida.lanecarford.service.VisitRecordService;
|
import com.aida.lanecarford.service.VisitRecordService;
|
||||||
@@ -14,6 +15,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import io.netty.util.internal.StringUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -30,10 +32,13 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||||||
private final VisitRecordService visitRecordService;
|
private final VisitRecordService visitRecordService;
|
||||||
|
|
||||||
// 选择顾客登录并添加入店记录
|
// 选择顾客登录并添加入店记录
|
||||||
public CustomerCheckInVO customerCheckIn(String name, String email) {
|
public CustomerCheckInVO customerCheckIn(String vipId) {
|
||||||
|
if (StringUtil.isNullOrEmpty(vipId)) {
|
||||||
|
throw new BusinessException("Please enter a VIP ID.");
|
||||||
|
}
|
||||||
// 1. 判断当前顾客信息在数据库中是否有存储
|
// 1. 判断当前顾客信息在数据库中是否有存储
|
||||||
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(Customer::getName, name).eq(Customer::getEmail, email);
|
queryWrapper.eq(Customer::getVipId, vipId);
|
||||||
|
|
||||||
Customer customer = getOne(queryWrapper);
|
Customer customer = getOne(queryWrapper);
|
||||||
|
|
||||||
@@ -45,8 +50,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||||||
// 如果找到了,则添加到数据库
|
// 如果找到了,则添加到数据库
|
||||||
// 3. 添加当前顾客到本系统数据库
|
// 3. 添加当前顾客到本系统数据库
|
||||||
customer = new Customer();
|
customer = new Customer();
|
||||||
customer.setName(name);
|
customer.setVipId(vipId);
|
||||||
customer.setEmail(email);
|
|
||||||
customer.setCreatedTime(LocalDateTime.now());
|
customer.setCreatedTime(LocalDateTime.now());
|
||||||
|
|
||||||
save(customer);
|
save(customer);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
|
|||||||
|
|
||||||
StylistPathEnum stylistPathEnum = StylistPathEnum.of(requestOutfitDTO.getStylist());
|
StylistPathEnum stylistPathEnum = StylistPathEnum.of(requestOutfitDTO.getStylist());
|
||||||
Map<String, Object> params = setRequestOutfitParams(requestOutfitDTO.getCustomerId(), requestOutfitDTO.getNum(),
|
Map<String, Object> params = setRequestOutfitParams(requestOutfitDTO.getCustomerId(), requestOutfitDTO.getNum(),
|
||||||
stylistPathEnum.getPath(), requestOutfitDTO.getGender(), requestOutfitDTO.getSessionId());
|
stylistPathEnum.getName(), requestOutfitDTO.getGender(), requestOutfitDTO.getSessionId());
|
||||||
|
|
||||||
OutfitRequest outfitRequest = new OutfitRequest();
|
OutfitRequest outfitRequest = new OutfitRequest();
|
||||||
outfitRequest.setCustomerId(requestOutfitDTO.getCustomerId());
|
outfitRequest.setCustomerId(requestOutfitDTO.getCustomerId());
|
||||||
@@ -102,8 +102,9 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
|
|||||||
params.put("stylist_path", stylistPath);
|
params.put("stylist_path", stylistPath);
|
||||||
params.put("callback_url", webhookDomain);
|
params.put("callback_url", webhookDomain);
|
||||||
params.put("gender", gender);
|
params.put("gender", gender);
|
||||||
params.put("max_len", 9);
|
// params.put("max_len", 5);
|
||||||
params.put("session_id", sessionId);
|
params.put("session_id", sessionId);
|
||||||
|
params.put("batch_sources", Collections.singleton("2025_q4"));
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*
|
*
|
||||||
* @author AI Assistant
|
* @author AI Assistant
|
||||||
* @since 2024-01-01
|
* @since 2024-01-01
|
||||||
/**
|
* /**
|
||||||
* 试穿效果服务实现类
|
* 试穿效果服务实现类
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@@ -186,6 +186,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加意见建议
|
* 添加意见建议
|
||||||
|
*
|
||||||
* @param suggestion 意见建议实体
|
* @param suggestion 意见建议实体
|
||||||
* @return 是否添加成功
|
* @return 是否添加成功
|
||||||
*/
|
*/
|
||||||
@@ -260,11 +261,12 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
@Override
|
@Override
|
||||||
public List<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO) {
|
public List<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO) {
|
||||||
LambdaQueryWrapper<TryOnEffect> tryOnEffectLambdaQueryWrapper = new LambdaQueryWrapper<TryOnEffect>()
|
LambdaQueryWrapper<TryOnEffect> tryOnEffectLambdaQueryWrapper = new LambdaQueryWrapper<TryOnEffect>()
|
||||||
|
.eq(TryOnEffect::getCustomerId, historicalDTO.getCustomerId())
|
||||||
.orderByDesc(TryOnEffect::getCreatedTime);
|
.orderByDesc(TryOnEffect::getCreatedTime);
|
||||||
if (historicalDTO.getVisitRecordId() != null) {
|
if (historicalDTO.getVisitRecordId() != null) {
|
||||||
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getVisitRecordId, historicalDTO.getVisitRecordId());
|
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getVisitRecordId, historicalDTO.getVisitRecordId());
|
||||||
}
|
}
|
||||||
if (historicalDTO.getIsLibrary() != null||historicalDTO.getIsLibrary()){
|
if (historicalDTO.getIsLibrary() != null && historicalDTO.getIsLibrary()) {
|
||||||
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsFavorite, 1);
|
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsFavorite, 1);
|
||||||
}
|
}
|
||||||
if (CommonConstants.TRYON.equals(historicalDTO.getType())) {
|
if (CommonConstants.TRYON.equals(historicalDTO.getType())) {
|
||||||
@@ -301,11 +303,14 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO) {
|
public List<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO) {
|
||||||
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<Style>().orderByDesc(Style::getCreatedTime);
|
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<Style>()
|
||||||
|
.eq(Style::getCustomerId, historicalDTO.getCustomerId())
|
||||||
|
.eq(Style::getGenerationStatus, 1)
|
||||||
|
.orderByDesc(Style::getCreatedTime);
|
||||||
if (historicalDTO.getVisitRecordId() != null) {
|
if (historicalDTO.getVisitRecordId() != null) {
|
||||||
styleLambdaQueryWrapper.eq(Style::getVisitRecordId, historicalDTO.getVisitRecordId());
|
styleLambdaQueryWrapper.eq(Style::getVisitRecordId, historicalDTO.getVisitRecordId());
|
||||||
}
|
}
|
||||||
if (historicalDTO.getIsLibrary() != null||historicalDTO.getIsLibrary()){
|
if (historicalDTO.getIsLibrary() != null && historicalDTO.getIsLibrary()) {
|
||||||
styleLambdaQueryWrapper.eq(Style::getIsFavorite, 1);
|
styleLambdaQueryWrapper.eq(Style::getIsFavorite, 1);
|
||||||
}
|
}
|
||||||
List<Style> styles = styleService.list(styleLambdaQueryWrapper);
|
List<Style> styles = styleService.list(styleLambdaQueryWrapper);
|
||||||
@@ -684,6 +689,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用换脸API
|
* 调用换脸API
|
||||||
|
*
|
||||||
* @param imageUrls 图片URL列表,第一个为源图片,第二个为目标图片
|
* @param imageUrls 图片URL列表,第一个为源图片,第二个为目标图片
|
||||||
* @return 换脸后的图片URL
|
* @return 换脸后的图片URL
|
||||||
*/
|
*/
|
||||||
@@ -801,7 +807,6 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
log.info("换脸成功,图片路径: {}", imagePath);
|
log.info("换脸成功,图片路径: {}", imagePath);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 下载图片并上传到MinIO
|
// 下载图片并上传到MinIO
|
||||||
return imagePath;
|
return imagePath;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ CREATE TABLE `styles` (
|
|||||||
`style_image_url` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '风格图片URL',
|
`style_image_url` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '风格图片URL',
|
||||||
`python_request_id` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Python请求ID',
|
`python_request_id` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Python请求ID',
|
||||||
`generation_status` tinyint DEFAULT '0' COMMENT '生成状态(0-处理中,1-已完成,2-失败)',
|
`generation_status` tinyint DEFAULT '0' COMMENT '生成状态(0-处理中,1-已完成,2-失败)',
|
||||||
`is_favorite` tinyint DEFAULT '0' COMMENT '是否喜欢(0-否,1-是)',
|
`is_favorite` tinyint NOT NULL DEFAULT '0' COMMENT '是否喜欢(0-否,1-是)',
|
||||||
`items` json DEFAULT NULL COMMENT '单品唯一标识',
|
`items` json DEFAULT NULL COMMENT '单品唯一标识',
|
||||||
`error_message` text COLLATE utf8mb4_unicode_ci COMMENT '错误信息',
|
`error_message` text COLLATE utf8mb4_unicode_ci COMMENT '错误信息',
|
||||||
`created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
|||||||
Reference in New Issue
Block a user