Initial commit: KPI Management System Backend
Features: - FastAPI backend with JWT authentication - MySQL database with SQLAlchemy ORM - KPI workflow: draft → pending → approved → evaluation → completed - Ollama LLM API integration for AI features - Gitea API integration for version control - Complete API endpoints for KPI, dashboard, notifications Tables: KPI_D_* prefix naming convention 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
163
app/schemas/kpi_sheet.py
Normal file
163
app/schemas/kpi_sheet.py
Normal file
@@ -0,0 +1,163 @@
|
||||
"""
|
||||
KPI 表單 Schemas
|
||||
"""
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from typing import Optional, List
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.schemas.employee import EmployeeSimple
|
||||
from app.schemas.kpi_item import KPIItemCreate, KPIItemResponse, SelfEvalItem, ManagerEvalItem
|
||||
|
||||
|
||||
class KPIPeriodBase(BaseModel):
|
||||
"""KPI 期間基本資訊"""
|
||||
|
||||
id: int
|
||||
code: str
|
||||
name: str
|
||||
|
||||
|
||||
class KPIPeriodResponse(KPIPeriodBase):
|
||||
"""KPI 期間回應"""
|
||||
|
||||
start_date: str
|
||||
end_date: str
|
||||
setting_start: str
|
||||
setting_end: str
|
||||
self_eval_start: Optional[str]
|
||||
self_eval_end: Optional[str]
|
||||
manager_eval_start: Optional[str]
|
||||
manager_eval_end: Optional[str]
|
||||
status: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class KPISheetCreate(BaseModel):
|
||||
"""建立 KPI 表單"""
|
||||
|
||||
period_id: int
|
||||
items: List[KPIItemCreate]
|
||||
|
||||
|
||||
class KPISheetUpdate(BaseModel):
|
||||
"""更新 KPI 表單"""
|
||||
|
||||
items: Optional[List[KPIItemCreate]] = None
|
||||
|
||||
|
||||
class KPISheetResponse(BaseModel):
|
||||
"""KPI 表單回應"""
|
||||
|
||||
id: int
|
||||
employee: EmployeeSimple
|
||||
period: KPIPeriodBase
|
||||
department_id: int
|
||||
status: str
|
||||
items: List[KPIItemResponse]
|
||||
|
||||
# 提交資訊
|
||||
submitted_at: Optional[datetime]
|
||||
|
||||
# 審核資訊
|
||||
approved_by: Optional[int]
|
||||
approved_at: Optional[datetime]
|
||||
approve_comment: Optional[str]
|
||||
|
||||
# 退回資訊
|
||||
rejected_by: Optional[int]
|
||||
rejected_at: Optional[datetime]
|
||||
reject_reason: Optional[str]
|
||||
|
||||
# 自評資訊
|
||||
self_eval_at: Optional[datetime]
|
||||
|
||||
# 主管評核資訊
|
||||
manager_eval_by: Optional[int]
|
||||
manager_eval_at: Optional[datetime]
|
||||
manager_eval_comment: Optional[str]
|
||||
|
||||
# 分數
|
||||
total_score: Optional[Decimal]
|
||||
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class KPISheetListItem(BaseModel):
|
||||
"""KPI 表單列表項目"""
|
||||
|
||||
id: int
|
||||
employee: EmployeeSimple
|
||||
period: KPIPeriodBase
|
||||
status: str
|
||||
total_score: Optional[Decimal]
|
||||
submitted_at: Optional[datetime]
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class ApproveRequest(BaseModel):
|
||||
"""審核通過請求"""
|
||||
|
||||
comment: Optional[str] = None
|
||||
|
||||
|
||||
class RejectRequest(BaseModel):
|
||||
"""退回請求"""
|
||||
|
||||
reason: str
|
||||
|
||||
|
||||
class SelfEvalRequest(BaseModel):
|
||||
"""自評請求"""
|
||||
|
||||
items: List[SelfEvalItem]
|
||||
|
||||
|
||||
class ManagerEvalRequest(BaseModel):
|
||||
"""主管評核請求"""
|
||||
|
||||
items: List[ManagerEvalItem]
|
||||
comment: Optional[str] = None
|
||||
|
||||
|
||||
# KPI 範本相關
|
||||
class KPITemplateResponse(BaseModel):
|
||||
"""KPI 範本回應"""
|
||||
|
||||
id: int
|
||||
code: str
|
||||
name: str
|
||||
category: str
|
||||
description: Optional[str]
|
||||
default_weight: int
|
||||
level0_desc: str
|
||||
level1_desc: str
|
||||
level2_desc: str
|
||||
level3_desc: str
|
||||
level4_desc: str
|
||||
is_active: bool
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class KPIPresetResponse(BaseModel):
|
||||
"""KPI 預設組合回應"""
|
||||
|
||||
id: int
|
||||
code: str
|
||||
name: str
|
||||
description: Optional[str]
|
||||
items: List[KPITemplateResponse]
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
Reference in New Issue
Block a user