feat(shop-role): 实现店铺角色继承功能和权限检查优化
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m39s

- 新增店铺角色管理 API 和数据模型
- 实现角色继承和权限检查逻辑
- 添加流程测试框架和集成测试
- 更新权限服务和账号管理逻辑
- 添加数据库迁移脚本
- 归档 OpenSpec 变更文档

Ultraworked with Sisyphus
This commit is contained in:
2026-02-03 10:06:13 +08:00
parent bc7e5d6f6d
commit 5a90caa619
61 changed files with 21284 additions and 131 deletions

View File

View File

@@ -0,0 +1,61 @@
"""
示例流程测试
本文件展示如何编写流程测试,供参考。
删除本文件后不影响测试框架运行。
"""
import pytest
class TestExampleFlow:
"""示例:账号登录流程"""
def test_admin_login_flow(self, client, auth):
"""
流程:超级管理员登录
步骤:
1. 使用超级管理员账号登录
2. 验证能获取用户信息
"""
# === 1. 登录 ===
auth.as_super_admin()
# === 2. 获取用户信息 ===
resp = client.get("/api/admin/auth/me")
# 如果接口存在,验证返回
if resp.status_code == 200:
assert resp.ok(), f"获取用户信息失败: {resp.msg}"
assert resp.data is not None
else:
pytest.skip("接口不存在,跳过测试")
@pytest.mark.skip(reason="示例测试,实际使用时删除此标记")
def test_create_shop_flow(self, client, auth, tracker):
"""
流程:创建店铺
步骤:
1. 平台管理员登录
2. 创建店铺
3. 验证店铺创建成功
"""
# === 1. 登录 ===
auth.as_platform_admin()
# === 2. 创建店铺 ===
resp = client.post("/api/admin/shops", json={
"shop_name": "测试店铺_流程测试",
"contact_name": "测试联系人",
"contact_phone": "13800138000",
})
assert resp.ok(), f"创建店铺失败: {resp.msg}"
shop_id = resp.data["id"]
tracker.track("tb_shop", shop_id)
# === 3. 验证店铺存在 ===
resp = client.get(f"/api/admin/shops/{shop_id}")
assert resp.ok()
assert resp.data["shop_name"] == "测试店铺_流程测试"