refactor: 拆分模板工作区服务并统一后台访问控制

This commit is contained in:
que01 committed 2026-10-23 12:26:37 +08:00
1 parent 5051839986
commit b4e3e86dcd
13 files changed
+441 -329

No files matched your search

@@ -2,24 +2,28 @@ import { AdminBrand, AdminRoles } from "../../admin-auth.decorators.js";
import { Body, Controller, Get, Post, Req } from "@nestjs/common";
import type { FastifyRequest } from "fastify";
import { RollbackTemplateDto, UpgradeTemplateDto } from "../../admin.dto.js";
import { TemplateWorkspaceService } from "../../template-workspace.service.js";
import { PageSchemeService } from "../../template/page-scheme.service.js";
import { TemplateInstallationService } from "../../template/template-installation.service.js";
import { requireAdminIdentity } from "../../admin-access.identity.js";
@AdminBrand()
@Controller("admin/workspace")
class AdminTemplateController {
constructor(private readonly templateWorkspace: TemplateWorkspaceService) {}
constructor(
private readonly pageSchemes: PageSchemeService,
private readonly templateInstallations: TemplateInstallationService,
) {}
@AdminRoles(["owner", "admin", "platform-admin"])
@Get("template/options")
options(@Req() request: FastifyRequest): Promise<unknown> {
return this.templateWorkspace.getPageSchemeOptions(requireAdminIdentity(request).brandId);
return this.pageSchemes.getPageSchemeOptions(requireAdminIdentity(request).brandId);
}
@AdminRoles(["owner", "admin", "platform-admin"])
@Get("template/preview")
preview(@Req() request: FastifyRequest): Promise<unknown> {
return this.templateWorkspace.preview(requireAdminIdentity(request).brandId);
return this.templateInstallations.preview(requireAdminIdentity(request).brandId);
}
@AdminRoles(["owner", "admin", "platform-admin"])
@@ -30,7 +34,7 @@ class AdminTemplateController {
): Promise<unknown> {
const identity = requireAdminIdentity(request);
const requestId = request.headers["x-request-id"]?.toString() ?? request.id;
return this.templateWorkspace.upgrade(identity.brandId, body, identity.subject, requestId);
return this.templateInstallations.upgrade(identity.brandId, body, identity.subject, requestId);
}
@AdminRoles(["owner", "admin", "platform-admin"])
@@ -41,7 +45,7 @@ class AdminTemplateController {
): Promise<unknown> {
const identity = requireAdminIdentity(request);
const requestId = request.headers["x-request-id"]?.toString() ?? request.id;
return this.templateWorkspace.rollback(identity.brandId, identity.subject, body, requestId);
return this.templateInstallations.rollback(identity.brandId, identity.subject, body, requestId);
}
}