feat(duty): persist work plans and times; relax grab shift types
Map invalid HH:mm to DutyBizError, serialize workPlans/timeLabel from dict, ensure dict items on save, and allow custom shift types on public grab. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
4447a1e8e6
commit
cd0491e601
3 files changed
+202
-8
No files matched your search
+23
-1
@@ -11,7 +11,7 @@ from app.core.database import get_db
|
||||
from app.core.menu_guard import require_admin_or_super_admin
|
||||
from app.core.response import error_response, success_response
|
||||
from app.crud import user as user_crud
|
||||
from app.schemas.duty import DutyDaySaveBody, DutyLinkBody
|
||||
from app.schemas.duty import DutyDaySaveBody, DutyDictEnsureBody, DutyLinkBody
|
||||
from app.services import duty_schedule as duty_svc
|
||||
from app.services.duty_schedule import DutyBizError
|
||||
|
||||
@@ -73,6 +73,28 @@ def duty_user_options(
|
||||
return success_response(out)
|
||||
|
||||
|
||||
@router.post("/dict/ensure")
|
||||
def ensure_duty_dict(
|
||||
body: DutyDictEnsureBody,
|
||||
_user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _user.get("tenant_no", "") or ""
|
||||
user_id = _user.get("user_id") or _user.get("id", "") or ""
|
||||
try:
|
||||
data = duty_svc.ensure_dict_data(
|
||||
db,
|
||||
tenant_no=tenant_no,
|
||||
dict_type=body.dictType,
|
||||
label=body.label,
|
||||
user_id=user_id,
|
||||
)
|
||||
db.commit()
|
||||
return success_response(data, message="已保存")
|
||||
except DutyBizError as exc:
|
||||
return error_response(400, str(exc))
|
||||
|
||||
|
||||
@router.post("/day")
|
||||
def save_day(
|
||||
body: DutyDaySaveBody,
|
||||
|
||||
Reference in new issue
Block a user