fix: 收口模板主模板策略与提供项响应契约

This commit is contained in:
que01 committed 2026-09-20 09:54:35 +08:00
1 parent 7e83d16cc9
commit 4470302b3f
2 files changed
+23 -6

No files matched your search

+17 -6
View File
@@ -184,12 +184,21 @@ export class AdminWorkspaceController {
}
@Get("offerings")
listOfferings(@Req() request: FastifyRequest): Promise<unknown> {
async listOfferings(@Req() request: FastifyRequest): Promise<unknown> {
this.requireAdmin(request);
return this.prisma.offering.findMany({
const items = await this.prisma.offering.findMany({
where: { brandId: this.brandId() },
orderBy: { sortOrder: "asc" },
});
return items.map((item) => {
const config = (item.config ?? {}) as Record<string, unknown>;
return {
...item,
sections: config.sections ?? [],
media: config.media ?? [],
cta: config.cta ?? null,
};
});
}
@Post("offerings")
@@ -279,10 +288,12 @@ export class AdminWorkspaceController {
this.requireAdmin(request);
const brandId = this.brandId();
const template = brandTemplates[body.templateKey];
const existing = await this.prisma.brandTemplateInstallation.findUnique({
where: { brandId_templateKey: { brandId, templateKey: body.templateKey } },
});
if (existing) throw new BadRequestException("该模板已经安装");
const existing = await this.prisma.brandTemplateInstallation.findFirst({ where: { brandId } });
if (existing) {
if (existing.templateKey === body.templateKey)
throw new BadRequestException("该模板已经安装");
throw new BadRequestException("品牌已经安装主模板,请先完成模板切换流程");
}
const modules = [
["text", "品牌介绍"],
["trust-content", "信任证明"],