refactor(backend): 重构后端代码 wave 3

This commit is contained in:
sophie committed 2026-07-29 19:12:49 +08:00
1 parent affe139bf9
commit 8415653365
97 files changed
+4673 -6164

No files matched your search

+9 -7
View File
@@ -32,7 +32,7 @@ ENV_FILE="${ROOT_DIR}/.env.${ENV_NAME}"
SHARED_ENV_FILE="${ROOT_DIR}/.env.shared"
ORACLE_CLIENT_DIR="${ROOT_DIR}/oracle_client"
BACKEND_DOCKERFILE="${ROOT_DIR}/backend/Dockerfile"
SCHEMA_DOC_PATH="${ROOT_DIR}/docs/(表+字段).md"
SCHEMA_DOC_PATH="${ROOT_DIR}/docs/integrations/erp/text2sql_schema.md"
ROOT_DOCKERIGNORE="${ROOT_DIR}/.dockerignore"
check_oracle_client() {
@@ -63,7 +63,7 @@ check_backend_build_inputs() {
if [[ ! -f "${SCHEMA_DOC_PATH}" ]]; then
echo "Missing Text2SQL schema doc: ${SCHEMA_DOC_PATH}"
echo "Please ensure docs/(表+字段).md exists in the repository root before building hxops-backend."
echo "Please ensure docs/integrations/erp/text2sql_schema.md exists before building hxops-backend."
exit 1
fi
@@ -75,18 +75,20 @@ check_backend_build_inputs() {
exit 1
fi
if ! grep -Fq 'COPY docs/(表+字段).md /app/docs/(表+字段).md' "${BACKEND_DOCKERFILE}"; then
if ! grep -Fq 'COPY docs/integrations/erp/text2sql_schema.md /app/docs/integrations/erp/text2sql_schema.md' "${BACKEND_DOCKERFILE}"; then
echo "Invalid backend Dockerfile: schema doc is not copied into the image."
echo "Expected line:"
echo " COPY docs/(表+字段).md /app/docs/(表+字段).md"
echo " COPY docs/integrations/erp/text2sql_schema.md /app/docs/integrations/erp/text2sql_schema.md"
exit 1
fi
if [[ -f "${ROOT_DOCKERIGNORE}" ]] && grep -Eq '^(docs|docs/\*)$' "${ROOT_DOCKERIGNORE}"; then
if ! grep -Fxq '!docs/(表+字段).md' "${ROOT_DOCKERIGNORE}"; then
echo "Invalid .dockerignore: docs is excluded but docs/(表+字段).md is not re-included."
if ! grep -Fxq '!docs/integrations/erp/text2sql_schema.md' "${ROOT_DOCKERIGNORE}"; then
echo "Invalid .dockerignore: docs is excluded but the Text2SQL schema is not re-included."
echo "Please add the following line to ${ROOT_DOCKERIGNORE}:"
echo " !docs/(表+字段).md"
echo " !docs/integrations/"
echo " !docs/integrations/erp/"
echo " !docs/integrations/erp/text2sql_schema.md"
exit 1
fi
fi
-38
View File
@@ -1,38 +0,0 @@
#!/bin/bash
set -e
# Configuration
SERVER_USER="ai30"
SERVER_IP="192.168.100.230"
REMOTE_DIR="/data/ai-platform/hxops"
BACKEND_CONTAINER="hxops-backend"
echo "=== Starting Remote Server Initialization ==="
echo "Target: $SERVER_USER@$SERVER_IP"
# 1. Check local files exist
if [ ! -f "backend/init_db.py" ] || [ ! -f "backend/seed_production.py" ]; then
echo "Error: Required files not found locally (backend/init_db.py or backend/seed_production.py)"
exit 1
fi
# 2. Upload updated scripts to server
echo ">>> Uploading initialization scripts..."
scp backend/init_db.py $SERVER_USER@$SERVER_IP:$REMOTE_DIR/backend/
scp backend/seed_production.py $SERVER_USER@$SERVER_IP:$REMOTE_DIR/backend/
# 3. Execute remote commands
echo ">>> Executing remote initialization..."
ssh $SERVER_USER@$SERVER_IP "cd $REMOTE_DIR && \
echo '--- 1. Initializing Database (Create DB if missing) ---' && \
docker-compose exec -T $BACKEND_CONTAINER python3 init_db.py && \
echo '--- 2. Running Migrations (Create Tables) ---' && \
docker-compose exec -T $BACKEND_CONTAINER flask db upgrade && \
echo '--- 3. Seeding Data (Admin User & Languages) ---' && \
docker-compose exec -T $BACKEND_CONTAINER python3 seed_production.py"
echo "=== Initialization Complete! ==="
echo "You can now login with:"
echo " Username: admin"
echo " Password: admin"
echo "Please change the password immediately after login."