design request
This commit is contained in:
@@ -27,9 +27,9 @@ export class CatalogueController {
|
||||
return this.catalogueService.findOne(id);
|
||||
}
|
||||
|
||||
@Get('public/catalogue/slug/:slug')
|
||||
findOneBySlugAsPublic(@Param('slug') slug: string) {
|
||||
return this.catalogueService.findOneOrFailBySlug(slug);
|
||||
@Get('public/catalogue/:businessSlug/:catalogueSlug')
|
||||
findOneBySlugAsPublic(@Param('businessSlug') businessSlug: string, @Param('catalogueSlug') catalogueSlug: string) {
|
||||
return this.catalogueService.findOneOrFailBySlug(businessSlug,catalogueSlug);
|
||||
}
|
||||
|
||||
// ============= Admin Routes ==============
|
||||
|
||||
@@ -67,8 +67,8 @@ export class CatalogueService {
|
||||
return catalogue
|
||||
}
|
||||
|
||||
async findOneOrFailBySlug(slug: string) {
|
||||
const catalogue = await this.catalogueRepository.findOne({ slug })
|
||||
async findOneOrFailBySlug(businessSlug: string, catalogueSlug: string) {
|
||||
const catalogue = await this.catalogueRepository.findOne({ business: { slug: businessSlug }, slug: catalogueSlug })
|
||||
if (!catalogue) {
|
||||
throw new NotFoundException("catalogue by slug not found")
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import {
|
||||
Cascade, Collection, Entity, EntityRepositoryType, Enum,
|
||||
ManyToOne, OneToMany, OneToOne, Opt, Property
|
||||
Index,
|
||||
ManyToOne, OneToMany, OneToOne, Opt, Property,
|
||||
Unique
|
||||
} from "@mikro-orm/core";
|
||||
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
@@ -9,6 +11,9 @@ import { CatalogueSize, CatalogueStatus } from "../enums/company-status.enum";
|
||||
import { CatalogueRepository } from "../repositories/catalogue.repository";
|
||||
|
||||
@Entity({ repository: () => CatalogueRepository })
|
||||
@Index({ properties: ['business.id'] })
|
||||
@Index({ properties: ['slug'] })
|
||||
@Unique({ properties: ['business.id', 'slug'] })
|
||||
export class Catalogue extends BaseEntity {
|
||||
@Property({ type: "varchar", length: 255})
|
||||
name!: string;
|
||||
|
||||
@@ -7,8 +7,10 @@ import { SuperAdminAuthGuard } from '../auth/guards/superAdminAuth.guard';
|
||||
import { FinishDesignRequestDto } from './dto/finish-design-request.dto';
|
||||
import { FindDesignRequestsDto } from './dto/find-design-requests.dto';
|
||||
import { MarkDesignRequestPaidDto } from './dto/mark-design-request-paid.dto';
|
||||
import { ApiBearerAuth } from '@nestjs/swagger';
|
||||
|
||||
@Controller()
|
||||
@ApiBearerAuth()
|
||||
export class DesignRequestController {
|
||||
constructor(private readonly designRequestService: DesignRequestService) { }
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export class DesignRequestService {
|
||||
private readonly httpService: HttpService,
|
||||
@Inject(ConfigService)
|
||||
private readonly configService: ConfigService,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
private getDesignUnitPrice(count: number): number {
|
||||
if (count < 10) {
|
||||
@@ -59,7 +59,8 @@ export class DesignRequestService {
|
||||
],
|
||||
};
|
||||
|
||||
let invoiceData: { id: string };
|
||||
let invoiceData: { id: string } = { id: '' };
|
||||
|
||||
|
||||
try {
|
||||
const { data } = await firstValueFrom(
|
||||
@@ -77,8 +78,8 @@ export class DesignRequestService {
|
||||
}),
|
||||
),
|
||||
);
|
||||
invoiceData = data;
|
||||
} catch (error: unknown) {
|
||||
invoiceData = data.data.invoice
|
||||
} catch (error: unknown) {
|
||||
this.logger.error(
|
||||
`Error create invoice: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user