PaymentCenter/app/http/entities/backend/product.go

72 lines
2.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package backend
import (
"qteam/app/http/domains"
"time"
)
type ProductCreateRequest struct {
ProductName string `json:"product_name" validate:"required" example:"snow"`
ProductType int `json:"product_type" validate:"required,oneof=1 2 3" example:"1"` // 产品类型1/优惠券类2/组合礼包类3/商城积分类)
PacketRule int `json:"packet_rule"`
ProductKind int `json:"'product_kind'"`
Amount string `json:"'amount'"`
CouponType int `json:"'coupon_type'"`
IsSuperposition int `json:"'is_superposition'"`
TemplateId int `json:"'template_id'"`
Status int `json:"status"`
IsNeedBill int `json:"'is_need_bill'"`
SupplierProductId int64 `json:"supplier_product_id"`
SupplierProductName string `json:"supplier_product_name"`
}
func (p *ProductCreateRequest) ToDomain() (do domains.Product, err error) {
do.ProductName = p.ProductName
do.ProductType = p.ProductType
do.PacketRule = p.PacketRule
do.ProductKind = p.ProductKind
do.Amount = p.Amount
do.CouponType = p.CouponType
do.IsSuperposition = p.IsSuperposition
do.TemplateId = do.TemplateId
do.Status = p.Status
do.SupplierProductId = p.SupplierProductId
do.SupplierProductName = p.SupplierProductName
return
}
type ProductCreateResponse struct {
Id int `json:"id"`
ProductName string `json:"product_name"`
ProductType int `json:"product_type"`
PacketRule int `json:"packet_rule"`
ProductKind int `json:"'product_kind'"`
Amount string `json:"'amount'"`
CouponType int `json:"'coupon_type'"`
IsSuperposition int `json:"'is_superposition'"`
TemplateId int `json:"'template_id'"`
Status int `json:"status"`
IsNeedBill int `json:"'is_need_bill'"`
SupplierProductId int64 `json:"supplier_product_id"`
SupplierProductName string `json:"supplier_product_name"`
CreateTime string `json:"create_time"`
UpdateTime string `json:"update_time"`
Creator string `json:"creator"`
}
func (p *ProductCreateResponse) FromDomain(do domains.Product) {
p.ProductName = do.ProductName
p.ProductType = do.ProductType
p.PacketRule = do.PacketRule
p.ProductKind = do.ProductKind
p.Amount = do.Amount
p.CouponType = do.CouponType
p.IsSuperposition = do.IsSuperposition
p.TemplateId = do.TemplateId
p.Status = do.Status
p.SupplierProductId = do.SupplierProductId
p.SupplierProductName = do.SupplierProductName
p.CreateTime = do.CreateTime.Format(time.DateTime)
}