refactor: 拆分公开内容控制器
This commit is contained in:
1 parent
464c706021
commit
41ab3b6d23
3 files changed
+99
-81
No files matched your search
@@ -14,6 +14,7 @@
|
|||||||
- `CustomerSessionController` 和 `AdminSessionController` 已迁移到 `modules/session/session.controller.ts`。
|
- `CustomerSessionController` 和 `AdminSessionController` 已迁移到 `modules/session/session.controller.ts`。
|
||||||
- `AdminBookingController` 已迁移到 `modules/admin/admin-booking.controller.ts`。
|
- `AdminBookingController` 已迁移到 `modules/admin/admin-booking.controller.ts`。
|
||||||
- `CustomerBookingController` 已迁移到 `modules/customer/customer-booking.controller.ts`。
|
- `CustomerBookingController` 已迁移到 `modules/customer/customer-booking.controller.ts`。
|
||||||
|
- `PublicController`、`PublicTrustContentController`、`PublicTemplateController` 已迁移到 `modules/public/public.controller.ts`。
|
||||||
- 新增 `GET /admin/brands` 和 `POST /admin/brands/:brandId/switch`,切换由 membership 服务端校验。
|
- 新增 `GET /admin/brands` 和 `POST /admin/brands/:brandId/switch`,切换由 membership 服务端校验。
|
||||||
- seed 已增加第二个独立品牌 `林境门作`(slug:`linjing-doors`),并绑定同一管理员的独立 membership。
|
- seed 已增加第二个独立品牌 `林境门作`(slug:`linjing-doors`),并绑定同一管理员的独立 membership。
|
||||||
- 修复多品牌出现后 `findFirst()` 导致默认品牌串线的问题,默认公开品牌和客户会话现在使用 `DEFAULT_BRAND_ID`。
|
- 修复多品牌出现后 `findFirst()` 导致默认品牌串线的问题,默认公开品牌和客户会话现在使用 `DEFAULT_BRAND_ID`。
|
||||||
+5
-81
@@ -48,6 +48,11 @@ import {
|
|||||||
import { AdminBookingController } from "./modules/admin/admin-booking.controller.js";
|
import { AdminBookingController } from "./modules/admin/admin-booking.controller.js";
|
||||||
import { CustomerBookingController } from "./modules/customer/customer-booking.controller.js";
|
import { CustomerBookingController } from "./modules/customer/customer-booking.controller.js";
|
||||||
import { TenantController } from "./modules/tenant/tenant.controller.js";
|
import { TenantController } from "./modules/tenant/tenant.controller.js";
|
||||||
|
import {
|
||||||
|
PublicController,
|
||||||
|
PublicTemplateController,
|
||||||
|
PublicTrustContentController,
|
||||||
|
} from "./modules/public/public.controller.js";
|
||||||
import type {
|
import type {
|
||||||
RuntimeInquiryField,
|
RuntimeInquiryField,
|
||||||
RuntimeOffering,
|
RuntimeOffering,
|
||||||
@@ -63,87 +68,6 @@ export class HealthController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Controller("public")
|
|
||||||
export class PublicController {
|
|
||||||
constructor(private readonly prisma: PrismaService) {}
|
|
||||||
|
|
||||||
@Get("brand")
|
|
||||||
async brand(): Promise<unknown> {
|
|
||||||
return this.prisma.brandProfile.findUnique({
|
|
||||||
where: {
|
|
||||||
id: process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001",
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
name: true,
|
|
||||||
templateKey: true,
|
|
||||||
tagline: true,
|
|
||||||
description: true,
|
|
||||||
avatarUrl: true,
|
|
||||||
coverUrl: true,
|
|
||||||
hours: true,
|
|
||||||
address: true,
|
|
||||||
deliveryNote: true,
|
|
||||||
contactPhone: true,
|
|
||||||
contactWechat: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Controller("public/trust-content")
|
|
||||||
export class PublicTrustContentController {
|
|
||||||
constructor(private readonly prisma: PrismaService) {}
|
|
||||||
@Get()
|
|
||||||
list(): Promise<unknown> {
|
|
||||||
return this.prisma.trustContent.findMany({
|
|
||||||
where: {
|
|
||||||
brandId: process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001",
|
|
||||||
isPublished: true,
|
|
||||||
},
|
|
||||||
orderBy: [{ type: "asc" }, { sortOrder: "asc" }],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Controller("public/templates")
|
|
||||||
export class PublicTemplateController {
|
|
||||||
@Get()
|
|
||||||
list(): unknown {
|
|
||||||
return { industries: Object.values(brandTemplates), visuals: Object.values(visualTemplates) };
|
|
||||||
}
|
|
||||||
@Get("preview")
|
|
||||||
preview(
|
|
||||||
@Query("industry") industry = "personal",
|
|
||||||
@Query("visual") visual = "linjing-editorial",
|
|
||||||
): unknown {
|
|
||||||
const industryTemplate = getBrandTemplate(industry);
|
|
||||||
const visualTemplate = getVisualTemplate(visual) ?? getVisualTemplate("linjing-editorial");
|
|
||||||
if (!industryTemplate || !visualTemplate) throw new BadRequestException("模板组合不存在");
|
|
||||||
return {
|
|
||||||
industry: industryTemplate,
|
|
||||||
visual: visualTemplate,
|
|
||||||
runtime: {
|
|
||||||
schemaVersion: "1.0.0",
|
|
||||||
modules: industryTemplate.modules.map((module) => ({
|
|
||||||
key: module.key,
|
|
||||||
type: module.type,
|
|
||||||
title: module.title,
|
|
||||||
variant: visualTemplate.variants[module.type] ?? "default",
|
|
||||||
})),
|
|
||||||
capabilities: resolveCapabilities(industryTemplate.capabilities),
|
|
||||||
theme: visualTemplate.theme,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@Get(":key")
|
|
||||||
get(@Param("key") key: string): unknown {
|
|
||||||
const template = getBrandTemplate(key);
|
|
||||||
if (!template) throw new BadRequestException("行业模板不存在");
|
|
||||||
return template;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Controller("public/workspace")
|
@Controller("public/workspace")
|
||||||
export class PublicWorkspaceController {
|
export class PublicWorkspaceController {
|
||||||
constructor(private readonly prisma: PrismaService) {}
|
constructor(private readonly prisma: PrismaService) {}
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import { BadRequestException, Controller, Get, Param, Query } from "@nestjs/common";
|
||||||
|
import { PrismaService } from "../../prisma.service.js";
|
||||||
|
import {
|
||||||
|
brandTemplates,
|
||||||
|
getBrandTemplate,
|
||||||
|
getVisualTemplate,
|
||||||
|
resolveCapabilities,
|
||||||
|
visualTemplates,
|
||||||
|
} from "@personal-brand/config";
|
||||||
|
|
||||||
|
@Controller("public")
|
||||||
|
export class PublicController {
|
||||||
|
constructor(private readonly prisma: PrismaService) {}
|
||||||
|
|
||||||
|
@Get("brand")
|
||||||
|
async brand(): Promise<unknown> {
|
||||||
|
return this.prisma.brandProfile.findUnique({
|
||||||
|
where: {
|
||||||
|
id: process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001",
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
templateKey: true,
|
||||||
|
tagline: true,
|
||||||
|
description: true,
|
||||||
|
avatarUrl: true,
|
||||||
|
coverUrl: true,
|
||||||
|
hours: true,
|
||||||
|
address: true,
|
||||||
|
deliveryNote: true,
|
||||||
|
contactPhone: true,
|
||||||
|
contactWechat: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Controller("public/trust-content")
|
||||||
|
export class PublicTrustContentController {
|
||||||
|
constructor(private readonly prisma: PrismaService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
list(): Promise<unknown> {
|
||||||
|
return this.prisma.trustContent.findMany({
|
||||||
|
where: {
|
||||||
|
brandId: process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001",
|
||||||
|
isPublished: true,
|
||||||
|
},
|
||||||
|
orderBy: [{ type: "asc" }, { sortOrder: "asc" }],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Controller("public/templates")
|
||||||
|
export class PublicTemplateController {
|
||||||
|
@Get()
|
||||||
|
list(): unknown {
|
||||||
|
return { industries: Object.values(brandTemplates), visuals: Object.values(visualTemplates) };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get("preview")
|
||||||
|
preview(
|
||||||
|
@Query("industry") industry = "personal",
|
||||||
|
@Query("visual") visual = "linjing-editorial",
|
||||||
|
): unknown {
|
||||||
|
const industryTemplate = getBrandTemplate(industry);
|
||||||
|
const visualTemplate = getVisualTemplate(visual) ?? getVisualTemplate("linjing-editorial");
|
||||||
|
if (!industryTemplate || !visualTemplate) throw new BadRequestException("模板组合不存在");
|
||||||
|
return {
|
||||||
|
industry: industryTemplate,
|
||||||
|
visual: visualTemplate,
|
||||||
|
runtime: {
|
||||||
|
schemaVersion: "1.0.0",
|
||||||
|
modules: industryTemplate.modules.map((module) => ({
|
||||||
|
key: module.key,
|
||||||
|
type: module.type,
|
||||||
|
title: module.title,
|
||||||
|
variant: visualTemplate.variants[module.type] ?? "default",
|
||||||
|
})),
|
||||||
|
capabilities: resolveCapabilities(industryTemplate.capabilities),
|
||||||
|
theme: visualTemplate.theme,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(":key")
|
||||||
|
get(@Param("key") key: string): unknown {
|
||||||
|
const template = getBrandTemplate(key);
|
||||||
|
if (!template) throw new BadRequestException("行业模板不存在");
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user