feat(工作日): 新增工作小时计算工具 + 节假日表与管理接口
- time_utils 新增 to_beijing(统一naive按UTC转北京时间) + working_duration_hours(排除周末/节假日) - Holiday 模型 + alembic 迁移建 holidays 表 - GET/POST/DELETE /holidays 节假日管理接口,可随时配置放假日期
This commit is contained in:
21
backend/app/models/holiday.py
Normal file
21
backend/app/models/holiday.py
Normal file
@ -0,0 +1,21 @@
|
||||
"""节假日模型 — 放假日期配置,用于工作日时长计算"""
|
||||
from datetime import date
|
||||
from sqlalchemy import Date, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.models.base import Base
|
||||
|
||||
|
||||
class Holiday(Base):
|
||||
__tablename__ = "holidays"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
day: Mapped[date] = mapped_column(
|
||||
Date, unique=True, index=True, comment="放假日期",
|
||||
)
|
||||
name: Mapped[str | None] = mapped_column(
|
||||
String(100), nullable=True, comment="放假说明(如国庆节)",
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Holiday {self.day}>"
|
||||
Reference in New Issue
Block a user