style: 统一全仓代码格式

This commit is contained in:
que01 committed 2026-09-19 18:46:26 +08:00
1 parent d811478d0f
commit 8033cabff9
30 files changed
+1183 -187

No files matched your search

+27 -25
View File
@@ -20,33 +20,35 @@ async function main(): Promise<void> {
});
const services = [
{
brandId: brand.id,
name: "红烧肉双拼套餐",
description: "红烧肉、时蔬、米饭",
priceText: "¥28 / 份",
priceAmount: 2800,
sortOrder: 1,
},
{
brandId: brand.id,
name: "小炒鸡套餐",
description: "现炒鸡块、时蔬、米饭",
priceText: "¥25 / 份",
priceAmount: 2500,
sortOrder: 2,
},
{
brandId: brand.id,
name: "家庭聚餐私厨",
description: "根据人数、地点和口味人工沟通报价",
priceText: "面议",
bookingEnabled: true,
sortOrder: 3,
},
{
brandId: brand.id,
name: "红烧肉双拼套餐",
description: "红烧肉、时蔬、米饭",
priceText: "¥28 / 份",
priceAmount: 2800,
sortOrder: 1,
},
{
brandId: brand.id,
name: "小炒鸡套餐",
description: "现炒鸡块、时蔬、米饭",
priceText: "¥25 / 份",
priceAmount: 2500,
sortOrder: 2,
},
{
brandId: brand.id,
name: "家庭聚餐私厨",
description: "根据人数、地点和口味人工沟通报价",
priceText: "面议",
bookingEnabled: true,
sortOrder: 3,
},
];
for (const service of services) {
const existing = await prisma.service.findFirst({ where: { brandId: brand.id, name: service.name } });
const existing = await prisma.service.findFirst({
where: { brandId: brand.id, name: service.name },
});
if (existing) await prisma.service.update({ where: { id: existing.id }, data: service });
else await prisma.service.create({ data: service });
}
+2 -1
View File
@@ -17,7 +17,8 @@ export class BookingItemDto {
}
export class CreateBookingDto {
@IsIn(["package", "private_chef", "inquiry"]) requestType!: "package" | "private_chef" | "inquiry";
@IsIn(["package", "private_chef", "inquiry"]) requestType!:
"package" | "private_chef" | "inquiry";
@IsString() customerName!: string;
@IsOptional() @IsString() phone?: string;
@IsOptional() @IsString() wechatId?: string;
+10 -6
View File
@@ -31,18 +31,22 @@ export class ApiExceptionFilter implements ExceptionFilter {
const request = context.getRequest<FastifyRequest>();
const status = exception instanceof HttpException ? exception.getStatus() : 500;
if (!(exception instanceof HttpException)) console.error("api unhandled error", exception);
const detail = exception instanceof HttpException
? exception.getResponse()
: process.env.NODE_ENV === "development" && exception instanceof Error
? exception.message
: "服务器内部错误";
const detail =
exception instanceof HttpException
? exception.getResponse()
: process.env.NODE_ENV === "development" && exception instanceof Error
? exception.message
: "服务器内部错误";
response.status(status).send({
data: null,
error: {
code: `HTTP_${status}`,
message: typeof detail === "string" ? detail : "请求失败",
},
requestId: (request as FastifyRequest & { requestId?: string }).requestId ?? request.headers["x-request-id"] ?? null,
requestId:
(request as FastifyRequest & { requestId?: string }).requestId ??
request.headers["x-request-id"] ??
null,
});
}
}
+4 -1
View File
@@ -32,7 +32,10 @@ export class WechatAuthService {
try {
response = await fetch(`https://api.weixin.qq.com/sns/jscode2session?${query.toString()}`);
} catch (error) {
console.error("wechat session request failed", error instanceof Error ? error.message : error);
console.error(
"wechat session request failed",
error instanceof Error ? error.message : error,
);
throw new ServiceUnavailableException("微信登录服务暂时不可用");
}
if (!response.ok) {
+4 -1
View File
@@ -90,7 +90,10 @@ test("订单状态只能按定义的状态机流转", async () => {
},
});
const bookings = new BookingService(prisma);
assert.equal((await bookings.updateStatus(brandId, "booking-1", "contacting")).status, "contacting");
assert.equal(
(await bookings.updateStatus(brandId, "booking-1", "contacting")).status,
"contacting",
);
await assert.rejects(
() => bookings.updateStatus(brandId, "booking-1", "completed"),
(error: unknown) => error instanceof BadRequestException,