fix: 使用管理员品牌上下文管理能力
This commit is contained in:
1 parent
ee3bd9051b
commit
7451268e59
1 file changed
+5
-7
@@ -171,13 +171,12 @@ class AdminWorkspaceController {
|
||||
@Body() body: InstallTemplateDto,
|
||||
): Promise<unknown> {
|
||||
this.requireAdmin(request);
|
||||
return this.templateWorkspace.install(this.brandId(), body.templateKey);
|
||||
return this.templateWorkspace.install(this.requireAdmin(request).brandId, body.templateKey);
|
||||
}
|
||||
|
||||
@Get("capabilities")
|
||||
async listCapabilities(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
this.requireAdmin(request);
|
||||
const brandId = this.brandId();
|
||||
const brandId = this.requireAdmin(request).brandId;
|
||||
const [brand, installations] = await Promise.all([
|
||||
this.prisma.brandProfile.findUnique({
|
||||
where: { id: brandId },
|
||||
@@ -203,8 +202,7 @@ class AdminWorkspaceController {
|
||||
|
||||
@Get("sample-content/preview")
|
||||
async previewSampleContent(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
this.requireAdmin(request);
|
||||
const brandId = this.brandId();
|
||||
const brandId = this.requireAdmin(request).brandId;
|
||||
const [offerings, trustContent, fields] = await Promise.all([
|
||||
this.prisma.offering.count({ where: { brandId } }),
|
||||
this.prisma.trustContent.count({ where: { brandId } }),
|
||||
@@ -220,7 +218,7 @@ class AdminWorkspaceController {
|
||||
@Post("sample-content/import")
|
||||
async importSampleContent(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
const identity = this.requireAdmin(request);
|
||||
const brandId = this.brandId();
|
||||
const brandId = identity.brandId;
|
||||
const existing = await this.prisma.brandFieldDefinition.count({
|
||||
where: { brandId, source: "sample" },
|
||||
});
|
||||
@@ -296,7 +294,7 @@ class AdminWorkspaceController {
|
||||
@Body() body: UpdateCapabilityInstallationDto,
|
||||
): Promise<unknown> {
|
||||
const identity = this.requireAdmin(request);
|
||||
const brandId = this.brandId();
|
||||
const brandId = identity.brandId;
|
||||
const brand = await this.prisma.brandProfile.findUnique({ where: { id: brandId } });
|
||||
const template = getBrandTemplate(brand?.templateKey ?? "personal");
|
||||
if (!template?.capabilities.includes(key as never) && !(key in capabilityPlugins))
|
||||
|
||||
Reference in new issue
Block a user