freeleaps-ops/apps/gitea-webhook-ambassador-python/app/models/project_mapping.py
Nicolas f6c515157c feat: 添加 Python 版本的 Gitea Webhook Ambassador
- 新增完整的 Python 实现,替代 Go 版本
- 添加 Web 登录界面和仪表板
- 实现 JWT 认证和 API 密钥管理
- 添加数据库存储功能
- 保持与 Go 版本一致的目录结构和启动脚本
- 包含完整的文档和测试脚本
2025-07-20 21:17:10 +08:00

20 lines
1014 B
Python

from datetime import datetime
from sqlalchemy import Column, Integer, String, DateTime, JSON
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class ProjectMapping(Base):
"""项目映射模型"""
__tablename__ = "project_mappings"
id = Column(Integer, primary_key=True, index=True)
repository_name = Column(String(255), nullable=False, unique=True, index=True)
default_job = Column(String(255), nullable=False)
branch_jobs = Column(JSON, nullable=False, default=list) # [{"branch": "dev", "job": "dev-build"}]
branch_patterns = Column(JSON, nullable=False, default=list) # [{"pattern": "feature/*", "job": "feature-build"}]
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
def __repr__(self):
return f"<ProjectMapping(id={self.id}, repository={self.repository_name}, default_job={self.default_job})>"