feat: 增加个人品牌信任内容管理接口
This commit is contained in:
1 parent
60db0a85db
commit
b7fbfa1646
5 files changed
+60
-1
No files matched your search
@@ -40,6 +40,17 @@ export class CreateServiceDto {
|
||||
@IsOptional() config?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class CreateTrustContentDto {
|
||||
@IsIn(["profile", "experience", "credential", "portfolio", "process", "testimonial"]) type!: string;
|
||||
@IsString() title!: string;
|
||||
@IsOptional() @IsString() summary?: string;
|
||||
@IsString() content!: string;
|
||||
@IsOptional() @IsString() coverUrl?: string;
|
||||
@IsOptional() @IsInt() @Min(0) @Max(9999) sortOrder?: number;
|
||||
@IsOptional() @IsBoolean() isPublished?: boolean;
|
||||
@IsOptional() config?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class UpdateBookingStatusDto {
|
||||
@IsIn(["received", "contacting", "confirmed", "completed", "cancelled"])
|
||||
status!: "received" | "contacting" | "confirmed" | "completed" | "cancelled";
|
||||
|
||||
+10
-1
@@ -3,6 +3,7 @@ import {
|
||||
BadRequestException,
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Module,
|
||||
Param,
|
||||
@@ -20,7 +21,7 @@ import { PrismaService } from "./prisma.service.js";
|
||||
import { WechatAuthService } from "./wechat-auth.js";
|
||||
import { BookingService } from "./booking.service.js";
|
||||
import { CreateBookingDto } from "./booking.dto.js";
|
||||
import { CreateServiceDto, CreateTagDto, UpdateBookingStatusDto, UpdateBookingTagsDto, UpdateBrandDto, UpdateServiceDto } from "./admin.dto.js";
|
||||
import { CreateServiceDto, CreateTagDto, CreateTrustContentDto, UpdateBookingStatusDto, UpdateBookingTagsDto, UpdateBrandDto, UpdateServiceDto } from "./admin.dto.js";
|
||||
import { AdminAuthService } from "./admin-auth.service.js";
|
||||
import { AdminLoginDto } from "./admin-auth.dto.js";
|
||||
import type { FastifyRequest } from "fastify";
|
||||
@@ -296,6 +297,14 @@ export class AdminConfigController {
|
||||
getBrand(@Req() request: FastifyRequest): Promise<unknown> { this.requireAdmin(request); return this.prisma.brandProfile.findUnique({ where: { id: this.brandId() } }); }
|
||||
@Patch("brand")
|
||||
updateBrand(@Req() request: FastifyRequest, @Body() body: UpdateBrandDto): Promise<unknown> { this.requireAdmin(request); return this.prisma.brandProfile.update({ where: { id: this.brandId() }, data: body }); }
|
||||
@Get("trust-content")
|
||||
listTrustContent(@Req() request: FastifyRequest): Promise<unknown> { this.requireAdmin(request); return this.prisma.trustContent.findMany({ where: { brandId: this.brandId() }, orderBy: [{ type: "asc" }, { sortOrder: "asc" }] }); }
|
||||
@Post("trust-content")
|
||||
createTrustContent(@Req() request: FastifyRequest, @Body() body: CreateTrustContentDto): Promise<unknown> { this.requireAdmin(request); const { config, ...fields } = body; return this.prisma.trustContent.create({ data: { ...fields, brandId: this.brandId(), ...(config === undefined ? {} : { config: config as Prisma.InputJsonValue }) } }); }
|
||||
@Patch("trust-content/:id")
|
||||
async updateTrustContent(@Req() request: FastifyRequest, @Param("id") id: string, @Body() body: Partial<CreateTrustContentDto>): Promise<unknown> { this.requireAdmin(request); const item = await this.prisma.trustContent.findFirst({ where: { id, brandId: this.brandId() } }); if (!item) throw new BadRequestException("信任内容不存在"); const { config, ...fields } = body; return this.prisma.trustContent.update({ where: { id }, data: { ...fields, ...(config === undefined ? {} : { config: config as Prisma.InputJsonValue }) } }); }
|
||||
@Delete("trust-content/:id")
|
||||
async deleteTrustContent(@Req() request: FastifyRequest, @Param("id") id: string): Promise<unknown> { this.requireAdmin(request); const item = await this.prisma.trustContent.findFirst({ where: { id, brandId: this.brandId() } }); if (!item) throw new BadRequestException("信任内容不存在"); await this.prisma.trustContent.delete({ where: { id } }); return { deleted: true }; }
|
||||
@Get("services")
|
||||
listServices(@Req() request: FastifyRequest): Promise<unknown> { this.requireAdmin(request); return this.prisma.service.findMany({ where: { brandId: this.brandId() }, orderBy: { sortOrder: "asc" } }); }
|
||||
@Post("services")
|
||||
|
||||
Reference in new issue
Block a user