package request import ( "enaklo-pos-be/internal/constants/product" "enaklo-pos-be/internal/entity" ) type ProductParam struct { Search string `form:"search" json:"search" example:"Nasi Goreng"` Name string `form:"name" json:"name" example:"Nasi Goreng"` Type product.ProductType `form:"type" json:"type" example:"FOOD/BEVERAGE"` BranchID int64 `form:"branch_id" json:"branch_id" example:"1"` Available product.ProductStock `form:"available" json:"available" example:"1" example:"AVAILABLE/UNAVAILABLE"` Limit int `form:"limit" json:"limit" example:"10"` Offset int `form:"offset" json:"offset" example:"0"` CategoryID int64 `form:"category_id" json:"category_id" example:"1"` } func (p *ProductParam) ToEntity(partnerID int64) entity.ProductSearch { return entity.ProductSearch{ Search: p.Search, Name: p.Name, Type: p.Type, PartnerID: partnerID, Available: p.Available, Limit: p.Limit, Offset: p.Offset, CategoryID: p.CategoryID, } } type Product struct { ID int64 `json:"id,omitempty"` PartnerID int64 `json:"partner_id"` SiteID int64 `json:"site_id"` Name string `json:"name" validate:"required"` Type string `json:"type"` Price float64 `json:"price" validate:"required"` Status string `json:"status"` Description string `json:"description"` Stock int64 `json:"stock"` Image string `json:"image"` CategoryID int64 `json:"category_id"` } func (e *Product) ToEntity() *entity.Product { return &entity.Product{ Name: e.Name, Type: e.Type, Price: e.Price, Status: e.Status, Description: e.Description, PartnerID: e.PartnerID, Image: e.Image, CategoryID: &e.CategoryID, } }