Compare commits
No commits in common. "79860bac50839e4fc4e0bd5b7c4954ca15824ee5" and "10fe37399860db66da76f2c19d2d76446d2449c9" have entirely different histories.
79860bac50
...
10fe373998
|
@ -1,37 +0,0 @@
|
||||||
package client
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"git.selly.red/Selly-Modules/natsio"
|
|
||||||
"git.selly.red/Selly-Modules/natsio/model"
|
|
||||||
"git.selly.red/Selly-Modules/natsio/subject"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Promotion struct{}
|
|
||||||
|
|
||||||
func GetPromotion() Promotion {
|
|
||||||
return Promotion{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Promotion) GenerateVoucherPromotion(p model.GenerateVoucherPromotionRequest) (*model.ResponseGenerateVoucherPromotion, error) {
|
|
||||||
msg, err := natsio.GetServer().Request(subject.Promotion.GenerateVoucherPromotion, toBytes(p))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var r struct {
|
|
||||||
Data *model.ResponseGenerateVoucherPromotion `json:"data"`
|
|
||||||
Error string `json:"error"`
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = json.Unmarshal(msg.Data, &r); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if r.Error != "" {
|
|
||||||
return nil, errors.New(r.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r.Data, nil
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package model
|
|
||||||
|
|
||||||
import "go.mongodb.org/mongo-driver/bson/primitive"
|
|
||||||
|
|
||||||
type GenerateVoucherPromotionRequest struct {
|
|
||||||
Cash float64 `json:"cash"`
|
|
||||||
TargetID primitive.ObjectID `json:"targetId"`
|
|
||||||
TargetType string `json:"targetType"`
|
|
||||||
Options GenerateVoucherPromotionOptions `json:"options"`
|
|
||||||
Seller primitive.ObjectID `json:"seller"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GenerateVoucherPromotionOptions struct {
|
|
||||||
Title string `json:"title"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ResponseGenerateVoucherPromotion struct {
|
|
||||||
Success bool `json:"success"`
|
|
||||||
Error string `json:"error"`
|
|
||||||
}
|
|
Loading…
Reference in New Issue