feat: migrate ORM base to sqlmodel-ext, add file viewers and WOPI integration
All checks were successful
Test / test (push) Successful in 1m45s

- Migrate SQLModel base classes, mixins, and database management to
  external sqlmodel-ext package; remove sqlmodels/base/, sqlmodels/mixin/,
  and sqlmodels/database.py
- Add file viewer/editor system with WOPI protocol support for
  collaborative editing (OnlyOffice, Collabora)
- Add enterprise edition license verification module (ee/)
- Add Dockerfile multi-stage build with Cython compilation support
- Add new dependencies: sqlmodel-ext, cryptography, whatthepatch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 14:23:17 +08:00
parent 53b757de7a
commit ccadfe57cd
81 changed files with 5106 additions and 4837 deletions

View File

@@ -0,0 +1,49 @@
"""
许可证加载与缓存服务(编译为 .so
从环境变量 LICENSE_KEY 或 license.key 文件加载许可证,
调用 verify_license() 验证后缓存结果。
"""
import os
from pathlib import Path
import aiofiles
from ee.license import LicenseError, verify_license
from ee.service import LicensePayload
_cached_payload: LicensePayload | None = None
async def load_and_validate_license() -> LicensePayload:
"""
加载并验证许可证,成功后缓存。
加载优先级:
1. 环境变量 ``LICENSE_KEY``
2. 项目根目录 ``license.key`` 文件
:returns: 验证通过的 LicensePayload
:raises LicenseError: 未找到许可证 / 验证失败 / 已过期
"""
global _cached_payload
raw: str | None = os.getenv("LICENSE_KEY")
if not raw:
key_path = Path("license.key")
if key_path.is_file():
async with aiofiles.open(key_path, 'r') as f:
raw = (await f.read()).strip()
if not raw:
raise LicenseError("未找到许可证:请设置 LICENSE_KEY 环境变量或提供 license.key 文件")
data = verify_license(raw)
_cached_payload = LicensePayload.model_validate(data)
return _cached_payload
def get_cached_license() -> LicensePayload | None:
"""获取已缓存的许可证载荷(未加载时返回 None"""
return _cached_payload