refactor: 删除旧业务提供项路由
This commit is contained in:
1 parent
fe7005d4d0
commit
88cd8df40e
3 files changed
+7
-92
No files matched your search
@@ -26,32 +26,6 @@ export class UpdateBrandDto {
|
||||
@IsOptional() @IsObject() config?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class UpdateServiceDto {
|
||||
@IsOptional() @IsString() name?: string;
|
||||
@IsOptional() @IsString() description?: string;
|
||||
@IsOptional() @IsString() coverUrl?: string;
|
||||
@IsOptional() @IsString() priceText?: string;
|
||||
@IsOptional() @IsInt() @Min(0) priceAmount?: number;
|
||||
@IsOptional() @IsInt() @Min(0) @Max(9999) sortOrder?: number;
|
||||
@IsOptional() @IsBoolean() bookingEnabled?: boolean;
|
||||
@IsOptional() @IsBoolean() isEnabled?: boolean;
|
||||
@IsOptional() @IsString() categoryKey?: string;
|
||||
@IsOptional() config?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class CreateServiceDto {
|
||||
@IsString() name!: string;
|
||||
@IsString() description!: string;
|
||||
@IsOptional() @IsString() categoryKey?: string;
|
||||
@IsOptional() @IsString() coverUrl?: string;
|
||||
@IsOptional() @IsString() priceText?: string;
|
||||
@IsOptional() @IsInt() @Min(0) priceAmount?: number;
|
||||
@IsOptional() @IsInt() @Min(0) @Max(9999) sortOrder?: number;
|
||||
@IsOptional() @IsBoolean() bookingEnabled?: boolean;
|
||||
@IsOptional() @IsBoolean() isEnabled?: boolean;
|
||||
@IsOptional() config?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class CreateTrustContentDto {
|
||||
@IsIn(["profile", "experience", "credential", "portfolio", "process", "testimonial"])
|
||||
type!: string;
|
||||
|
||||
@@ -24,13 +24,11 @@ import { WechatAuthService } from "./wechat-auth.js";
|
||||
import { BookingService } from "./booking.service.js";
|
||||
import { CreateBookingDto, CreateInquirySubmissionDto } from "./booking.dto.js";
|
||||
import {
|
||||
CreateServiceDto,
|
||||
CreateTagDto,
|
||||
CreateTrustContentDto,
|
||||
UpdateBookingStatusDto,
|
||||
UpdateBookingTagsDto,
|
||||
UpdateBrandDto,
|
||||
UpdateServiceDto,
|
||||
UpdateTrustContentDto,
|
||||
} from "./admin.dto.js";
|
||||
import { AdminAuthService } from "./admin-auth.service.js";
|
||||
@@ -76,19 +74,6 @@ export class PublicController {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@Get("services")
|
||||
async services(): Promise<unknown> {
|
||||
const offerings = await this.prisma.offering.findMany({
|
||||
where: { isEnabled: true },
|
||||
orderBy: { sortOrder: "asc" },
|
||||
});
|
||||
return offerings.map((offering) => ({
|
||||
...offering,
|
||||
bookingEnabled: true,
|
||||
categoryKey: offering.kind,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Controller("public/trust-content")
|
||||
@@ -555,50 +540,6 @@ export class AdminConfigController {
|
||||
await this.prisma.trustContent.delete({ where: { id } });
|
||||
return { deleted: true };
|
||||
}
|
||||
@Get("services")
|
||||
listServices(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
this.requireAdmin(request);
|
||||
return this.prisma.offering.findMany({
|
||||
where: { brandId: this.brandId() },
|
||||
orderBy: { sortOrder: "asc" },
|
||||
});
|
||||
}
|
||||
@Post("services")
|
||||
async createService(
|
||||
@Req() request: FastifyRequest,
|
||||
@Body() body: CreateServiceDto,
|
||||
): Promise<unknown> {
|
||||
this.requireAdmin(request);
|
||||
const { config, categoryKey, ...fields } = body;
|
||||
const brandId = this.brandId();
|
||||
return this.prisma.offering.create({
|
||||
data: {
|
||||
...fields,
|
||||
brandId,
|
||||
kind: categoryKey ?? "service",
|
||||
...(config === undefined ? {} : { config: config as Prisma.InputJsonValue }),
|
||||
},
|
||||
});
|
||||
}
|
||||
@Patch("services/:id")
|
||||
async updateService(
|
||||
@Req() request: FastifyRequest,
|
||||
@Param("id") id: string,
|
||||
@Body() body: UpdateServiceDto,
|
||||
): Promise<unknown> {
|
||||
this.requireAdmin(request);
|
||||
const item = await this.prisma.offering.findFirst({ where: { id, brandId: this.brandId() } });
|
||||
if (!item) throw new BadRequestException("业务提供项不存在");
|
||||
const { config, categoryKey, ...fields } = body;
|
||||
return this.prisma.offering.update({
|
||||
where: { id },
|
||||
data: {
|
||||
...fields,
|
||||
...(categoryKey === undefined ? {} : { kind: categoryKey }),
|
||||
...(config === undefined ? {} : { config: config as Prisma.InputJsonValue }),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Module({
|
||||
|
||||
Reference in new issue
Block a user