feat: 完成多品牌隔离专项验收
This commit is contained in:
1 parent
1a2f179e15
commit
dcb40f629b
16 files changed
+197
-51
No files matched your search
@@ -1,13 +1,17 @@
|
||||
import { BadRequestException, Controller, Get, Param } from "@nestjs/common";
|
||||
import { BadRequestException, Controller, Get, Param, Query } from "@nestjs/common";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { PrismaService } from "../../prisma.service.js";
|
||||
import { PublicBrandContextService } from "./public-brand-context.service.js";
|
||||
|
||||
@Controller("public/offerings")
|
||||
export class PublicOfferingController {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly brandContext: PublicBrandContextService,
|
||||
) {}
|
||||
@Get()
|
||||
async list(): Promise<unknown> {
|
||||
const brandId = process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001";
|
||||
async list(@Query("brandSlug") brandSlug?: string): Promise<unknown> {
|
||||
const brandId = await this.brandContext.resolveId(brandSlug);
|
||||
const items = await this.prisma.offering.findMany({
|
||||
where: { brandId, isEnabled: true },
|
||||
orderBy: { sortOrder: "asc" },
|
||||
@@ -22,11 +26,12 @@ export class PublicOfferingController {
|
||||
return items.map((item) => this.present(item));
|
||||
}
|
||||
@Get(":id")
|
||||
async get(@Param("id") id: string): Promise<unknown> {
|
||||
async get(@Param("id") id: string, @Query("brandSlug") brandSlug?: string): Promise<unknown> {
|
||||
const brandId = await this.brandContext.resolveId(brandSlug);
|
||||
const item = await this.prisma.offering.findFirst({
|
||||
where: {
|
||||
id,
|
||||
brandId: process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001",
|
||||
brandId,
|
||||
isEnabled: true,
|
||||
},
|
||||
include: {
|
||||
|
||||
Reference in new issue
Block a user