48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
|
|
"""
|
||
|
|
功能模块模型
|
||
|
|
"""
|
||
|
|
from typing import List, Dict, Any
|
||
|
|
|
||
|
|
|
||
|
|
class Module:
|
||
|
|
"""功能模块数据模型"""
|
||
|
|
|
||
|
|
def __init__(self, name: str, description: str, requirements: List[str] = None):
|
||
|
|
"""
|
||
|
|
初始化模块
|
||
|
|
|
||
|
|
Args:
|
||
|
|
name: 模块名称
|
||
|
|
description: 模块描述
|
||
|
|
requirements: 关联的需求ID列表
|
||
|
|
"""
|
||
|
|
self.name = name
|
||
|
|
self.description = description
|
||
|
|
self.requirements = requirements or []
|
||
|
|
self.tech_stack = []
|
||
|
|
self.progress = 0
|
||
|
|
self.icon = "🔧"
|
||
|
|
|
||
|
|
def add_requirement(self, req_id: str):
|
||
|
|
"""添加关联需求"""
|
||
|
|
if req_id not in self.requirements:
|
||
|
|
self.requirements.append(req_id)
|
||
|
|
|
||
|
|
def add_tech(self, tech: str):
|
||
|
|
"""添加技术栈"""
|
||
|
|
if tech not in self.tech_stack:
|
||
|
|
self.tech_stack.append(tech)
|
||
|
|
|
||
|
|
def to_dict(self) -> Dict[str, Any]:
|
||
|
|
"""转换为字典"""
|
||
|
|
return {
|
||
|
|
'name': self.name,
|
||
|
|
'description': self.description,
|
||
|
|
'requirements': self.requirements,
|
||
|
|
'tech_stack': self.tech_stack,
|
||
|
|
'progress': self.progress
|
||
|
|
}
|
||
|
|
|
||
|
|
def __str__(self) -> str:
|
||
|
|
return f"{self.icon} {self.name}"
|