init project
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"furtuna-be/internal/constants/product"
|
||||
"furtuna-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"`
|
||||
}
|
||||
|
||||
func (p *ProductParam) ToEntity() entity.ProductSearch {
|
||||
return entity.ProductSearch{
|
||||
Search: p.Search,
|
||||
Name: p.Name,
|
||||
Type: p.Type,
|
||||
BranchID: p.BranchID,
|
||||
Available: p.Available,
|
||||
Limit: p.Limit,
|
||||
Offset: p.Offset,
|
||||
}
|
||||
}
|
||||
|
||||
type Product struct {
|
||||
Name string `json:"name" validate:"required"`
|
||||
Type product.ProductType `json:"type" validate:"required"`
|
||||
Price float64 `json:"price" validate:"required"`
|
||||
Status product.ProductStatus `json:"status" validate:"required"`
|
||||
Description string `json:"description" `
|
||||
Image string `json:"image" `
|
||||
BranchID int64 `json:"branch_id" validate:"required"`
|
||||
StockQty int64 `json:"stock_qty" `
|
||||
}
|
||||
|
||||
func (e *Product) ToEntity() *entity.Product {
|
||||
return &entity.Product{
|
||||
Name: e.Name,
|
||||
Type: e.Type,
|
||||
Price: e.Price,
|
||||
Status: e.Status,
|
||||
Description: e.Description,
|
||||
Image: e.Image,
|
||||
BranchID: e.BranchID,
|
||||
StockQty: e.StockQty,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user