Add public catalog APIs, website slots, featured slots, and int category/product IDs.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
15dd3597f0
commit
835c8a0ac1
@@ -1,4 +1,4 @@
|
||||
import { Controller, Get, Param, Query } from '@nestjs/common';
|
||||
import { Controller, Get, Param, ParseIntPipe, Query } from '@nestjs/common';
|
||||
import { PublicService } from './public.service';
|
||||
|
||||
@Controller('public')
|
||||
@@ -19,23 +19,53 @@ export class PublicController {
|
||||
@Query('minPrice') minPrice?: number,
|
||||
@Query('maxPrice') maxPrice?: number,
|
||||
) {
|
||||
const parsedCategoryId =
|
||||
categoryId !== undefined && categoryId !== ''
|
||||
? Number(categoryId)
|
||||
: undefined;
|
||||
return this.publicService.listProducts({
|
||||
storeId,
|
||||
storeSlug,
|
||||
name,
|
||||
categoryId,
|
||||
categoryId:
|
||||
parsedCategoryId !== undefined && Number.isFinite(parsedCategoryId)
|
||||
? parsedCategoryId
|
||||
: undefined,
|
||||
minPrice,
|
||||
maxPrice,
|
||||
});
|
||||
}
|
||||
|
||||
@Get('products/:id')
|
||||
findProduct(@Param('id') id: string) {
|
||||
findProduct(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.publicService.findProduct(id);
|
||||
}
|
||||
|
||||
@Get('categories')
|
||||
listCategories(@Query('storeSlug') storeSlug?: string) {
|
||||
return this.publicService.listCategories(storeSlug);
|
||||
}
|
||||
|
||||
@Get('search')
|
||||
search(
|
||||
@Query('q') q?: string,
|
||||
@Query('storeSlug') storeSlug?: string,
|
||||
@Query('limit') limit?: number,
|
||||
) {
|
||||
return this.publicService.search({
|
||||
q,
|
||||
storeSlug,
|
||||
limit: limit !== undefined ? Number(limit) : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
@Get('blogs')
|
||||
listBlogs(@Query('storeSlug') storeSlug?: string) {
|
||||
return this.publicService.listBlogs(storeSlug);
|
||||
}
|
||||
|
||||
@Get('website-slots')
|
||||
listWebsiteSlots(@Query('storeSlug') storeSlug?: string) {
|
||||
return this.publicService.listWebsiteSlots(storeSlug);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user