diff --git a/apps/api/package.json b/apps/api/package.json index dac199b..618e82c 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -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", diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index b86cf62..bc29914 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -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, diff --git a/packages/config/package.json b/packages/config/package.json index 7135611..1efebbb 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -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", diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts index 92ebf5f..81d0aab 100644 --- a/packages/config/src/index.ts +++ b/packages/config/src/index.ts @@ -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 = { + 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", + ], + }, +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 24b932f..17fbf69 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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)