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

@@ -0,0 +1,37 @@
# 本地开发环境配置
# 使用方式: TEST_ENV=local pytest (默认)
api:
base_url: "http://localhost:3000"
timeout: 30
database:
host: "localhost"
port: 5432
name: "junhong_dev"
user: "postgres"
password: "postgres"
redis:
host: "localhost"
port: 6379
db: 0
# 预置测试账号
# 根据实际系统配置修改
accounts:
super_admin:
username: "superadmin"
password: "Admin123456"
platform_admin:
username: "platform"
password: "Admin123456"
# Mock 配置
mock:
# 是否启用 Mock 模式(跳过真实第三方调用)
enabled: true
# 支付回调 Mock
payment:
auto_success: true
delay_seconds: 1

View File

@@ -0,0 +1,34 @@
# 远程测试环境配置
# 使用方式: TEST_ENV=remote pytest
api:
base_url: "https://test-api.example.com"
timeout: 30
database:
host: "test-db.example.com"
port: 5432
name: "junhong_test"
user: "test_user"
password: "test_password"
redis:
host: "test-redis.example.com"
port: 6379
db: 0
# 预置测试账号
accounts:
super_admin:
username: "superadmin"
password: "Admin123456"
platform_admin:
username: "platform"
password: "Admin123456"
# Mock 配置
mock:
enabled: true
payment:
auto_success: true
delay_seconds: 1

View File

@@ -0,0 +1,95 @@
"""
配置管理模块
支持多环境配置切换:
- TEST_ENV=local 使用本地配置(默认)
- TEST_ENV=remote 使用远程配置
"""
import os
from pathlib import Path
from typing import Any, Optional
import yaml
class Settings:
"""配置管理器"""
_instance: Optional['Settings'] = None
_config: dict = {}
def __new__(cls):
if cls._instance is None:
cls._instance = super().__new__(cls)
cls._instance._load_config()
return cls._instance
def _load_config(self):
"""加载配置文件"""
env = os.getenv("TEST_ENV", "local")
config_dir = Path(__file__).parent
config_file = config_dir / f"{env}.yaml"
if not config_file.exists():
raise FileNotFoundError(f"配置文件不存在: {config_file}")
with open(config_file, "r", encoding="utf-8") as f:
self._config = yaml.safe_load(f)
print(f"[配置] 已加载 {env} 环境配置")
def get(self, key: str, default: Any = None) -> Any:
"""
获取配置值,支持点号分隔的路径
示例:
settings.get("api.base_url")
settings.get("database.host")
"""
keys = key.split(".")
value = self._config
for k in keys:
if isinstance(value, dict):
value = value.get(k)
else:
return default
if value is None:
return default
return value
@property
def api_base_url(self) -> str:
return self.get("api.base_url", "http://localhost:3000")
@property
def api_timeout(self) -> int:
return self.get("api.timeout", 30)
@property
def db_config(self) -> dict:
return {
"host": self.get("database.host", "localhost"),
"port": self.get("database.port", 5432),
"database": self.get("database.name", "junhong_dev"),
"user": self.get("database.user", "postgres"),
"password": self.get("database.password", "postgres"),
}
@property
def redis_config(self) -> dict:
return {
"host": self.get("redis.host", "localhost"),
"port": self.get("redis.port", 6379),
"db": self.get("redis.db", 0),
}
def get_account(self, role: str) -> dict:
"""获取预置账号信息"""
return self.get(f"accounts.{role}", {})
# 全局配置实例
settings = Settings()