-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Implement][Category] View categories and create category API
- Loading branch information
1 parent
4ee1ef6
commit f638744
Showing
7 changed files
with
96 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Controller, Get } from '@nestjs/common' | ||
import { ApiOkResponse, ApiQuery, ApiTags } from '@nestjs/swagger' | ||
import { PaginateResponse } from '@common/contracts/openapi-builder' | ||
import { PaginationQuery } from '@src/common/contracts/dto' | ||
import { CategoryService } from '@category/services/category.service' | ||
import { Pagination, PaginationParams } from '@src/common/decorators/pagination.decorator' | ||
import { PublicCategory } from '@category/dto/category.dto' | ||
|
||
@ApiTags('Category - Customer') | ||
@Controller('customer') | ||
export class CategoryCustomerController { | ||
constructor(private readonly categoryService: CategoryService) {} | ||
|
||
@Get() | ||
@ApiOkResponse({ type: PaginateResponse(PublicCategory) }) | ||
@ApiQuery({ type: PaginationQuery }) | ||
async getAllCategories(@Pagination() paginationParams: PaginationParams) { | ||
return await this.categoryService.getAllPublicCategories(paginationParams) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { IsNotEmpty, IsUrl, MaxLength } from 'class-validator' | ||
|
||
export class PublicCategory { | ||
@ApiProperty() | ||
_id: string | ||
|
||
@ApiProperty() | ||
name: string | ||
|
||
@ApiProperty() | ||
description: string | ||
|
||
@ApiProperty() | ||
image: string | ||
} | ||
|
||
export class CreateCategoryDto { | ||
@ApiProperty() | ||
@IsNotEmpty() | ||
@MaxLength(30) | ||
name: string | ||
|
||
@ApiProperty() | ||
@MaxLength(100) | ||
description: string | ||
|
||
@ApiProperty() | ||
@IsNotEmpty() | ||
@IsUrl() | ||
image: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters