From 57f019b1e908c536befb66f03f34bd437bdfacd3 Mon Sep 17 00:00:00 2001 From: fernanda-one Date: Sat, 24 Aug 2024 01:49:14 +0700 Subject: [PATCH] feat: site stock --- internal/handlers/http/product/product.go | 1 + internal/handlers/http/sites/sites.go | 1 + internal/handlers/request/product.go | 2 ++ internal/handlers/request/site.go | 1 + internal/services/product/product.go | 2 -- 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/handlers/http/product/product.go b/internal/handlers/http/product/product.go index 8661454..bad35ea 100644 --- a/internal/handlers/http/product/product.go +++ b/internal/handlers/http/product/product.go @@ -284,6 +284,7 @@ func (h *Handler) toProductResponse(resp *entity.Product) response.Product { SiteID: resp.SiteID, IsSeasonTicket: resp.IsSeasonTicket, IsWeekendTicket: resp.IsWeekendTicket, + Stock: resp.Stock, } } diff --git a/internal/handlers/http/sites/sites.go b/internal/handlers/http/sites/sites.go index 0bc8c6f..8eda8dc 100644 --- a/internal/handlers/http/sites/sites.go +++ b/internal/handlers/http/sites/sites.go @@ -324,6 +324,7 @@ func (h *Handler) toProductResponseList(products []entity.Product) []response.Pr Description: product.Description, CreatedAt: product.CreatedAt.Format(time.RFC3339), UpdatedAt: product.UpdatedAt.Format(time.RFC3339), + Stock: product.Stock, }) } return res diff --git a/internal/handlers/request/product.go b/internal/handlers/request/product.go index 3b99b01..6b12a06 100644 --- a/internal/handlers/request/product.go +++ b/internal/handlers/request/product.go @@ -37,6 +37,7 @@ type Product struct { IsSeasonTicket bool `json:"is_season_ticket"` Status string `json:"status"` Description string `json:"description" validate:"required"` + Stock int64 `json:"stock"` } func (e *Product) ToEntity() *entity.Product { @@ -46,5 +47,6 @@ func (e *Product) ToEntity() *entity.Product { Price: e.Price, Status: e.Status, Description: e.Description, + Stock: e.Stock, } } diff --git a/internal/handlers/request/site.go b/internal/handlers/request/site.go index 25b9cb5..d83726f 100644 --- a/internal/handlers/request/site.go +++ b/internal/handlers/request/site.go @@ -41,6 +41,7 @@ func (r *Site) ToEntity(createdBy int64) *entity.Site { Status: p.Status, Description: p.Description, CreatedBy: createdBy, + Stock: p.Stock, }) } diff --git a/internal/services/product/product.go b/internal/services/product/product.go index 829bef0..105621c 100644 --- a/internal/services/product/product.go +++ b/internal/services/product/product.go @@ -2,7 +2,6 @@ package product import ( "context" - "fmt" "furtuna-be/internal/common/logger" "furtuna-be/internal/common/mycontext" "furtuna-be/internal/entity" @@ -63,7 +62,6 @@ func (s *ProductService) GetByID(ctx context.Context, id int64) (*entity.Product func (s *ProductService) GetAll(ctx context.Context, search entity.ProductSearch) ([]*entity.Product, int, error) { products, total, err := s.repo.GetAllProducts(ctx, search) - fmt.Println(products, "tes") if err != nil { logger.ContextLogger(ctx).Error("error when get all products", zap.Error(err)) return nil, 0, err