feat: HR Portal - Complete Multi-Tenant System with Redis Session Storage
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>
This commit is contained in:
105
backend/app/schemas/network_drive.py
Normal file
105
backend/app/schemas/network_drive.py
Normal file
@@ -0,0 +1,105 @@
|
||||
"""
|
||||
網路硬碟 Schemas
|
||||
"""
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from pydantic import Field, ConfigDict
|
||||
|
||||
from app.schemas.base import BaseSchema, TimestampSchema
|
||||
|
||||
|
||||
class NetworkDriveBase(BaseSchema):
|
||||
"""網路硬碟基礎 Schema"""
|
||||
|
||||
quota_gb: int = Field(..., gt=0, description="配額 (GB)")
|
||||
webdav_url: Optional[str] = Field(None, max_length=255, description="WebDAV 路徑")
|
||||
smb_url: Optional[str] = Field(None, max_length=255, description="SMB 路徑")
|
||||
|
||||
|
||||
class NetworkDriveCreate(NetworkDriveBase):
|
||||
"""創建網路硬碟 Schema"""
|
||||
|
||||
employee_id: int = Field(..., description="員工 ID")
|
||||
drive_name: str = Field(..., min_length=3, max_length=100, description="NAS 帳號名稱")
|
||||
|
||||
model_config = ConfigDict(
|
||||
json_schema_extra={
|
||||
"example": {
|
||||
"employee_id": 1,
|
||||
"drive_name": "porsche.chen",
|
||||
"quota_gb": 200,
|
||||
"webdav_url": "https://nas.lab.taipei/webdav/porsche.chen",
|
||||
"smb_url": "\\\\10.1.0.30\\porsche.chen"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class NetworkDriveUpdate(BaseSchema):
|
||||
"""更新網路硬碟 Schema"""
|
||||
|
||||
quota_gb: Optional[int] = Field(None, gt=0)
|
||||
webdav_url: Optional[str] = Field(None, max_length=255)
|
||||
smb_url: Optional[str] = Field(None, max_length=255)
|
||||
is_active: Optional[bool] = None
|
||||
|
||||
|
||||
class NetworkDriveInDB(NetworkDriveBase, TimestampSchema):
|
||||
"""資料庫中的網路硬碟 Schema"""
|
||||
|
||||
id: int
|
||||
employee_id: int
|
||||
drive_name: str
|
||||
is_active: bool
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class NetworkDriveResponse(NetworkDriveInDB):
|
||||
"""網路硬碟響應 Schema"""
|
||||
|
||||
employee_name: Optional[str] = Field(None, description="員工姓名")
|
||||
employee_username: Optional[str] = Field(None, description="員工基礎帳號")
|
||||
|
||||
model_config = ConfigDict(
|
||||
json_schema_extra={
|
||||
"example": {
|
||||
"id": 1,
|
||||
"employee_id": 1,
|
||||
"drive_name": "porsche.chen",
|
||||
"quota_gb": 200,
|
||||
"webdav_url": "https://nas.lab.taipei/webdav/porsche.chen",
|
||||
"smb_url": "\\\\10.1.0.30\\porsche.chen",
|
||||
"is_active": True,
|
||||
"created_at": "2020-01-01T00:00:00",
|
||||
"updated_at": "2020-01-01T00:00:00",
|
||||
"employee_name": "陳保時",
|
||||
"employee_username": "porsche.chen"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class NetworkDriveListItem(BaseSchema):
|
||||
"""網路硬碟列表項 Schema"""
|
||||
|
||||
id: int
|
||||
drive_name: str
|
||||
quota_gb: int
|
||||
is_active: bool
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class NetworkDriveQuotaUpdate(BaseSchema):
|
||||
"""更新配額 Schema"""
|
||||
|
||||
quota_gb: int = Field(..., gt=0, le=1000, description="新配額 (GB)")
|
||||
|
||||
model_config = ConfigDict(
|
||||
json_schema_extra={
|
||||
"example": {
|
||||
"quota_gb": 500
|
||||
}
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user