mergeDev/campaign #73
|
@ -0,0 +1,31 @@
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetNotification() Notification {
|
||||||
|
return Notification{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Notification struct{}
|
||||||
|
|
||||||
|
func (n Notification) SupplierChangeBalanceRequestApproved(p model.NotificationSupplierChangeBalanceRequestApprovedReq) error {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.Notification.SupplierChangeBalanceRequestApproved, toBytes(p))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var r model.CommonResponseData
|
||||||
|
if err = json.Unmarshal(msg.Data, &r); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if r.Error != "" {
|
||||||
|
return errors.New(r.Error)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
type NotificationSupplierChangeBalanceRequestApprovedReq struct {
|
||||||
|
SupplierID string `json:"supplierId"`
|
||||||
|
Cash float64 `json:"cash"`
|
||||||
|
Reason string `json:"reason"`
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
package model
|
|
@ -8,6 +8,7 @@ var prefixes = struct {
|
||||||
Location string
|
Location string
|
||||||
Bank string
|
Bank string
|
||||||
Supplier string
|
Supplier string
|
||||||
|
Notification string
|
||||||
Seller string
|
Seller string
|
||||||
SupplierUser string
|
SupplierUser string
|
||||||
SupplierRole string
|
SupplierRole string
|
||||||
|
@ -20,6 +21,7 @@ var prefixes = struct {
|
||||||
Warehouse: "warehouse",
|
Warehouse: "warehouse",
|
||||||
Location: "location",
|
Location: "location",
|
||||||
Supplier: "supplier",
|
Supplier: "supplier",
|
||||||
|
Notification: "notification",
|
||||||
Bank: "bank",
|
Bank: "bank",
|
||||||
Seller: "seller",
|
Seller: "seller",
|
||||||
SupplierUser: "supplier_user",
|
SupplierUser: "supplier_user",
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package subject
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func getNotificationValue(val string) string {
|
||||||
|
return fmt.Sprintf("%s.%s", prefixes.Notification, val)
|
||||||
|
}
|
||||||
|
|
||||||
|
var Notification = struct {
|
||||||
|
SupplierChangeBalanceRequestApproved string
|
||||||
|
}{
|
||||||
|
SupplierChangeBalanceRequestApproved: getNotificationValue("supplier_change_balance_request_approved"),
|
||||||
|
}
|
Loading…
Reference in New Issue