feat: colum stock in product
This commit is contained in:
parent
b7799b7ada
commit
56f7baf21d
@ -21,6 +21,7 @@ type Product struct {
|
|||||||
DeletedAt *time.Time `gorm:"column:deleted_at"`
|
DeletedAt *time.Time `gorm:"column:deleted_at"`
|
||||||
CreatedBy int64 `gorm:"type:int;column:created_by"`
|
CreatedBy int64 `gorm:"type:int;column:created_by"`
|
||||||
UpdatedBy int64 `gorm:"type:int;column:updated_by"`
|
UpdatedBy int64 `gorm:"type:int;column:updated_by"`
|
||||||
|
Stock int64 `gorm:"type:int;column:stock"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Product) TableName() string {
|
func (Product) TableName() string {
|
||||||
@ -75,6 +76,7 @@ func (e *ProductDB) ToProduct() *Product {
|
|||||||
SiteID: e.SiteID,
|
SiteID: e.SiteID,
|
||||||
IsSeasonTicket: e.IsSeasonTicket,
|
IsSeasonTicket: e.IsSeasonTicket,
|
||||||
IsWeekendTicket: e.IsWeekendTicket,
|
IsWeekendTicket: e.IsWeekendTicket,
|
||||||
|
Stock: e.Stock,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ type Product struct {
|
|||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
CreatedAt string `json:"created_at"`
|
CreatedAt string `json:"created_at"`
|
||||||
UpdatedAt string `json:"updated_at"`
|
UpdatedAt string `json:"updated_at"`
|
||||||
|
Stock int64 `json:"stock"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProductList struct {
|
type ProductList struct {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ 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"
|
||||||
@ -62,6 +63,7 @@ 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