Skip to content

Commit

Permalink
EF-83-add _id product swagger in cart (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
MinhhTien authored Jan 25, 2024
1 parent 87d7b4e commit 41dde80
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/cart/services/cart.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export class CartService {

public async addToCart(addToCartDto: AddToCartDto) {
const { customerId, product, quantity } = addToCartDto

// TODO: Check exists productId, implement after product module done

// TODO: Check inventory quantity <= product.quantity

const cart = await this.cartRepository.findOne({
conditions: {
customerId
Expand Down
5 changes: 4 additions & 1 deletion src/common/decorators/pagination.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export const handlePagination: (request: any) => PaginationParams = (request) =>
sort: request.query.sort
}
paginationParams.page = Number(paginationParams.page) > 0 ? Number(paginationParams.page) : 1
paginationParams.limit = Number(paginationParams.limit) > 0 ? Number(paginationParams.limit) : DEFAULT_LIMIT
paginationParams.limit =
Number(paginationParams.limit) > 0 && Number(paginationParams.limit) < 100
? Number(paginationParams.limit)
: DEFAULT_LIMIT
if (_.isEmpty(paginationParams.sort)) {
paginationParams.sort = {
createdAt: -1
Expand Down
1 change: 1 addition & 0 deletions src/product/schemas/product.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class Product {
this._id = id
}

@ApiProperty()
@Transform(({ value }) => value?.toString())
_id: string

Expand Down

0 comments on commit 41dde80

Please sign in to comment.