feat(admin): 添加用户管理相关文件

添加用户管理视图、API和状态管理文件
This commit is contained in:
张翔
2026-03-28 14:37:29 +08:00
commit 08ea5fbe98
1643 changed files with 255646 additions and 0 deletions
+140
View File
@@ -0,0 +1,140 @@
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_ROOT"
echo "========================================="
echo "测试环境部署脚本"
echo "========================================="
check_docker() {
if ! command -v docker &> /dev/null; then
echo "错误: Docker未安装"
exit 1
fi
if ! command -v docker-compose &> /dev/null; then
echo "错误: Docker Compose未安装"
exit 1
fi
echo "✓ Docker环境检查通过"
}
check_ports() {
local ports=("$@")
for port in "${ports[@]}"; do
if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null 2>&1; then
echo "警告: 端口 $port 已被占用"
fi
done
}
build_images() {
echo "构建Docker镜像..."
docker-compose -f docker-compose.test-new.yml --env-file .env.test build
echo "✓ Docker镜像构建完成"
}
start_services() {
echo "启动测试服务..."
docker-compose -f docker-compose.test-new.yml --env-file .env.test up -d
echo "✓ 测试服务启动完成"
}
wait_for_services() {
echo "等待服务启动..."
local max_attempts=60
local attempt=0
while [ $attempt -lt $max_attempts ]; do
local all_healthy=true
if ! docker-compose -f docker-compose.test-new.yml --env-file .env.test ps | grep -q "test-postgres.*healthy"; then
all_healthy=false
fi
if ! docker-compose -f docker-compose.test-new.yml --env-file .env.test ps | grep -q "test-redis.*healthy"; then
all_healthy=false
fi
if $all_healthy; then
echo "✓ 所有服务启动成功"
return 0
fi
attempt=$((attempt + 1))
echo "等待服务启动... ($attempt/$max_attempts)"
sleep 5
done
echo "错误: 服务启动超时"
docker-compose -f docker-compose.test-new.yml --env-file .env.test logs
exit 1
}
init_database() {
echo "初始化测试数据库..."
docker-compose -f docker-compose.test-new.yml --env-file .env.test exec -T test-postgres psql -U ${TEST_DB_USER:-test_user} -d ${TEST_DB_NAME:-everything_test} -f /docker-entrypoint-initdb.d/init-test-db.sql
echo "✓ 测试数据库初始化完成"
}
generate_test_data() {
echo "生成测试数据..."
python3 scripts/generate-test-data.py
echo "✓ 测试数据生成完成"
}
verify_deployment() {
echo "验证部署..."
echo "检查PostgreSQL..."
docker-compose -f docker-compose.test-new.yml --env-file .env.test exec -T test-postgres pg_isready -U ${TEST_DB_USER:-test_user}
echo "检查Redis..."
docker-compose -f docker-compose.test-new.yml --env-file .env.test exec -T test-redis redis-cli ping
echo "检查API Gateway..."
curl -f http://localhost:${TEST_API_PORT:-8081}/actuator/health
echo "检查Admin Backend..."
curl -f http://localhost:${TEST_ADMIN_PORT:-8082}/actuator/health
echo "✓ 部署验证完成"
}
main() {
check_docker
check_ports ${TEST_DB_PORT:-5433} ${TEST_REDIS_PORT:-6380} ${TEST_API_PORT:-8081} ${TEST_ADMIN_PORT:-8082}
build_images
start_services
wait_for_services
init_database
generate_test_data
verify_deployment
echo ""
echo "========================================="
echo "测试环境部署完成!"
echo "========================================="
echo ""
echo "服务访问地址:"
echo " API Gateway: http://localhost:${TEST_API_PORT:-8081}"
echo " Admin Backend: http://localhost:${TEST_ADMIN_PORT:-8082}"
echo " PostgreSQL: localhost:${TEST_DB_PORT:-5433}"
echo " Redis: localhost:${TEST_REDIS_PORT:-6380}"
echo ""
echo "管理命令:"
echo " 停止环境: ./scripts/setup-test-env.sh stop"
echo " 查看状态: ./scripts/setup-test-env.sh status"
echo " 查看日志: ./scripts/setup-test-env.sh logs"
echo " 清理环境: ./scripts/setup-test-env.sh clean"
echo ""
}
main "$@"