fix: 使用管理员品牌上下文管理能力

This commit is contained in:
que01 committed 2026-09-23 02:14:15 +08:00
1 parent ee3bd9051b
commit 7451268e59
1 file changed
+5 -7
+5 -7
View File
@@ -171,13 +171,12 @@ class AdminWorkspaceController {
@Body() body: InstallTemplateDto, @Body() body: InstallTemplateDto,
): Promise<unknown> { ): Promise<unknown> {
this.requireAdmin(request); this.requireAdmin(request);
return this.templateWorkspace.install(this.brandId(), body.templateKey); return this.templateWorkspace.install(this.requireAdmin(request).brandId, body.templateKey);
} }
@Get("capabilities") @Get("capabilities")
async listCapabilities(@Req() request: FastifyRequest): Promise<unknown> { async listCapabilities(@Req() request: FastifyRequest): Promise<unknown> {
this.requireAdmin(request); const brandId = this.requireAdmin(request).brandId;
const brandId = this.brandId();
const [brand, installations] = await Promise.all([ const [brand, installations] = await Promise.all([
this.prisma.brandProfile.findUnique({ this.prisma.brandProfile.findUnique({
where: { id: brandId }, where: { id: brandId },
@@ -203,8 +202,7 @@ class AdminWorkspaceController {
@Get("sample-content/preview") @Get("sample-content/preview")
async previewSampleContent(@Req() request: FastifyRequest): Promise<unknown> { async previewSampleContent(@Req() request: FastifyRequest): Promise<unknown> {
this.requireAdmin(request); const brandId = this.requireAdmin(request).brandId;
const brandId = this.brandId();
const [offerings, trustContent, fields] = await Promise.all([ const [offerings, trustContent, fields] = await Promise.all([
this.prisma.offering.count({ where: { brandId } }), this.prisma.offering.count({ where: { brandId } }),
this.prisma.trustContent.count({ where: { brandId } }), this.prisma.trustContent.count({ where: { brandId } }),
@@ -220,7 +218,7 @@ class AdminWorkspaceController {
@Post("sample-content/import") @Post("sample-content/import")
async importSampleContent(@Req() request: FastifyRequest): Promise<unknown> { async importSampleContent(@Req() request: FastifyRequest): Promise<unknown> {
const identity = this.requireAdmin(request); const identity = this.requireAdmin(request);
const brandId = this.brandId(); const brandId = identity.brandId;
const existing = await this.prisma.brandFieldDefinition.count({ const existing = await this.prisma.brandFieldDefinition.count({
where: { brandId, source: "sample" }, where: { brandId, source: "sample" },
}); });
@@ -296,7 +294,7 @@ class AdminWorkspaceController {
@Body() body: UpdateCapabilityInstallationDto, @Body() body: UpdateCapabilityInstallationDto,
): Promise<unknown> { ): Promise<unknown> {
const identity = this.requireAdmin(request); const identity = this.requireAdmin(request);
const brandId = this.brandId(); const brandId = identity.brandId;
const brand = await this.prisma.brandProfile.findUnique({ where: { id: brandId } }); const brand = await this.prisma.brandProfile.findUnique({ where: { id: brandId } });
const template = getBrandTemplate(brand?.templateKey ?? "personal"); const template = getBrandTemplate(brand?.templateKey ?? "personal");
if (!template?.capabilities.includes(key as never) && !(key in capabilityPlugins)) if (!template?.capabilities.includes(key as never) && !(key in capabilityPlugins))