56 lines
2.4 KiB
Python
56 lines
2.4 KiB
Python
"""员工自助: 资料变更申请、通用审批流水、员工确认/评价."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import date, datetime
|
|
|
|
from sqlalchemy import JSON, Date, DateTime, Integer, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from ..db.base import Base, PKMixin, TimestampMixin, utcnow
|
|
|
|
|
|
class ProfileRequest(PKMixin, TimestampMixin, Base):
|
|
"""自助端提交的资料/证件变更申请, 审批通过后写回档案."""
|
|
|
|
__tablename__ = "self_profile_request"
|
|
|
|
employee_id: Mapped[int] = mapped_column(Integer, index=True)
|
|
changes: Mapped[dict | None] = mapped_column(JSON) # {field: {"before": x, "after": y}}
|
|
reason: Mapped[str | None] = mapped_column(String(255))
|
|
status: Mapped[str] = mapped_column(String(16), default="pending", index=True)
|
|
applicant_user_id: Mapped[int | None] = mapped_column(Integer)
|
|
approver_id: Mapped[int | None] = mapped_column(Integer)
|
|
approver_name: Mapped[str | None] = mapped_column(String(64))
|
|
approved_at: Mapped[datetime | None] = mapped_column(DateTime)
|
|
comment: Mapped[str | None] = mapped_column(String(255))
|
|
|
|
|
|
class ApprovalLog(PKMixin, Base):
|
|
"""任意业务对象的审批轨迹."""
|
|
|
|
__tablename__ = "self_approval_log"
|
|
|
|
entity_type: Mapped[str] = mapped_column(String(32), index=True)
|
|
entity_id: Mapped[int] = mapped_column(Integer, index=True)
|
|
action: Mapped[str] = mapped_column(String(24)) # submit/approve/reject/cancel/withdraw
|
|
actor_id: Mapped[int | None] = mapped_column(Integer)
|
|
actor_name: Mapped[str | None] = mapped_column(String(64))
|
|
comment: Mapped[str | None] = mapped_column(String(255))
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, default=utcnow)
|
|
|
|
|
|
class TaskReminder(PKMixin, TimestampMixin, Base):
|
|
"""HR 工作台待办 (合同到期/试用期到期/生日/招聘跟进...)."""
|
|
|
|
__tablename__ = "self_task_reminder"
|
|
|
|
category: Mapped[str] = mapped_column(String(32), index=True)
|
|
title: Mapped[str] = mapped_column(String(160))
|
|
employee_id: Mapped[int | None] = mapped_column(Integer, index=True)
|
|
due_date: Mapped[date | None] = mapped_column(Date, index=True)
|
|
level: Mapped[str] = mapped_column(String(16), default="normal")
|
|
status: Mapped[str] = mapped_column(String(16), default="open", index=True)
|
|
detail: Mapped[str | None] = mapped_column(Text)
|
|
link: Mapped[str | None] = mapped_column(String(255))
|