refactor: establish standalone application boundary

This commit is contained in:
leefer
2026-08-03 21:42:25 +08:00
parent cc5fb8d73e
commit e1e76cd51e
324 changed files with 63090 additions and 44743 deletions
+40
View File
@@ -0,0 +1,40 @@
from __future__ import annotations
from datetime import datetime
from http import HTTPStatus
class SystemRoutesMixin:
def _handle_system_public_get(self, parsed) -> bool:
if parsed.path == "/api/health":
self.send_json(
{
"ok": True,
"storage": "sqlite",
"account_required": True,
"time": datetime.now().astimezone().isoformat(timespec="seconds"),
}
)
return True
return False
def _handle_system_get(self, parsed) -> bool:
if parsed.path == "/api/admin/settings":
self.send_json(
{"ok": True, **self.application_service.system_status(), "users": self.application_service.admin_users()}
)
return True
return False
def backfill_data(self) -> None:
try:
body = self.read_json_body()
results = self.application_service.backfill(
str(body.get("start_date") or ""),
str(body.get("end_date") or ""),
)
self.send_json({"ok": True, "results": results})
except ValueError as exc:
self.send_json({"error": str(exc)}, HTTPStatus.BAD_REQUEST)
except Exception as exc:
self.send_json({"error": f"历史回补失败:{exc}"}, HTTPStatus.INTERNAL_SERVER_ERROR)