v3数据表更改
This commit is contained in:
@@ -7,7 +7,7 @@ export class CatalogService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async listCities() {
|
||||
const cities = await this.prisma.city.findMany({
|
||||
const cities = await this.prisma.commonCity.findMany({
|
||||
where: { status: 'ACTIVE' },
|
||||
include: { partner: { select: { companyName: true } } },
|
||||
});
|
||||
@@ -15,9 +15,10 @@ export class CatalogService {
|
||||
}
|
||||
|
||||
async listProducts(aromaType?: string) {
|
||||
const products = await this.prisma.product.findMany({
|
||||
const products = await this.prisma.commonProductItem.findMany({
|
||||
where: { status: 'ON_SALE', ...(aromaType ? { aromaType: aromaType as never } : {}) },
|
||||
orderBy: { sortOrder: 'asc' },
|
||||
include: { coverResource: true },
|
||||
});
|
||||
return serializeBigInt(
|
||||
products.map((p) => ({
|
||||
@@ -25,17 +26,22 @@ export class CatalogService {
|
||||
benefitAmount: p.benefitAmount ?? p.price,
|
||||
price: Number(p.price),
|
||||
benefitDisplay: Number(p.benefitAmount ?? p.price),
|
||||
mainImageUrl: p.coverResource?.url ?? null,
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
async getProduct(id: bigint) {
|
||||
const product = await this.prisma.product.findUnique({ where: { id } });
|
||||
const product = await this.prisma.commonProductItem.findUnique({
|
||||
where: { id },
|
||||
include: { coverResource: true },
|
||||
});
|
||||
if (!product) return null;
|
||||
return serializeBigInt({
|
||||
...product,
|
||||
benefitAmount: product.benefitAmount ?? product.price,
|
||||
price: Number(product.price),
|
||||
mainImageUrl: product.coverResource?.url ?? null,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user