init: 初始化 dpb 桃育种系统代码库
前后端 + 后端 FastAPI 全量源码、部署脚本与文档。
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
"""人员花名册 数据模型"""
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Float, ForeignKey, Index, Integer, String, Text, text
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.core.base_model import MappedBase, ModelMixin, UserMixin
|
||||
|
||||
|
||||
class PersonnelModel(ModelMixin, UserMixin, MappedBase):
|
||||
"""人员花名册 主数据表。"""
|
||||
|
||||
__tablename__ = "bre_personnel"
|
||||
|
||||
name: Mapped[str] = mapped_column(String(100), nullable=False, comment="姓名")
|
||||
|
||||
gender: Mapped[str | None] = mapped_column(String(50), nullable=True, comment="性别", default=None)
|
||||
|
||||
role: Mapped[str | None] = mapped_column(String(50), nullable=True, comment="角色", default=None)
|
||||
|
||||
phone: Mapped[str | None] = mapped_column(String(100), nullable=True, comment="联系电话", default=None)
|
||||
|
||||
organization: Mapped[str | None] = mapped_column(String(100), nullable=True, comment="所属单位", default=None)
|
||||
|
||||
join_date: Mapped[str | None] = mapped_column(String(20), nullable=True, comment="入职日期", default=None)
|
||||
|
||||
remark: Mapped[str | None] = mapped_column(Text, nullable=True, comment="备注", default=None)
|
||||
|
||||
# 无 status 列:覆盖基类默认 ix_<表>_status_deleted 索引,
|
||||
# 仅保留 (created_time, is_deleted) 复合索引用于数据权限过滤。
|
||||
__table_args__ = (
|
||||
Index("ix_bre_personnel_created_deleted", "created_time", "is_deleted"),
|
||||
# 人员姓名唯一(仅约束未软删记录,与 service 层查重语义一致)
|
||||
Index(
|
||||
"uniq_bre_personnel_name", "name",
|
||||
unique=True, postgresql_where=text("is_deleted = false"),
|
||||
),
|
||||
)
|
||||
Reference in New Issue
Block a user