feat: 增加品牌通用扩展配置

This commit is contained in:
que01 committed 2026-09-21 14:10:25 +08:00
1 parent 270136d24e
commit 73e21e6b0d
5 files changed
+22 -1

No files matched your search

@@ -0,0 +1,11 @@
ALTER TABLE "BrandProfile" ADD COLUMN "config" JSONB;
UPDATE "BrandProfile"
SET "config" = jsonb_strip_nulls(jsonb_build_object(
'legacyIndustryFields', jsonb_strip_nulls(jsonb_build_object(
'hours', "hours",
'address', "address",
'deliveryNote', "deliveryNote"
))
))
WHERE "hours" IS NOT NULL OR "address" IS NOT NULL OR "deliveryNote" IS NOT NULL;
+1
View File
@@ -45,6 +45,7 @@ model BrandProfile {
deliveryNote String? deliveryNote String?
contactPhone String? contactPhone String?
contactWechat String? contactWechat String?
config Json?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
services Service[] services Service[]
+1
View File
@@ -23,6 +23,7 @@ export class UpdateBrandDto {
@IsOptional() @IsString() deliveryNote?: string; @IsOptional() @IsString() deliveryNote?: string;
@IsOptional() @IsString() contactPhone?: string; @IsOptional() @IsString() contactPhone?: string;
@IsOptional() @IsString() contactWechat?: string; @IsOptional() @IsString() contactWechat?: string;
@IsOptional() @IsObject() config?: Record<string, unknown>;
} }
export class UpdateServiceDto { export class UpdateServiceDto {
+8 -1
View File
@@ -465,7 +465,14 @@ export class AdminConfigController {
@Patch("brand") @Patch("brand")
updateBrand(@Req() request: FastifyRequest, @Body() body: UpdateBrandDto): Promise<unknown> { updateBrand(@Req() request: FastifyRequest, @Body() body: UpdateBrandDto): Promise<unknown> {
this.requireAdmin(request); this.requireAdmin(request);
return this.prisma.brandProfile.update({ where: { id: this.brandId() }, data: body }); const { config, ...fields } = body;
return this.prisma.brandProfile.update({
where: { id: this.brandId() },
data: {
...fields,
...(config ? { config: config as Prisma.InputJsonValue } : {}),
},
});
} }
@Get("trust-content") @Get("trust-content")
listTrustContent(@Req() request: FastifyRequest): Promise<unknown> { listTrustContent(@Req() request: FastifyRequest): Promise<unknown> {
+1
View File
@@ -22,6 +22,7 @@ export interface BrandProfile {
deliveryNote: string | null; deliveryNote: string | null;
contactPhone: string | null; contactPhone: string | null;
contactWechat: string | null; contactWechat: string | null;
config?: Record<string, unknown> | null;
} }
export type BrandUpdate = Partial<Omit<BrandProfile, "id">>; export type BrandUpdate = Partial<Omit<BrandProfile, "id">>;
export interface ServiceUpdate { export interface ServiceUpdate {