"""添加测试数据"""

from sqlalchemy.orm import Session
from app.core.database import SessionLocal
from app.core.security import get_password_hash
from app.models.user import User
from app.models.work import Work

def seed_data():
    """添加测试数据"""
    db = SessionLocal()
    
    try:
        # 创建测试用户（使用手机号）
        test_user = User(
            phone="13800138000",
            password_hash=get_password_hash("123456"),
            nickname="测试用户",
            balance=100.0  # 给测试用户100元余额
        )
        db.add(test_user)
        
        # 创建测试作品
        test_works = [
            Work(
                title="活动海报设计",
                category="活动",
                designer="呵呵",
                level=3,
                level_text="设计师",
                price=9.9,
                thumbnail_image="/uploads/thumbnail/1.jpg",
                watermarked_image="/uploads/watermarked/1.jpg",
                original_image="/uploads/original/1.jpg",
                description="高品质活动海报设计，适合各类活动宣传",
                tags='["海报", "活动", "设计"]'
            ),
            Work(
                title="马年招聘海报",
                category="活动",
                designer="六十六号屯",
                level=4,
                level_text="资深设计师",
                price=15.9,
                thumbnail_image="/uploads/thumbnail/2.jpg",
                watermarked_image="/uploads/watermarked/2.jpg",
                original_image="/uploads/original/2.jpg",
                description="马年主题招聘海报，创意十足",
                tags='["招聘", "马年", "海报"]'
            ),
            Work(
                title="新中式主视觉",
                category="中式",
                designer="小鱼是设计",
                level=4,
                level_text="资深设计师",
                price=19.9,
                thumbnail_image="/uploads/thumbnail/3.jpg",
                watermarked_image="/uploads/watermarked/3.jpg",
                original_image="/uploads/original/3.jpg",
                description="新中式风格主视觉设计，高端大气",
                tags='["中式", "主视觉", "设计"]'
            ),
            Work(
                title="品牌VI设计",
                category="直播",
                designer="设计狮",
                level=5,
                level_text="首席设计师",
                price=29.9,
                thumbnail_image="/uploads/thumbnail/4.jpg",
                watermarked_image="/uploads/watermarked/4.jpg",
                original_image="/uploads/original/4.jpg",
                description="完整品牌VI视觉识别系统设计",
                tags='["品牌", "VI", "Logo"]'
            ),
            Work(
                title="电商促销Banner",
                category="活动",
                designer="小美设计",
                level=3,
                level_text="设计师",
                price=12.9,
                thumbnail_image="/uploads/thumbnail/5.jpg",
                watermarked_image="/uploads/watermarked/5.jpg",
                original_image="/uploads/original/5.jpg",
                description="电商平台促销活动Banner设计",
                tags='["电商", "Banner", "促销"]'
            ),
            Work(
                title="春节主题海报",
                category="周年庆",
                designer="创意工作室",
                level=4,
                level_text="资深设计师",
                price=18.9,
                thumbnail_image="/uploads/thumbnail/6.jpg",
                watermarked_image="/uploads/watermarked/6.jpg",
                original_image="/uploads/original/6.jpg",
                description="春节节日氛围海报设计",
                tags='["春节", "节日", "海报"]'
            ),
            Work(
                title="移动端UI界面",
                category="直播",
                designer="UI设计师",
                level=4,
                level_text="资深设计师",
                price=25.9,
                thumbnail_image="/uploads/thumbnail/7.jpg",
                watermarked_image="/uploads/watermarked/7.jpg",
                original_image="/uploads/original/7.jpg",
                description="简洁大气的移动端应用界面设计",
                tags='["UI", "移动端", "界面"]'
            ),
            Work(
                title="扁平风格插画",
                category="活动",
                designer="插画师小陈",
                level=5,
                level_text="首席设计师",
                price=22.9,
                thumbnail_image="/uploads/thumbnail/8.jpg",
                watermarked_image="/uploads/watermarked/8.jpg",
                original_image="/uploads/original/8.jpg",
                description="扁平风格商业插画设计",
                tags='["插画", "扁平", "商业"]'
            ),
            Work(
                title="风光摄影作品",
                category="中式",
                designer="摄影师老王",
                level=6,
                level_text="大师",
                price=39.9,
                thumbnail_image="/uploads/thumbnail/9.jpg",
                watermarked_image="/uploads/watermarked/9.jpg",
                original_image="/uploads/original/9.jpg",
                description="自然风光摄影精品",
                tags='["摄影", "风光", "自然"]'
            ),
            Work(
                title="简约Logo设计",
                category="直播",
                designer="品牌设计师",
                level=5,
                level_text="首席设计师",
                price=35.9,
                thumbnail_image="/uploads/thumbnail/10.jpg",
                watermarked_image="/uploads/watermarked/10.jpg",
                original_image="/uploads/original/10.jpg",
                description="简约现代风格Logo设计",
                tags='["Logo", "简约", "品牌"]'
            ),
            Work(
                title="产品包装设计",
                category="活动",
                designer="包装设计工作室",
                level=4,
                level_text="资深设计师",
                price=28.9,
                thumbnail_image="/uploads/thumbnail/11.jpg",
                watermarked_image="/uploads/watermarked/11.jpg",
                original_image="/uploads/original/11.jpg",
                description="创意产品包装盒设计",
                tags='["包装", "产品", "创意"]'
            ),
            Work(
                title="商务名片设计",
                category="直播",
                designer="名片专家",
                level=3,
                level_text="设计师",
                price=8.9,
                thumbnail_image="/uploads/thumbnail/12.jpg",
                watermarked_image="/uploads/watermarked/12.jpg",
                original_image="/uploads/original/12.jpg",
                description="高端商务名片设计",
                tags='["名片", "商务", "印刷"]'
            ),
            Work(
                title="宣传单页设计",
                category="活动",
                designer="平面设计师",
                level=3,
                level_text="设计师",
                price=11.9,
                thumbnail_image="/uploads/thumbnail/13.jpg",
                watermarked_image="/uploads/watermarked/13.jpg",
                original_image="/uploads/original/13.jpg",
                description="活动宣传单页设计",
                tags='["宣传单", "活动", "印刷"]'
            ),
            Work(
                title="企业画册设计",
                category="中式",
                designer="画册设计团队",
                level=5,
                level_text="首席设计师",
                price=45.9,
                thumbnail_image="/uploads/thumbnail/14.jpg",
                watermarked_image="/uploads/watermarked/14.jpg",
                original_image="/uploads/original/14.jpg",
                description="企业宣传画册整体设计",
                tags='["画册", "企业", "宣传"]'
            ),
            Work(
                title="展板海报设计",
                category="周年庆",
                designer="展览设计师",
                level=4,
                level_text="资深设计师",
                price=24.9,
                thumbnail_image="/uploads/thumbnail/15.jpg",
                watermarked_image="/uploads/watermarked/15.jpg",
                original_image="/uploads/original/15.jpg",
                description="展览展示展板设计",
                tags='["展板", "展览", "海报"]'
            ),
        ]
        
        for work in test_works:
            db.add(work)
        
        db.commit()
        print("✅ 测试数据添加成功！")
        print("\n测试账号：")
        print("手机号: 13800138000")
        print("密码: 123456")
        print("余额: 100.0 元")
        
    except Exception as e:
        print(f"❌ 错误: {e}")
        db.rollback()
    finally:
        db.close()

if __name__ == "__main__":
    seed_data()
