Major Features: - ✅ Multi-tenant architecture (tenant isolation) - ✅ Employee CRUD with lifecycle management (onboarding/offboarding) - ✅ Department tree structure with email domain management - ✅ Company info management (single-record editing) - ✅ System functions CRUD (permission management) - ✅ Email account management (multi-account per employee) - ✅ Keycloak SSO integration (auth.lab.taipei) - ✅ Redis session storage (10.1.0.254:6379) - Solves Cookie 4KB limitation - Cross-system session sharing - Sliding expiration (8 hours) - Automatic token refresh Technical Stack: Backend: - FastAPI + SQLAlchemy - PostgreSQL 16 (10.1.0.20:5433) - Keycloak Admin API integration - Docker Mailserver integration (SSH) - Alembic migrations Frontend: - Next.js 14 (App Router) - NextAuth 4 with Keycloak Provider - Redis session storage (ioredis) - Tailwind CSS Infrastructure: - Redis 7 (10.1.0.254:6379) - Session + Cache - Keycloak 26.1.0 (auth.lab.taipei) - Docker Mailserver (10.1.0.254) Architecture Highlights: - Session管理由 Keycloak + Redis 統一控制 - 支援多系統 (HR/WebMail/Calendar/Drive/Office) 共享 session - Token 自動刷新,異質服務整合 - 未來可無縫遷移到雲端 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
70 lines
3.1 KiB
Python
70 lines
3.1 KiB
Python
"""
|
|
員工履歷資料 Model (人員基本檔)
|
|
記錄員工的個人資料、教育背景等(與任用無關的基本資料)
|
|
"""
|
|
from datetime import datetime, date
|
|
from sqlalchemy import Column, Integer, String, Boolean, Date, DateTime, Text, ForeignKey, UniqueConstraint, Index
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class EmpResume(Base):
|
|
"""員工履歷表(人員基本檔)"""
|
|
|
|
__tablename__ = "tenant_emp_resumes"
|
|
__table_args__ = (
|
|
UniqueConstraint("tenant_id", "seq_no", name="uq_tenant_resume_seq"),
|
|
UniqueConstraint("tenant_id", "id_number", name="uq_tenant_id_number"),
|
|
Index("idx_emp_resume_tenant", "tenant_id"),
|
|
)
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
tenant_id = Column(Integer, ForeignKey("tenants.id", ondelete="CASCADE"), nullable=False, index=True,
|
|
comment="租戶 ID")
|
|
seq_no = Column(Integer, nullable=False, comment="租戶內序號 (觸發器自動生成)")
|
|
|
|
# 個人基本資料
|
|
legal_name = Column(String(100), nullable=False, comment="法定姓名")
|
|
english_name = Column(String(100), nullable=True, comment="英文名稱")
|
|
id_number = Column(String(20), nullable=False, comment="身分證字號/護照號碼")
|
|
birth_date = Column(Date, nullable=True, comment="出生日期")
|
|
gender = Column(String(10), nullable=True, comment="性別: M/F/Other")
|
|
marital_status = Column(String(20), nullable=True, comment="婚姻狀況: single/married/divorced/widowed")
|
|
nationality = Column(String(50), nullable=True, comment="國籍")
|
|
|
|
# 聯絡資訊
|
|
phone = Column(String(20), nullable=True, comment="聯絡電話")
|
|
mobile = Column(String(20), nullable=True, comment="手機")
|
|
personal_email = Column(String(255), nullable=True, comment="個人郵箱")
|
|
address = Column(Text, nullable=True, comment="通訊地址")
|
|
emergency_contact = Column(String(100), nullable=True, comment="緊急聯絡人")
|
|
emergency_phone = Column(String(20), nullable=True, comment="緊急聯絡電話")
|
|
|
|
# 教育背景
|
|
education_level = Column(String(50), nullable=True, comment="學歷: high_school/bachelor/master/phd")
|
|
school_name = Column(String(200), nullable=True, comment="畢業學校")
|
|
major = Column(String(100), nullable=True, comment="主修科系")
|
|
graduation_year = Column(Integer, nullable=True, comment="畢業年份")
|
|
|
|
# 備註
|
|
notes = Column(Text, nullable=True, comment="備註")
|
|
|
|
# 通用欄位
|
|
is_active = Column(Boolean, default=True, nullable=False, comment="是否啟用")
|
|
edit_by = Column(String(100), nullable=True, comment="最後編輯者")
|
|
created_at = Column(DateTime, default=datetime.utcnow, nullable=False, comment="建立時間")
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False, comment="更新時間")
|
|
|
|
# 關聯
|
|
tenant = relationship("Tenant")
|
|
employment_setting = relationship(
|
|
"EmpSetting",
|
|
back_populates="resume",
|
|
uselist=False,
|
|
cascade="all, delete-orphan"
|
|
)
|
|
|
|
def __repr__(self):
|
|
return f"<EmpResume {self.legal_name} ({self.id_number})>"
|