feat: 增加可替换行业模板定义接口

This commit is contained in:
que01 committed 2026-09-19 21:20:20 +08:00
1 parent 2b1035dbc8
commit c6785892ed
5 files changed
+61

No files matched your search

+1
View File
@@ -20,6 +20,7 @@
"@nestjs/common": "^11.0.11",
"@nestjs/core": "^11.0.11",
"@nestjs/platform-fastify": "^11.0.11",
"@personal-brand/config": "workspace:^",
"@prisma/client": "^6.2.1",
"bcryptjs": "^2.4.3",
"class-transformer": "^0.5.1",
+12
View File
@@ -41,6 +41,7 @@ import type { TransformFnParams } from "class-transformer";
import { IsBoolean, IsEnum, IsOptional, IsString } from "class-validator";
import { readIdentity, signIdentity } from "./auth.js";
import { ApiExceptionFilter, RequestIdMiddleware } from "./http.js";
import { brandTemplates, type BrandTemplateKey } from "@personal-brand/config";
@Controller("health")
export class HealthController {
@@ -109,6 +110,16 @@ export class PublicTrustContentController {
}
}
@Controller("public/templates")
export class PublicTemplateController {
@Get(":key")
get(@Param("key") key: string): unknown {
const template = brandTemplates[key as BrandTemplateKey];
if (!template) throw new BadRequestException("行业模板不存在");
return template;
}
}
@Controller("customer/session")
export class CustomerSessionController {
constructor(
@@ -441,6 +452,7 @@ export class AdminConfigController {
HealthController,
PublicController,
PublicTrustContentController,
PublicTemplateController,
CustomerSessionController,
AdminSessionController,
CustomerBookingController,
+6
View File
@@ -2,6 +2,12 @@
"name": "@personal-brand/config",
"private": true,
"type": "module",
"exports": {
".": {
"types": "./src/index.ts",
"import": "./src/index.ts"
}
},
"scripts": {
"lint": "eslint .",
"typecheck": "tsc -p tsconfig.json --noEmit",
+39
View File
@@ -1 +1,40 @@
export const configPackageName = "personal-brand-config";
export type BrandTemplateKey = "personal" | "food";
export interface BrandTemplateDefinition {
key: BrandTemplateKey;
name: string;
description: string;
serviceCategories: string[];
trustContentTypes: string[];
}
export const brandTemplates: Record<BrandTemplateKey, BrandTemplateDefinition> = {
personal: {
key: "personal",
name: "个人品牌",
description: "围绕定位、信任、作品与合作建立个人品牌。",
serviceCategories: ["consulting", "collaboration", "custom"],
trustContentTypes: [
"profile",
"experience",
"credential",
"portfolio",
"process",
"testimonial",
],
},
food: {
key: "food",
name: "餐饮模板",
description: "适用于餐饮服务与套餐预约的行业模板。",
serviceCategories: ["food-package", "private-chef", "custom"],
trustContentTypes: [
"profile",
"experience",
"credential",
"portfolio",
"process",
"testimonial",
],
},
};
+3
View File
@@ -75,6 +75,9 @@ importers:
'@nestjs/platform-fastify':
specifier: ^11.0.11
version: 11.2.5(@nestjs/common@11.2.5(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.2.5(@nestjs/common@11.2.5(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2))(reflect-metadata@0.2.2)(rxjs@7.8.2))
'@personal-brand/config':
specifier: workspace:^
version: link:../../packages/config
'@prisma/client':
specifier: ^6.2.1
version: 6.19.3(prisma@6.19.3(typescript@5.9.3))(typescript@5.9.3)