Artifact 8a1e8b8c0b6e2e57dbff93262b154e00e2a18366bc1c4b969c1c218fadbd9daf:
- File
backend/src/swiftflow_clock_ffi.erl
— part of check-in
[1821522f51]
at
2026-10-23 05:51:23
on branch trunk
— RBAC 权限与多仓数据隔离
- 新增用户、角色、权限点、用户角色、用户授权仓库、登录会话、审计日志表(008_rbac) - 预设五个角色(超级管理员、仓库主管、制单/调度员、打包复核员、库内作业员),按角色限制登录终端 - 账号密码登录,PBKDF2-SHA256 加盐存储,令牌只存哈希,会话按配置过期,连续输错锁定 - 首个超级管理员从 SWIFTFLOW_ADMIN_USERNAME / SWIFTFLOW_ADMIN_PASSWORD 创建,仅在用户表为空时生效 - 除健康检查与登录外所有接口需登录并校验权限点 - 订单、采购单、库位、库存、批次码按授权仓库过滤;收货、上架、出库只能在当前作业仓库进行 - 用户管理、角色查询、审计日志接口;同步、库位、上架、收货、出库写操作记录审计 (user: pluto size: 1068)
-module(swiftflow_clock_ffi). -export([now_local/0, today_local/0, shift_days_local/1, shift_seconds_local/1, monotonic_ms/0]). now_local() -> datetime(calendar:local_time()). shift_seconds_local(Seconds) when is_integer(Seconds) -> Now = calendar:datetime_to_gregorian_seconds(calendar:local_time()), datetime(calendar:gregorian_seconds_to_datetime(Now + Seconds)). datetime({{Y, M, D}, {H, Min, S}}) -> iolist_to_binary([date(Y, M, D), " ", two(H), ":", two(Min), ":", two(S)]). today_local() -> {{Y, M, D}, _} = calendar:local_time(), date(Y, M, D). monotonic_ms() -> erlang:monotonic_time(millisecond). shift_days_local(Days) when is_integer(Days) -> {{Y, M, D}, _} = calendar:local_time(), Greg = calendar:date_to_gregorian_days({Y, M, D}) + Days, {Y2, M2, D2} = calendar:gregorian_days_to_date(Greg), date(Y2, M2, D2). date(Y, M, D) -> iolist_to_binary([integer_to_binary(Y), "-", two(M), "-", two(D)]). two(N) when N < 10 -> <<"0", (integer_to_binary(N))/binary>>; two(N) -> integer_to_binary(N).