feat(role): 根据role判断用户的权限
This commit is contained in:
1 parent
80d78130f8
commit
a24bd94d43
93 files changed
+4472
-387
No files matched your search
@@ -2,7 +2,7 @@
|
||||
backend/app/services/voucher_check/schedule_seed.py
|
||||
|
||||
用途:确保立账凭证检核(周二 06:00)与 PO 订单生成(周二 05:00)默认 ScheduleTask 存在。
|
||||
依赖:ScheduleTask/User、timezone_util、voucher_check.config。
|
||||
依赖:ScheduleTask/User、permission_roles.service.first_schedule_owner_user、timezone_util、voucher_check.config。
|
||||
逻辑:迁移种子 + create_app / User after_commit 幂等补建;检核排程剥离 schema 外的旧 job_params。
|
||||
"""
|
||||
|
||||
@@ -18,6 +18,7 @@ from sqlalchemy.orm.attributes import flag_modified
|
||||
|
||||
from app import db
|
||||
from app.models import ScheduleTask, User
|
||||
from app.services.permission_roles.service import first_schedule_owner_user
|
||||
from app.services.schedule.timezone_util import compute_next_run_at
|
||||
from app.services.voucher_check.config import DEFAULT_JOB_PARAMS, DEFAULT_PO_PRINT_JOB_PARAMS
|
||||
|
||||
@@ -107,14 +108,7 @@ def ensure_default_voucher_check_schedule(
|
||||
sess.commit()
|
||||
return existing
|
||||
|
||||
owner = (
|
||||
sess.query(User)
|
||||
.filter(User.role == "admin")
|
||||
.order_by(User.id.asc())
|
||||
.first()
|
||||
)
|
||||
if owner is None:
|
||||
owner = sess.query(User).order_by(User.id.asc()).first()
|
||||
owner = _pick_schedule_owner(sess)
|
||||
if owner is None:
|
||||
_LOGGER.info("skip seed accounting-voucher-check schedule: no users yet")
|
||||
return None
|
||||
@@ -169,16 +163,8 @@ def ensure_default_voucher_check_schedule(
|
||||
|
||||
|
||||
def _pick_schedule_owner(sess: Any) -> Any | None:
|
||||
"""优先管理员,否则任意用户;尚无用户时返回 None。"""
|
||||
owner = (
|
||||
sess.query(User)
|
||||
.filter(User.role == "admin")
|
||||
.order_by(User.id.asc())
|
||||
.first()
|
||||
)
|
||||
if owner is None:
|
||||
owner = sess.query(User).order_by(User.id.asc()).first()
|
||||
return owner
|
||||
"""优先平台管理员,否则任意用户;尚无用户时返回 None。"""
|
||||
return first_schedule_owner_user(sess)
|
||||
|
||||
|
||||
def ensure_default_voucher_po_print_schedule(
|
||||
|
||||
Reference in new issue
Block a user