feat: site stock
This commit is contained in:
parent
56f7baf21d
commit
57f019b1e9
@ -284,6 +284,7 @@ func (h *Handler) toProductResponse(resp *entity.Product) response.Product {
|
|||||||
SiteID: resp.SiteID,
|
SiteID: resp.SiteID,
|
||||||
IsSeasonTicket: resp.IsSeasonTicket,
|
IsSeasonTicket: resp.IsSeasonTicket,
|
||||||
IsWeekendTicket: resp.IsWeekendTicket,
|
IsWeekendTicket: resp.IsWeekendTicket,
|
||||||
|
Stock: resp.Stock,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -324,6 +324,7 @@ func (h *Handler) toProductResponseList(products []entity.Product) []response.Pr
|
|||||||
Description: product.Description,
|
Description: product.Description,
|
||||||
CreatedAt: product.CreatedAt.Format(time.RFC3339),
|
CreatedAt: product.CreatedAt.Format(time.RFC3339),
|
||||||
UpdatedAt: product.UpdatedAt.Format(time.RFC3339),
|
UpdatedAt: product.UpdatedAt.Format(time.RFC3339),
|
||||||
|
Stock: product.Stock,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|||||||
@ -37,6 +37,7 @@ type Product struct {
|
|||||||
IsSeasonTicket bool `json:"is_season_ticket"`
|
IsSeasonTicket bool `json:"is_season_ticket"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Description string `json:"description" validate:"required"`
|
Description string `json:"description" validate:"required"`
|
||||||
|
Stock int64 `json:"stock"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Product) ToEntity() *entity.Product {
|
func (e *Product) ToEntity() *entity.Product {
|
||||||
@ -46,5 +47,6 @@ func (e *Product) ToEntity() *entity.Product {
|
|||||||
Price: e.Price,
|
Price: e.Price,
|
||||||
Status: e.Status,
|
Status: e.Status,
|
||||||
Description: e.Description,
|
Description: e.Description,
|
||||||
|
Stock: e.Stock,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,7 @@ func (r *Site) ToEntity(createdBy int64) *entity.Site {
|
|||||||
Status: p.Status,
|
Status: p.Status,
|
||||||
Description: p.Description,
|
Description: p.Description,
|
||||||
CreatedBy: createdBy,
|
CreatedBy: createdBy,
|
||||||
|
Stock: p.Stock,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package product
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"furtuna-be/internal/common/logger"
|
"furtuna-be/internal/common/logger"
|
||||||
"furtuna-be/internal/common/mycontext"
|
"furtuna-be/internal/common/mycontext"
|
||||||
"furtuna-be/internal/entity"
|
"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) {
|
func (s *ProductService) GetAll(ctx context.Context, search entity.ProductSearch) ([]*entity.Product, int, error) {
|
||||||
products, total, err := s.repo.GetAllProducts(ctx, search)
|
products, total, err := s.repo.GetAllProducts(ctx, search)
|
||||||
fmt.Println(products, "tes")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ContextLogger(ctx).Error("error when get all products", zap.Error(err))
|
logger.ContextLogger(ctx).Error("error when get all products", zap.Error(err))
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user