Initial commit: hulai admin API backend

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
刘涛
2026-03-22 22:01:23 +08:00
共同撰写人 Claude Sonnet 4.6
当前提交 8c0a5f489d
共修改 114 个文件,包含 7619 行新增和 0 行删除
+1
查看文件
@@ -0,0 +1 @@
Generic single-database configuration.
+67
查看文件
@@ -0,0 +1,67 @@
from logging.config import fileConfig
import os
import sys
from sqlalchemy import engine_from_config
from sqlalchemy import pool
from alembic import context
# 确保项目根目录在 Python 路径中
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None:
fileConfig(config.config_file_name)
# 导入所有模型,使 autogenerate 能检测到所有表
from app.database import Base
import app.models # noqa: F401 - 导入所有模型
target_metadata = Base.metadata
# 从环境变量读取数据库 URL
from app.config import settings
config.set_main_option("sqlalchemy.url", settings.DATABASE_URL)
def run_migrations_offline() -> None:
"""Run migrations in 'offline' mode."""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online() -> None:
"""Run migrations in 'online' mode."""
connectable = engine_from_config(
config.get_section(config.config_ini_section, {}),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(
connection=connection, target_metadata=target_metadata
)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
+26
查看文件
@@ -0,0 +1,26 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision: str = ${repr(up_revision)}
down_revision: Union[str, None] = ${repr(down_revision)}
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
def upgrade() -> None:
${upgrades if upgrades else "pass"}
def downgrade() -> None:
${downgrades if downgrades else "pass"}
@@ -0,0 +1,137 @@
"""add blog stories news pricing qualifications partners calendar
Revision ID: 2bcfcc62f578
Revises:
Create Date: 2026-03-20 20:35:59.466044
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '2bcfcc62f578'
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('blog_posts',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('title', sa.String(length=200), nullable=False),
sa.Column('slug', sa.String(length=200), nullable=False),
sa.Column('cover_image', sa.String(length=500), nullable=True),
sa.Column('summary', sa.Text(), nullable=True),
sa.Column('content', sa.Text(), nullable=True),
sa.Column('author', sa.String(length=100), nullable=True),
sa.Column('category', sa.String(length=100), nullable=True),
sa.Column('tags', sa.JSON(), nullable=True),
sa.Column('published_at', sa.String(length=50), nullable=True),
sa.Column('is_visible', sa.Boolean(), nullable=True),
sa.Column('sort_order', sa.Integer(), nullable=True),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('slug')
)
op.create_table('calendar_months',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('year', sa.Integer(), nullable=False),
sa.Column('month', sa.Integer(), nullable=False),
sa.Column('title', sa.String(length=100), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('weather', sa.String(length=200), nullable=True),
sa.Column('highlights', sa.JSON(), nullable=True),
sa.Column('events', sa.JSON(), nullable=True),
sa.Column('is_available', sa.Boolean(), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('year', 'month', name='uq_calendar_year_month')
)
op.create_table('news',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('title', sa.String(length=200), nullable=False),
sa.Column('cover_image', sa.String(length=500), nullable=True),
sa.Column('summary', sa.Text(), nullable=True),
sa.Column('content', sa.Text(), nullable=True),
sa.Column('source', sa.String(length=100), nullable=True),
sa.Column('source_url', sa.String(length=500), nullable=True),
sa.Column('published_at', sa.String(length=50), nullable=True),
sa.Column('is_visible', sa.Boolean(), nullable=True),
sa.Column('sort_order', sa.Integer(), nullable=True),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('partners',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=200), nullable=False),
sa.Column('logo', sa.String(length=500), nullable=True),
sa.Column('website', sa.String(length=500), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('category', sa.String(length=100), nullable=True),
sa.Column('sort_order', sa.Integer(), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('pricing_items',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('product_name', sa.String(length=200), nullable=False),
sa.Column('product_slug', sa.String(length=100), nullable=True),
sa.Column('price_from', sa.String(length=50), nullable=True),
sa.Column('price_unit', sa.String(length=50), nullable=True),
sa.Column('price_label', sa.String(length=100), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('features', sa.JSON(), nullable=True),
sa.Column('notes', sa.JSON(), nullable=True),
sa.Column('is_visible', sa.Boolean(), nullable=True),
sa.Column('sort_order', sa.Integer(), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('qualifications',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('title', sa.String(length=200), nullable=False),
sa.Column('issuer', sa.String(length=200), nullable=True),
sa.Column('year', sa.String(length=20), nullable=True),
sa.Column('image', sa.String(length=500), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('category', sa.String(length=100), nullable=True),
sa.Column('sort_order', sa.Integer(), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('stories',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('title', sa.String(length=200), nullable=False),
sa.Column('cover_image', sa.String(length=500), nullable=True),
sa.Column('summary', sa.Text(), nullable=True),
sa.Column('content', sa.Text(), nullable=True),
sa.Column('customer_name', sa.String(length=100), nullable=True),
sa.Column('avatar', sa.String(length=500), nullable=True),
sa.Column('travel_date', sa.String(length=50), nullable=True),
sa.Column('product_name', sa.String(length=200), nullable=True),
sa.Column('scenes', sa.JSON(), nullable=True),
sa.Column('is_visible', sa.Boolean(), nullable=True),
sa.Column('sort_order', sa.Integer(), nullable=True),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('stories')
op.drop_table('qualifications')
op.drop_table('pricing_items')
op.drop_table('partners')
op.drop_table('news')
op.drop_table('calendar_months')
op.drop_table('blog_posts')
# ### end Alembic commands ###
@@ -0,0 +1,112 @@
"""add destination_details gallery_items courses_config selector_config customize_submissions seo_tldr
Revision ID: a3f9c1d8e256
Revises: 2bcfcc62f578
Create Date: 2026-03-20 21:00:00.000000
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
revision: str = 'a3f9c1d8e256'
down_revision: Union[str, None] = '2bcfcc62f578'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# SEO: add tldr column
op.add_column('seo_pages', sa.Column('tldr', sa.Text(), nullable=True))
# destination_details
op.create_table(
'destination_details',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=200), nullable=False),
sa.Column('slug', sa.String(length=200), nullable=False),
sa.Column('subtitle', sa.String(length=500), nullable=True),
sa.Column('cover_image', sa.String(length=500), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('location', sa.String(length=200), nullable=True),
sa.Column('best_season', sa.String(length=200), nullable=True),
sa.Column('duration', sa.String(length=100), nullable=True),
sa.Column('highlights', sa.JSON(), nullable=True),
sa.Column('gallery', sa.JSON(), nullable=True),
sa.Column('tags', sa.JSON(), nullable=True),
sa.Column('is_visible', sa.Boolean(), nullable=True),
sa.Column('sort_order', sa.Integer(), nullable=True),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('slug'),
)
# gallery_items
op.create_table(
'gallery_items',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('title', sa.String(length=200), nullable=True),
sa.Column('image', sa.String(length=500), nullable=False),
sa.Column('photographer', sa.String(length=100), nullable=True),
sa.Column('location', sa.String(length=200), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('tags', sa.JSON(), nullable=True),
sa.Column('is_visible', sa.Boolean(), nullable=True),
sa.Column('sort_order', sa.Integer(), nullable=True),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
# courses_config
op.create_table(
'courses_config',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('modules', sa.JSON(), nullable=True),
sa.Column('age_groups', sa.JSON(), nullable=True),
sa.Column('faqs', sa.JSON(), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
# selector_config
op.create_table(
'selector_config',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('questions', sa.JSON(), nullable=True),
sa.Column('rules', sa.JSON(), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
# customize_submissions
op.create_table(
'customize_submissions',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=100), nullable=True),
sa.Column('phone', sa.String(length=50), nullable=True),
sa.Column('wechat', sa.String(length=100), nullable=True),
sa.Column('adults', sa.Integer(), nullable=True),
sa.Column('children', sa.Integer(), nullable=True),
sa.Column('travel_dates', sa.String(length=200), nullable=True),
sa.Column('budget', sa.String(length=100), nullable=True),
sa.Column('interests', sa.JSON(), nullable=True),
sa.Column('notes', sa.Text(), nullable=True),
sa.Column('source', sa.String(length=100), nullable=True),
sa.Column('status', sa.Enum('pending', 'processed'), nullable=True),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
def downgrade() -> None:
op.drop_table('customize_submissions')
op.drop_table('selector_config')
op.drop_table('courses_config')
op.drop_table('gallery_items')
op.drop_table('destination_details')
op.drop_column('seo_pages', 'tldr')
@@ -0,0 +1,154 @@
"""add about new fields, brand cta buttons, customize config
Revision ID: b1e2f3a4c5d6
Revises: a3f9c1d8e256
Create Date: 2026-03-21 10:00:00.000000
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
revision: str = 'b1e2f3a4c5d6'
down_revision: Union[str, None] = 'a3f9c1d8e256'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# --- about_story: add totem fields ---
op.add_column('about_story', sa.Column('totem_description', sa.Text(), nullable=True))
op.add_column('about_story', sa.Column('totem_tagline', sa.String(length=500), nullable=True))
# --- about_culture: add core/trust/griefAward fields ---
op.add_column('about_culture', sa.Column('core', sa.String(length=200), nullable=True))
op.add_column('about_culture', sa.Column('trust', sa.String(length=500), nullable=True))
op.add_column('about_culture', sa.Column('grief_award_name', sa.String(length=100), nullable=True))
op.add_column('about_culture', sa.Column('grief_award_description', sa.Text(), nullable=True))
# --- about_founder_detail ---
op.create_table(
'about_founder_detail',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=100), nullable=True),
sa.Column('title', sa.String(length=200), nullable=True),
sa.Column('brand_founded', sa.Integer(), nullable=True),
sa.Column('years_in_hulunbuir', sa.String(length=50), nullable=True),
sa.Column('background', sa.Text(), nullable=True),
sa.Column('expertise', sa.JSON(), nullable=True),
sa.Column('media_presence', sa.JSON(), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
# --- about_founders ---
op.create_table(
'about_founders',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('title', sa.String(length=200), nullable=True),
sa.Column('story', sa.Text(), nullable=True),
sa.Column('sort_order', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
# --- about_milestones ---
op.create_table(
'about_milestones',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('year', sa.Integer(), nullable=False),
sa.Column('event', sa.Text(), nullable=False),
sa.Column('sort_order', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
# --- about_service_principles ---
op.create_table(
'about_service_principles',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('text', sa.Text(), nullable=False),
sa.Column('sort_order', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
# --- about_differentiation ---
op.create_table(
'about_differentiation',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('detail', sa.Text(), nullable=True),
sa.Column('sort_order', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
# --- about_service_journey ---
op.create_table(
'about_service_journey',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('title', sa.String(length=200), nullable=True),
sa.Column('subtitle', sa.String(length=500), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
# --- about_service_moments ---
op.create_table(
'about_service_moments',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('journey_id', sa.Integer(), nullable=False),
sa.Column('step', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('detail', sa.Text(), nullable=True),
sa.Column('sort_order', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['journey_id'], ['about_service_journey.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
)
# --- about_stats ---
op.create_table(
'about_stats',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('data', sa.JSON(), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
# --- brand: add cta_buttons, conversion_path ---
op.add_column('brand', sa.Column('cta_buttons', sa.JSON(), nullable=True))
op.add_column('brand', sa.Column('conversion_path', sa.JSON(), nullable=True))
# --- customize_config ---
op.create_table(
'customize_config',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('trust_stats', sa.JSON(), nullable=True),
sa.Column('durations', sa.JSON(), nullable=True),
sa.Column('activities', sa.JSON(), nullable=True),
sa.Column('budgets', sa.JSON(), nullable=True),
sa.Column('process', sa.JSON(), nullable=True),
sa.Column('contact', sa.JSON(), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
def downgrade() -> None:
op.drop_table('customize_config')
op.drop_column('brand', 'conversion_path')
op.drop_column('brand', 'cta_buttons')
op.drop_table('about_stats')
op.drop_table('about_service_moments')
op.drop_table('about_service_journey')
op.drop_table('about_differentiation')
op.drop_table('about_service_principles')
op.drop_table('about_milestones')
op.drop_table('about_founders')
op.drop_table('about_founder_detail')
op.drop_column('about_culture', 'grief_award_description')
op.drop_column('about_culture', 'grief_award_name')
op.drop_column('about_culture', 'trust')
op.drop_column('about_culture', 'core')
op.drop_column('about_story', 'totem_tagline')
op.drop_column('about_story', 'totem_description')