每次创建/编辑/软删除项目组时追加 biz_project_team_history, 用完整 serialize 快照保留负责人、成员、地区与医院等信息,便于追溯。 Refs: #50 Co-authored-by: Cursor <cursoragent@cursor.com>
81 lines
3.3 KiB
Python
81 lines
3.3 KiB
Python
"""租户项目及归属审计;区域医院关联只记录组织资料。"""
|
|
from datetime import datetime
|
|
from sqlalchemy import Column, String, Integer, SmallInteger, DateTime, Date, Text, UniqueConstraint
|
|
from app.models.base import Base
|
|
|
|
|
|
class ProjectFields:
|
|
id = Column(String(64), primary_key=True)
|
|
tenant_no = Column(String(64), nullable=False, index=True)
|
|
order_num = Column(Integer)
|
|
remark = Column(String(512))
|
|
create_by = Column(String(64))
|
|
create_dept_id = Column(String(64), nullable=False, default='')
|
|
create_time = Column(DateTime, nullable=False, default=datetime.now)
|
|
update_by = Column(String(64))
|
|
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now)
|
|
del_flag = Column(SmallInteger, nullable=False, default=0)
|
|
|
|
|
|
class ProjectTeam(ProjectFields, Base):
|
|
__tablename__ = 'biz_project_team'
|
|
team_name = Column(String(200), nullable=False)
|
|
leader_user_id = Column(String(64), nullable=False)
|
|
enabled = Column(SmallInteger, nullable=False, default=1)
|
|
|
|
|
|
class ProjectTeamMember(ProjectFields, Base):
|
|
__tablename__ = 'biz_project_team_member'
|
|
team_id = Column(String(64), nullable=False, index=True)
|
|
user_id = Column(String(64), nullable=False)
|
|
|
|
|
|
class ProjectTeamRegion(ProjectFields, Base):
|
|
__tablename__ = 'biz_project_team_region'
|
|
team_id = Column(String(64), nullable=False, index=True)
|
|
region_id = Column(String(64), nullable=False)
|
|
|
|
|
|
class ProjectTeamHospital(ProjectFields, Base):
|
|
__tablename__ = 'biz_project_team_hospital'
|
|
team_id = Column(String(64), nullable=False, index=True)
|
|
hospital_id = Column(String(64), nullable=False)
|
|
|
|
|
|
class Project(ProjectFields, Base):
|
|
__tablename__ = 'biz_project'
|
|
__table_args__ = (UniqueConstraint('tenant_no', 'project_no', name='uk_project_tenant_no'),)
|
|
project_no = Column(String(64), nullable=False)
|
|
project_name = Column(String(200), nullable=False)
|
|
team_id = Column(String(64), nullable=False, index=True)
|
|
leader_user_id = Column(String(64), nullable=False)
|
|
biz_types = Column(String(255), nullable=False)
|
|
start_date = Column(Date)
|
|
end_date = Column(Date)
|
|
status = Column(String(16), nullable=False, default='pending')
|
|
|
|
|
|
class ProjectAssignmentAudit(ProjectFields, Base):
|
|
__tablename__ = 'biz_project_assignment_audit'
|
|
biz_type = Column(String(32), nullable=False)
|
|
biz_id = Column(String(64), nullable=False, index=True)
|
|
old_project_id = Column(String(64))
|
|
new_project_id = Column(String(64))
|
|
old_project_name = Column(String(200))
|
|
new_project_name = Column(String(200))
|
|
reason = Column(String(512), nullable=False)
|
|
operator_name = Column(String(100))
|
|
|
|
|
|
class ProjectTeamHistory(ProjectFields, Base):
|
|
"""项目组版本历史;每次成功写入记完整快照。"""
|
|
__tablename__ = 'biz_project_team_history'
|
|
__table_args__ = (UniqueConstraint('tenant_no', 'team_id', 'version_no', name='uk_team_version'),)
|
|
team_id = Column(String(64), nullable=False, index=True)
|
|
version_no = Column(Integer, nullable=False)
|
|
action = Column(String(16), nullable=False)
|
|
snapshot_json = Column(Text, nullable=False)
|
|
operator_user_id = Column(String(64))
|
|
operator_user_name = Column(String(100))
|
|
operate_time = Column(DateTime, nullable=False, default=datetime.now)
|