126 lines
4.4 KiB
Bash
Executable File
126 lines
4.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Integrated CRM Application Build Script - Web Application Specification Compliant
|
|
set -e
|
|
|
|
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
echo "🚀 Building Integrated CRM Application at: $APP_DIR"
|
|
|
|
# Step 1: Create required directories
|
|
mkdir -p "$APP_DIR/pkgs"
|
|
mkdir -p "$APP_DIR/logs"
|
|
mkdir -p "$APP_DIR/files"
|
|
|
|
# Step 2: Setup Python virtual environment and install core dependencies
|
|
echo "📦 Installing core dependencies..."
|
|
pip install git+https://git.opencomputing.cn/yumoqing/apppublic
|
|
pip install git+https://git.opencomputing.cn/yumoqing/sqlor
|
|
pip install git+https://git.opencomputing.cn/yumoqing/ahserver
|
|
pip install xls2ddl
|
|
|
|
# Step 3: Clone and install database modules
|
|
echo "📥 Cloning and installing database modules..."
|
|
|
|
# Foundation modules
|
|
cd "$APP_DIR/pkgs"
|
|
git clone https://git.opencomputing.cn/yumoqing/appbase.git
|
|
git clone https://git.opencomputing.cn/yumoqing/rbac.git
|
|
|
|
# Business modules
|
|
git clone https://git.opencomputing.cn/yumoqing/customer_management.git
|
|
git clone https://git.opencomputing.cn/yumoqing/opportunity_management.git
|
|
git clone https://git.opencomputing.cn/yumoqing/contract_management.git
|
|
git clone https://git.opencomputing.cn/yumoqing/accounting.git
|
|
git clone https://git.opencomputing.cn/yumoqing/workflow_approval.git
|
|
git clone https://git.opencomputing.cn/yumoqing/unified_dashboard.git
|
|
|
|
# Install all modules
|
|
for module in appbase rbac customer_management opportunity_management contract_management accounting workflow_approval unified_dashboard; do
|
|
echo "Installing $module..."
|
|
pip install -e "$APP_DIR/pkgs/$module"
|
|
done
|
|
|
|
# Step 4: Generate database DDL for all modules with models/
|
|
echo "📊 Generating database DDL..."
|
|
|
|
# Process each module that has models/
|
|
for module in appbase rbac customer_management opportunity_management contract_management accounting workflow_approval unified_dashboard; do
|
|
if [ -d "$APP_DIR/pkgs/$module/models" ]; then
|
|
echo "Processing models for $module..."
|
|
cd "$APP_DIR/pkgs/$module/models"
|
|
|
|
# Check for .xlsx files first
|
|
if ls *.xlsx >/dev/null 2>&1; then
|
|
xls2ddl mysql . > "$APP_DIR/pkgs/$module/mysql.ddl.sql"
|
|
# Check for .json files
|
|
elif ls *.json >/dev/null 2>&1; then
|
|
json2ddl mysql . > "$APP_DIR/pkgs/$module/mysql.ddl.sql"
|
|
fi
|
|
|
|
# Apply DDL if generated
|
|
if [ -f "$APP_DIR/pkgs/$module/mysql.ddl.sql" ] && [ -s "$APP_DIR/pkgs/$module/mysql.ddl.sql" ]; then
|
|
echo "Generated DDL for $module"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# Step 5: Generate CRUD UI for all modules with json/
|
|
echo "🎨 Generating CRUD UI..."
|
|
|
|
for module in appbase rbac customer_management opportunity_management contract_management accounting workflow_approval unified_dashboard; do
|
|
if [ -d "$APP_DIR/pkgs/$module/json" ] && [ -d "$APP_DIR/pkgs/$module/models" ]; then
|
|
echo "Generating UI for $module..."
|
|
cd "$APP_DIR/pkgs/$module/json"
|
|
xls2ui -m ../models -o ../wwwroot $module *.json
|
|
fi
|
|
done
|
|
|
|
# Step 6: Create symbolic links for wwwroot
|
|
echo "🔗 Creating symbolic links..."
|
|
|
|
# Link all module wwwroot directories
|
|
for module in appbase rbac customer_management opportunity_management contract_management accounting workflow_approval unified_dashboard; do
|
|
if [ -d "$APP_DIR/pkgs/$module/wwwroot" ]; then
|
|
ln -sf "$APP_DIR/pkgs/$module/wwwroot" "$APP_DIR/wwwroot/$module"
|
|
fi
|
|
done
|
|
|
|
# Step 7: Setup Bricks framework
|
|
echo "🏗️ Setting up Bricks framework..."
|
|
|
|
if [ ! -d "$APP_DIR/pkgs/bricks" ]; then
|
|
cd "$APP_DIR/pkgs"
|
|
git clone https://git.opencomputing.cn/yumoqing/bricks.git
|
|
fi
|
|
|
|
# Build bricks if needed
|
|
if [ -f "$APP_DIR/pkgs/bricks/build.sh" ]; then
|
|
cd "$APP_DIR/pkgs/bricks" && ./build.sh
|
|
fi
|
|
|
|
# Link bricks dist directory
|
|
ln -sf "$APP_DIR/pkgs/bricks/dist" "$APP_DIR/wwwroot/bricks"
|
|
|
|
# Step 8: Create systemd service (optional for development)
|
|
echo "⚙️ Creating service scripts..."
|
|
|
|
cat > "$APP_DIR/start.sh" << 'EOF'
|
|
#!/bin/bash
|
|
source .env
|
|
python3 app/integrated_crm_app.py --port 8080 --root wwwroot/
|
|
EOF
|
|
|
|
cat > "$APP_DIR/stop.sh" << 'EOF'
|
|
#!/bin/bash
|
|
pkill -f "integrated_crm_app.py"
|
|
EOF
|
|
|
|
chmod +x "$APP_DIR/start.sh" "$APP_DIR/stop.sh"
|
|
|
|
echo ""
|
|
echo "✅ Integrated CRM Application build completed!"
|
|
echo ""
|
|
echo "📋 Next steps:"
|
|
echo "1. Update conf/config.json with your database credentials"
|
|
echo "2. Source environment: source .env"
|
|
echo "3. Start application: ./start.sh"
|
|
echo "4. Access at: http://localhost:8080/main/login.ui" |