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>
90 lines
2.5 KiB
Python
90 lines
2.5 KiB
Python
"""
|
|
事業部 Schemas
|
|
"""
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import Field, ConfigDict
|
|
|
|
from app.schemas.base import BaseSchema
|
|
|
|
|
|
class BusinessUnitBase(BaseSchema):
|
|
"""事業部基礎 Schema"""
|
|
|
|
name: str = Field(..., min_length=2, max_length=100, description="事業部名稱")
|
|
name_en: Optional[str] = Field(None, max_length=100, description="英文名稱")
|
|
code: str = Field(..., min_length=2, max_length=20, description="事業部代碼")
|
|
email_domain: str = Field(..., description="郵件網域")
|
|
description: Optional[str] = Field(None, description="說明")
|
|
|
|
|
|
class BusinessUnitCreate(BusinessUnitBase):
|
|
"""創建事業部 Schema"""
|
|
|
|
model_config = ConfigDict(
|
|
json_schema_extra={
|
|
"example": {
|
|
"name": "業務發展部",
|
|
"name_en": "Business Development",
|
|
"code": "biz",
|
|
"email_domain": "ease.taipei",
|
|
"description": "碳權申請諮詢、碳足跡盤查、碳權交易媒合、業務拓展"
|
|
}
|
|
}
|
|
)
|
|
|
|
|
|
class BusinessUnitUpdate(BaseSchema):
|
|
"""更新事業部 Schema"""
|
|
|
|
name: Optional[str] = Field(None, min_length=2, max_length=100)
|
|
name_en: Optional[str] = Field(None, max_length=100)
|
|
description: Optional[str] = None
|
|
is_active: Optional[bool] = None
|
|
|
|
|
|
class BusinessUnitInDB(BusinessUnitBase):
|
|
"""資料庫中的事業部 Schema"""
|
|
|
|
id: int
|
|
is_active: bool
|
|
created_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class BusinessUnitResponse(BusinessUnitInDB):
|
|
"""事業部響應 Schema"""
|
|
|
|
departments_count: Optional[int] = Field(None, description="部門數量")
|
|
employees_count: Optional[int] = Field(None, description="員工數量")
|
|
|
|
model_config = ConfigDict(
|
|
json_schema_extra={
|
|
"example": {
|
|
"id": 1,
|
|
"name": "業務發展部",
|
|
"name_en": "Business Development",
|
|
"code": "biz",
|
|
"email_domain": "ease.taipei",
|
|
"description": "碳權申請諮詢、碳足跡盤查、碳權交易媒合、業務拓展",
|
|
"is_active": True,
|
|
"created_at": "2020-01-01T00:00:00",
|
|
"departments_count": 3,
|
|
"employees_count": 15
|
|
}
|
|
}
|
|
)
|
|
|
|
|
|
class BusinessUnitListItem(BaseSchema):
|
|
"""事業部列表項 Schema"""
|
|
|
|
id: int
|
|
name: str
|
|
code: str
|
|
email_domain: str
|
|
is_active: bool
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|