You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.1 KiB
33 lines
1.1 KiB
"""
|
|
项目数据模型
|
|
"""
|
|
from sqlalchemy import Column, Integer, String, DateTime, Text, Boolean
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
from app.database import Base
|
|
|
|
class Project(Base):
|
|
"""项目模型"""
|
|
__tablename__ = "projects"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String(100), nullable=False, index=True)
|
|
description = Column(Text)
|
|
language = Column(String(20), nullable=False) # Python, C++, JavaScript等
|
|
repository_url = Column(String(500))
|
|
project_path = Column(String(500)) # 本地项目路径
|
|
config = Column(Text) # JSON格式的配置信息
|
|
|
|
# 状态字段
|
|
is_active = Column(Boolean, default=True)
|
|
|
|
# 时间戳
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
# 关联关系
|
|
scans = relationship("Scan", back_populates="project", cascade="all, delete-orphan")
|
|
|
|
def __repr__(self):
|
|
return f"<Project(id={self.id}, name='{self.name}', language='{self.language}')>"
|