affliate-reconciliation get staff info #40
|
@ -0,0 +1,35 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/Selly-Modules/natsio"
|
||||
"github.com/Selly-Modules/natsio/model"
|
||||
"github.com/Selly-Modules/natsio/subject"
|
||||
)
|
||||
|
||||
type Staff struct{}
|
||||
|
||||
func (s Staff) GetListStaffInfoByIDs(p model.GetListStaffInfoByIDsRequest) (*model.ResponseListStaffInfo, error) {
|
||||
msg, err := natsio.GetServer().Request(subject.Staff.GetListStaffInfoByIDs, toBytes(p))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var r struct {
|
||||
Data *model.ResponseListStaffInfo `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
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package model
|
||||
|
||||
import "go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
||||
// GetListStaffInfoByIDsRequest ...
|
||||
type GetListStaffInfoByIDsRequest struct {
|
||||
StaffIDs []primitive.ObjectID `json:"staffIds"`
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package model
|
||||
|
||||
// ResponseListStaffInfo ...
|
||||
type ResponseListStaffInfo struct {
|
||||
List []ResponseStaffInfo `json:"list"`
|
||||
}
|
||||
|
||||
// ResponseStaffInfo ...
|
||||
type ResponseStaffInfo struct {
|
||||
ID string `json:"_id"`
|
||||
Name string `json:"name"`
|
||||
}
|
|
@ -9,6 +9,7 @@ var prefixes = struct {
|
|||
Bank string
|
||||
Supplier string
|
||||
Seller string
|
||||
Staff string
|
||||
}{
|
||||
Communication: "communication",
|
||||
Order: "order",
|
||||
|
@ -18,4 +19,5 @@ var prefixes = struct {
|
|||
Supplier: "supplier",
|
||||
Bank: "bank",
|
||||
Seller: "seller",
|
||||
Staff: "staff",
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package subject
|
||||
|
||||
import "fmt"
|
||||
|
||||
func getStaffValue(val string) string {
|
||||
return fmt.Sprintf("%s.%s", prefixes.Staff, val)
|
||||
}
|
||||
|
||||
// Staff ...
|
||||
var Staff = struct {
|
||||
GetListStaffInfoByIDs string
|
||||
}{
|
||||
GetListStaffInfoByIDs: getStaffValue("get_list_staff_info_by_ids"),
|
||||
}
|
Loading…
Reference in New Issue