fix: 完成品牌配置与信任内容隔离

This commit is contained in:
que01 committed 2026-09-23 02:23:09 +08:00
1 parent 6835a2b0fd
commit d5e1543e60
1 file changed
+9 -9
+9 -9
View File
@@ -728,7 +728,7 @@ export class AdminConfigController {
const nextConfig = config ? { ...currentConfig, ...config } : undefined;
if (config?.visualTemplateKey && config.visualTemplateKey !== currentConfig.visualTemplateKey) {
const installation = await this.prisma.brandTemplateInstallation.findFirst({
where: { brandId: this.brandId() },
where: { brandId: this.brandId(request) },
});
if (installation) {
const history = Array.isArray(installation.previousSnapshots)
@@ -749,7 +749,7 @@ export class AdminConfigController {
}
}
return this.prisma.brandProfile.update({
where: { id: this.brandId() },
where: { id: this.brandId(request) },
data: {
...fields,
...(nextConfig ? { config: nextConfig as Prisma.InputJsonValue } : {}),
@@ -760,7 +760,7 @@ export class AdminConfigController {
getVisualTemplateHistory(@Req() request: FastifyRequest): unknown {
this.requireAdmin(request);
return this.prisma.brandTemplateInstallation
.findFirst({ where: { brandId: this.brandId() }, select: { previousSnapshots: true } })
.findFirst({ where: { brandId: this.brandId(request) }, select: { previousSnapshots: true } })
.then((installation) => ({
history: Array.isArray(installation?.previousSnapshots)
? installation.previousSnapshots.filter(
@@ -776,7 +776,7 @@ export class AdminConfigController {
@Post("visual-template/rollback")
async rollbackVisualTemplate(@Req() request: FastifyRequest): Promise<unknown> {
this.requireAdmin(request);
const brandId = this.brandId();
const brandId = this.brandId(request);
const [brand, installation] = await Promise.all([
this.prisma.brandProfile.findUnique({ where: { id: brandId }, select: { config: true } }),
this.prisma.brandTemplateInstallation.findFirst({ where: { brandId } }),
@@ -824,7 +824,7 @@ export class AdminConfigController {
getVisualTemplatePreview(@Req() request: FastifyRequest): unknown {
this.requireAdmin(request);
return this.prisma.brandProfile
.findUnique({ where: { id: this.brandId() }, select: { config: true } })
.findUnique({ where: { id: this.brandId(request) }, select: { config: true } })
.then((brand) => {
const config =
brand?.config && typeof brand.config === "object" && !Array.isArray(brand.config)
@@ -853,7 +853,7 @@ export class AdminConfigController {
listTrustContent(@Req() request: FastifyRequest): Promise<unknown> {
this.requireAdmin(request);
return this.prisma.trustContent.findMany({
where: { brandId: this.brandId() },
where: { brandId: this.brandId(request) },
orderBy: [{ type: "asc" }, { sortOrder: "asc" }],
});
}
@@ -867,7 +867,7 @@ export class AdminConfigController {
return this.prisma.trustContent.create({
data: {
...fields,
brandId: this.brandId(),
brandId: this.brandId(request),
...(config === undefined ? {} : { config: config as Prisma.InputJsonValue }),
},
});
@@ -880,7 +880,7 @@ export class AdminConfigController {
): Promise<unknown> {
this.requireAdmin(request);
const item = await this.prisma.trustContent.findFirst({
where: { id, brandId: this.brandId() },
where: { id, brandId: this.brandId(request) },
});
if (!item) throw new BadRequestException("信任内容不存在");
const { config, ...fields } = body;
@@ -899,7 +899,7 @@ export class AdminConfigController {
): Promise<unknown> {
this.requireAdmin(request);
const item = await this.prisma.trustContent.findFirst({
where: { id, brandId: this.brandId() },
where: { id, brandId: this.brandId(request) },
});
if (!item) throw new BadRequestException("信任内容不存在");
await this.prisma.trustContent.delete({ where: { id } });