add alug
This commit is contained in:
@@ -27,6 +27,11 @@ export class CatalogueController {
|
||||
return this.catalogueService.findOne(id);
|
||||
}
|
||||
|
||||
@Get('public/catalogue/slug/:slug')
|
||||
findOneBySlugAsPublic(@Param('slug') slug: string) {
|
||||
return this.catalogueService.findOneOrFailBySlug(slug);
|
||||
}
|
||||
|
||||
// ============= Admin Routes ==============
|
||||
|
||||
@Post('admin/catalogue')
|
||||
|
||||
@@ -67,6 +67,14 @@ export class CatalogueService {
|
||||
return catalogue
|
||||
}
|
||||
|
||||
async findOneOrFailBySlug(slug: string) {
|
||||
const catalogue = await this.catalogueRepository.findOne({ slug })
|
||||
if (!catalogue) {
|
||||
throw new NotFoundException("catalogue by slug not found")
|
||||
}
|
||||
return catalogue
|
||||
}
|
||||
|
||||
async update(id: string, dto: UpdateCatalogueDto) {
|
||||
const catalogue = await this.findOneOrFail(id)
|
||||
this.em.assign(catalogue, dto)
|
||||
|
||||
Reference in New Issue
Block a user