fix
This commit is contained in:
@@ -1,9 +1,22 @@
|
|||||||
# 模板表
|
# 模板表
|
||||||
from python_core.kv import kv
|
from python_core.kv import kv
|
||||||
from .db import Db
|
from .db import Db
|
||||||
|
from .types import TemplateInfo
|
||||||
|
|
||||||
class TemplateDb(Db):
|
class TemplateDb(Db):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.key = "template"
|
self.key = "template"
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def list(self)->list[TemplateInfo]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def get(self, id: str)->TemplateInfo:
|
||||||
|
...
|
||||||
|
|
||||||
|
def create(self, info: TemplateInfo):
|
||||||
|
...
|
||||||
|
|
||||||
|
def remove(self, id: str):
|
||||||
|
...
|
||||||
22
python_core/database/types.py
Normal file
22
python_core/database/types.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import Dict, List, Any
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class TemplateInfo:
|
||||||
|
id: str
|
||||||
|
name: str
|
||||||
|
description: str
|
||||||
|
thumbnail_path: str
|
||||||
|
draft_content_path: str
|
||||||
|
resources_path: str
|
||||||
|
created_at: str
|
||||||
|
updated_at: str
|
||||||
|
canvas_config: Dict[str, Any]
|
||||||
|
duration: int
|
||||||
|
material_count: int
|
||||||
|
track_count: int
|
||||||
|
tags: List[str]
|
||||||
|
# local/cloud
|
||||||
|
type: str
|
||||||
|
# 创建用户
|
||||||
|
user_id: str
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
测试资源分类管理CLI功能
|
|
||||||
"""
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
sys.path.insert(0, '/root/projects/mixvideo_v2')
|
|
||||||
|
|
||||||
from python_core.services.resource_category_manager import ResourceCategoryManager
|
|
||||||
|
|
||||||
def test_category_manager():
|
|
||||||
"""测试分类管理器基本功能"""
|
|
||||||
print("🧪 测试资源分类管理器...")
|
|
||||||
|
|
||||||
try:
|
|
||||||
# 创建管理器
|
|
||||||
manager = ResourceCategoryManager()
|
|
||||||
print("✅ ResourceCategoryManager 初始化成功")
|
|
||||||
|
|
||||||
# 创建测试分类
|
|
||||||
result1 = manager.create_category('商业', '商业相关的视频内容', '#FF6B6B')
|
|
||||||
print(f"✅ 创建分类1: {result1['title']} (ID: {result1['id'][:8]})")
|
|
||||||
|
|
||||||
result2 = manager.create_category('教育', '教育培训相关内容', '#4ECDC4')
|
|
||||||
print(f"✅ 创建分类2: {result2['title']} (ID: {result2['id'][:8]})")
|
|
||||||
|
|
||||||
result3 = manager.create_category('娱乐', '娱乐休闲相关内容', '#45B7D1')
|
|
||||||
print(f"✅ 创建分类3: {result3['title']} (ID: {result3['id'][:8]})")
|
|
||||||
|
|
||||||
# 获取所有分类
|
|
||||||
categories = manager.get_all_categories()
|
|
||||||
print(f"✅ 获取到 {len(categories)} 个分类")
|
|
||||||
|
|
||||||
# 搜索分类
|
|
||||||
search_results = manager.search_categories('商业')
|
|
||||||
print(f"✅ 搜索'商业'找到 {len(search_results)} 个结果")
|
|
||||||
|
|
||||||
# 更新分类
|
|
||||||
updated = manager.update_category(result1['id'], title='商业推广', color='#FF5555')
|
|
||||||
if updated:
|
|
||||||
print(f"✅ 更新分类成功: {updated['title']}")
|
|
||||||
|
|
||||||
# 获取单个分类
|
|
||||||
category = manager.get_category_by_id(result2['id'])
|
|
||||||
if category:
|
|
||||||
print(f"✅ 获取分类详情: {category['title']}")
|
|
||||||
|
|
||||||
print("\n📋 所有分类列表:")
|
|
||||||
for i, cat in enumerate(categories, 1):
|
|
||||||
print(f" {i}. {cat['title']} - {cat['color']} - {cat['ai_prompt'][:20]}...")
|
|
||||||
|
|
||||||
print("\n🎉 所有测试通过!")
|
|
||||||
return True
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(f"❌ 测试失败: {e}")
|
|
||||||
return False
|
|
||||||
|
|
||||||
def test_cli_import():
|
|
||||||
"""测试CLI模块导入"""
|
|
||||||
print("\n🧪 测试CLI模块导入...")
|
|
||||||
|
|
||||||
try:
|
|
||||||
from python_core.cli.commands.category import category_app
|
|
||||||
print("✅ category CLI模块导入成功")
|
|
||||||
|
|
||||||
from python_core.cli.cli import app
|
|
||||||
print("✅ 主CLI应用导入成功")
|
|
||||||
|
|
||||||
# 检查命令是否注册
|
|
||||||
commands = [cmd.name for cmd in app.registered_commands.values()]
|
|
||||||
groups = [group.name for group in app.registered_groups.values()]
|
|
||||||
|
|
||||||
print(f"✅ 注册的命令: {commands}")
|
|
||||||
print(f"✅ 注册的命令组: {groups}")
|
|
||||||
|
|
||||||
if 'category' in groups:
|
|
||||||
print("✅ category命令组已正确注册")
|
|
||||||
else:
|
|
||||||
print("❌ category命令组未注册")
|
|
||||||
return False
|
|
||||||
|
|
||||||
print("🎉 CLI导入测试通过!")
|
|
||||||
return True
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(f"❌ CLI导入测试失败: {e}")
|
|
||||||
return False
|
|
||||||
|
|
||||||
def main():
|
|
||||||
"""主测试函数"""
|
|
||||||
print("🚀 开始测试资源分类管理CLI集成...")
|
|
||||||
|
|
||||||
# 测试分类管理器
|
|
||||||
manager_ok = test_category_manager()
|
|
||||||
|
|
||||||
# 测试CLI导入
|
|
||||||
cli_ok = test_cli_import()
|
|
||||||
|
|
||||||
if manager_ok and cli_ok:
|
|
||||||
print("\n🎉 所有测试通过!资源分类管理CLI集成成功!")
|
|
||||||
|
|
||||||
print("\n📖 使用方法:")
|
|
||||||
print(" python3 -m python_core.cli category --help")
|
|
||||||
print(" python3 -m python_core.cli category list")
|
|
||||||
print(" python3 -m python_core.cli category create '标题' 'AI提示词' '#颜色'")
|
|
||||||
print(" python3 -m python_core.cli category search '关键词'")
|
|
||||||
print(" python3 -m python_core.cli category stats")
|
|
||||||
|
|
||||||
else:
|
|
||||||
print("\n❌ 测试失败!")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
Reference in New Issue
Block a user