enaklo pos backend
This commit is contained in:
@@ -212,14 +212,12 @@ func ConvertToProductResp(resp []*entity.Product) *response.SearchProductSiteRes
|
||||
partnerID := int64(0)
|
||||
for _, res := range resp {
|
||||
productResp = append(productResp, response.SearchProductSiteByIDResponse{
|
||||
ID: res.ID,
|
||||
Name: res.Name,
|
||||
SiteID: res.SiteID,
|
||||
Price: res.Price,
|
||||
IsWeekendTicket: res.IsWeekendTicket,
|
||||
IsSeasonTicket: res.IsSeasonTicket,
|
||||
Description: res.Description,
|
||||
Type: res.Type,
|
||||
ID: res.ID,
|
||||
Name: res.Name,
|
||||
SiteID: res.SiteID,
|
||||
Price: res.Price,
|
||||
Description: res.Description,
|
||||
Type: res.Type,
|
||||
})
|
||||
|
||||
partnerID = res.PartnerID
|
||||
|
||||
@@ -446,12 +446,11 @@ func MapOrderToPrintDetailResponse(order *entity.OrderPrintDetail, casherName st
|
||||
orderItems := make([]response.CreateOrderItemResponse, len(order.OrderItems))
|
||||
for i, item := range order.OrderItems {
|
||||
orderItems[i] = response.CreateOrderItemResponse{
|
||||
ID: item.ID,
|
||||
ItemID: item.ItemID,
|
||||
Quantity: item.Quantity,
|
||||
Price: item.Price,
|
||||
Name: item.Product.Name,
|
||||
IsSeasonTicket: item.Product.IsSeasonTicket,
|
||||
ID: item.ID,
|
||||
ItemID: item.ItemID,
|
||||
Quantity: item.Quantity,
|
||||
Price: item.Price,
|
||||
Name: item.Product.Name,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ type Handler struct {
|
||||
}
|
||||
|
||||
func (h *Handler) Route(group *gin.RouterGroup, jwt gin.HandlerFunc) {
|
||||
route := group.Group("/product")
|
||||
route := group.Group("/products")
|
||||
|
||||
route.POST("/", jwt, h.Create)
|
||||
route.POST("/create", jwt, h.Create)
|
||||
route.GET("/pos", jwt, h.GetPOSProduct)
|
||||
route.GET("/list", jwt, h.GetAll)
|
||||
route.PUT("/:id", jwt, h.Update)
|
||||
@@ -56,11 +56,8 @@ func (h *Handler) Create(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
validate := validator.New()
|
||||
if err := validate.Struct(req); err != nil {
|
||||
response.ErrorWrapper(c, err)
|
||||
return
|
||||
}
|
||||
req.PartnerID = *ctx.GetPartnerID()
|
||||
req.SiteID = *ctx.GetSiteID()
|
||||
|
||||
res, err := h.service.Create(ctx, req.ToEntity())
|
||||
|
||||
@@ -272,19 +269,16 @@ func (h *Handler) GetByID(c *gin.Context) {
|
||||
|
||||
func (h *Handler) toProductResponse(resp *entity.Product) response.Product {
|
||||
return response.Product{
|
||||
ID: resp.ID,
|
||||
Name: resp.Name,
|
||||
Type: resp.Type,
|
||||
Price: resp.Price,
|
||||
Status: resp.Status,
|
||||
Description: resp.Description,
|
||||
CreatedAt: resp.CreatedAt.Format(time.RFC3339),
|
||||
UpdatedAt: resp.CreatedAt.Format(time.RFC3339),
|
||||
PartnerID: resp.PartnerID,
|
||||
SiteID: resp.SiteID,
|
||||
IsSeasonTicket: resp.IsSeasonTicket,
|
||||
IsWeekendTicket: resp.IsWeekendTicket,
|
||||
Stock: resp.Stock,
|
||||
ID: resp.ID,
|
||||
Name: resp.Name,
|
||||
Type: resp.Type,
|
||||
Price: resp.Price,
|
||||
Status: resp.Status,
|
||||
Description: resp.Description,
|
||||
CreatedAt: resp.CreatedAt.Format(time.RFC3339),
|
||||
UpdatedAt: resp.CreatedAt.Format(time.RFC3339),
|
||||
PartnerID: resp.PartnerID,
|
||||
SiteID: resp.SiteID,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -312,19 +312,16 @@ func (h *Handler) toProductResponseList(products []entity.Product) []response.Pr
|
||||
var res []response.Product
|
||||
for _, product := range products {
|
||||
res = append(res, response.Product{
|
||||
ID: product.ID,
|
||||
PartnerID: product.PartnerID,
|
||||
SiteID: product.SiteID,
|
||||
Name: product.Name,
|
||||
Type: product.Type,
|
||||
Price: product.Price,
|
||||
IsWeekendTicket: product.IsWeekendTicket,
|
||||
IsSeasonTicket: product.IsSeasonTicket,
|
||||
Status: product.Status,
|
||||
Description: product.Description,
|
||||
CreatedAt: product.CreatedAt.Format(time.RFC3339),
|
||||
UpdatedAt: product.UpdatedAt.Format(time.RFC3339),
|
||||
Stock: product.Stock,
|
||||
ID: product.ID,
|
||||
PartnerID: product.PartnerID,
|
||||
SiteID: product.SiteID,
|
||||
Name: product.Name,
|
||||
Type: product.Type,
|
||||
Price: product.Price,
|
||||
Status: product.Status,
|
||||
Description: product.Description,
|
||||
CreatedAt: product.CreatedAt.Format(time.RFC3339),
|
||||
UpdatedAt: product.UpdatedAt.Format(time.RFC3339),
|
||||
})
|
||||
}
|
||||
return res
|
||||
|
||||
@@ -30,6 +30,7 @@ func (p *ProductParam) ToEntity() entity.ProductSearch {
|
||||
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"`
|
||||
@@ -38,6 +39,7 @@ type Product struct {
|
||||
Status string `json:"status"`
|
||||
Description string `json:"description" validate:"required"`
|
||||
Stock int64 `json:"stock"`
|
||||
Image string `json:"image"`
|
||||
}
|
||||
|
||||
func (e *Product) ToEntity() *entity.Product {
|
||||
@@ -47,6 +49,8 @@ func (e *Product) ToEntity() *entity.Product {
|
||||
Price: e.Price,
|
||||
Status: e.Status,
|
||||
Description: e.Description,
|
||||
Stock: e.Stock,
|
||||
PartnerID: e.PartnerID,
|
||||
SiteID: e.SiteID,
|
||||
Image: e.Image,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,17 +31,14 @@ func (r *Site) ToEntity(createdBy int64) *entity.Site {
|
||||
var products []entity.Product
|
||||
for _, p := range r.Products {
|
||||
products = append(products, entity.Product{
|
||||
ID: p.ID,
|
||||
PartnerID: *r.PartnerID,
|
||||
Name: p.Name,
|
||||
Type: p.Type,
|
||||
Price: p.Price,
|
||||
IsWeekendTicket: p.IsWeekendTicket,
|
||||
IsSeasonTicket: p.IsSeasonTicket,
|
||||
Status: p.Status,
|
||||
Description: p.Description,
|
||||
CreatedBy: createdBy,
|
||||
Stock: p.Stock,
|
||||
ID: p.ID,
|
||||
PartnerID: *r.PartnerID,
|
||||
Name: p.Name,
|
||||
Type: p.Type,
|
||||
Price: p.Price,
|
||||
Status: p.Status,
|
||||
Description: p.Description,
|
||||
CreatedBy: createdBy,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -151,12 +151,11 @@ type CheckingInquiryResponse struct {
|
||||
}
|
||||
|
||||
type CreateOrderItemResponse struct {
|
||||
ID int64 `json:"id"`
|
||||
ItemID int64 `json:"item_id"`
|
||||
Quantity int64 `json:"quantity"`
|
||||
Price float64 `json:"price"`
|
||||
Name string `json:"name"`
|
||||
IsSeasonTicket bool `json:"is_season_ticket"`
|
||||
ID int64 `json:"id"`
|
||||
ItemID int64 `json:"item_id"`
|
||||
Quantity int64 `json:"quantity"`
|
||||
Price float64 `json:"price"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type ProductDailySales struct {
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package response
|
||||
|
||||
type Product struct {
|
||||
ID int64 `json:"id"`
|
||||
PartnerID int64 `json:"partner_id"`
|
||||
SiteID int64 `json:"site_id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Price float64 `json:"price"`
|
||||
IsWeekendTicket bool `json:"is_weekend_ticket"`
|
||||
IsSeasonTicket bool `json:"is_season_ticket"`
|
||||
Status string `json:"status"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
Stock int64 `json:"stock"`
|
||||
ID int64 `json:"id"`
|
||||
PartnerID int64 `json:"partner_id"`
|
||||
SiteID int64 `json:"site_id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Price float64 `json:"price"`
|
||||
Status string `json:"status"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
Image string `json:"image"`
|
||||
}
|
||||
|
||||
type ProductList struct {
|
||||
|
||||
Reference in New Issue
Block a user