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