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:
2025-12-11 16:20:57 +08:00
commit f810ddc2ea
48 changed files with 4950 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
"""
KPI 審核紀錄 Model
"""
from datetime import datetime
from typing import Optional, TYPE_CHECKING
from sqlalchemy import String, Integer, DateTime, Text, ForeignKey
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.core.database import Base
if TYPE_CHECKING:
from app.models.kpi_sheet import KPISheet
from app.models.employee import Employee
class KPIReviewLog(Base):
"""KPI 審核紀錄"""
__tablename__ = "KPI_D_review_logs"
id: Mapped[int] = mapped_column(primary_key=True)
sheet_id: Mapped[int] = mapped_column(ForeignKey("KPI_D_sheets.id", ondelete="CASCADE"), nullable=False)
action: Mapped[str] = mapped_column(String(50), nullable=False) # submit, approve, reject, self_eval, manager_eval
actor_id: Mapped[int] = mapped_column(ForeignKey("KPI_D_employees.id"), nullable=False)
from_status: Mapped[Optional[str]] = mapped_column(String(20))
to_status: Mapped[Optional[str]] = mapped_column(String(20))
comment: Mapped[Optional[str]] = mapped_column(Text)
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
# Relationships
sheet: Mapped["KPISheet"] = relationship("KPISheet", back_populates="review_logs")
actor: Mapped["Employee"] = relationship("Employee")
def __repr__(self) -> str:
return f"<KPIReviewLog id={self.id} action={self.action} sheet={self.sheet_id}>"