49 lines
1.9 KiB
Python
49 lines
1.9 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
"""费用报销流程演示的一键入口。
|
|||
|
|
|
|||
|
|
cd backend/scripts
|
|||
|
|
python3 -m expense.cli config # 把演示账号并进数据库里的「应急账号」名单(保存即生效)
|
|||
|
|
python3 -m expense.cli org # 部门负责人 / 直属上级 / 岗位角色 / 分组 / 演示口令
|
|||
|
|
python3 -m expense.cli design # 字典 + 三张表单 + 主从流程,校验并发布
|
|||
|
|
python3 -m expense.cli run # 按场景把流程跑到每个阶段,数据留在库里
|
|||
|
|
python3 -m expense.cli report # 从库里重新导出一份现状快照
|
|||
|
|
python3 -m expense.cli all # org + design + run
|
|||
|
|
|
|||
|
|
对象名都是固定的(费用报销审批流程 等),重跑按名字复用,不会堆重复数据。
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
from __future__ import annotations
|
|||
|
|
|
|||
|
|
import argparse
|
|||
|
|
import sys
|
|||
|
|
|
|||
|
|
from . import common, design, org_setup, runner
|
|||
|
|
|
|||
|
|
|
|||
|
|
def main() -> int:
|
|||
|
|
parser = argparse.ArgumentParser(description="费用报销流程演示")
|
|||
|
|
parser.add_argument("step", choices=["config", "org", "design", "run", "report", "all"])
|
|||
|
|
parser.add_argument("--base", default="", help="接口地址,默认 http://127.0.0.1:8000/api/v1")
|
|||
|
|
parser.add_argument("--only", default="", help="只跑这几个场景,如 --only 5,6,7(配合 run 重跑)")
|
|||
|
|
args = parser.parse_args()
|
|||
|
|
if args.base:
|
|||
|
|
common.BASE = args.base
|
|||
|
|
print(f"接口:{common.BASE} 留档目录:{common.ROOT}")
|
|||
|
|
if args.step == "config":
|
|||
|
|
org_setup.ensure_local_accounts()
|
|||
|
|
return 0
|
|||
|
|
evidence = common.Evidence()
|
|||
|
|
if args.step in ("org", "all"):
|
|||
|
|
org_setup.run(evidence)
|
|||
|
|
if args.step in ("design", "all"):
|
|||
|
|
design.run(evidence)
|
|||
|
|
if args.step in ("run", "all"):
|
|||
|
|
runner.run(evidence, only=args.only)
|
|||
|
|
if args.step == "report":
|
|||
|
|
runner.report(evidence)
|
|||
|
|
return 0
|
|||
|
|
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
sys.exit(main())
|