feat(工作日): 新增工作小时计算工具 + 节假日表与管理接口
- time_utils 新增 to_beijing(统一naive按UTC转北京时间) + working_duration_hours(排除周末/节假日) - Holiday 模型 + alembic 迁移建 holidays 表 - GET/POST/DELETE /holidays 节假日管理接口,可随时配置放假日期
This commit is contained in:
32
backend/alembic/versions/h1h2h3h4h5h6_add_holidays.py
Normal file
32
backend/alembic/versions/h1h2h3h4h5h6_add_holidays.py
Normal file
@ -0,0 +1,32 @@
|
||||
"""add holidays table
|
||||
|
||||
Revision ID: h1h2h3h4h5h6
|
||||
Revises: g1h2i3j4k5l6
|
||||
Create Date: 2026-08-28 12:00:00.000000
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision: str = 'h1h2h3h4h5h6'
|
||||
down_revision: Union[str, Sequence[str], None] = 'g1h2i3j4k5l6'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
'holidays',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, primary_key=True),
|
||||
sa.Column('day', sa.Date(), nullable=False, comment='放假日期'),
|
||||
sa.Column('name', sa.String(length=100), nullable=True, comment='放假说明(如国庆节)'),
|
||||
)
|
||||
op.create_index('ix_holidays_day', 'holidays', ['day'], unique=True)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index('ix_holidays_day', table_name='holidays')
|
||||
op.drop_table('holidays')
|
||||
Reference in New Issue
Block a user