feat: Add quota check decorator and implement tenant-level API rate limiting

- Add quota check decorator module quota_stub.py, providing community edition stub implementation
- Add quota check decorators to multiple controllers
- Implement tenant-level API call rate limiting
- Remove redundant plan fields from tenant_model.py
- Optimize user permission check logic with added error handling
This commit is contained in:
wxy
2026-04-13 11:58:14 +08:00
parent 807dee8460
commit 72be9f75f9
15 changed files with 140 additions and 10 deletions

View File

@@ -29,11 +29,8 @@ class Tenants(Base):
contact_email = Column(String(255), nullable=True) # 联系人邮箱
contact_phone = Column(String(50), nullable=True) # 联系人电话
# 租户套餐信息
plan = Column(String(50), nullable=True) # 套餐类型
plan_expired_at = Column(DateTime, nullable=True) # 套餐到期时间
api_ops_rate_limit = Column(String(100), nullable=True) # API 调用频率限制
status = Column(String(50), nullable=True, default='active') # 租户状态
# 租户套餐信息(只读,从 tenant_subscriptions 动态获取)
status = Column(String(50), nullable=True, default='active', server_default='active') # 租户状态
# Relationship to users - one tenant has many users
users = relationship("User", back_populates="tenant")