affliate-reconciliation get staff info

This commit is contained in:
phuanbui 2022-10-07 15:09:28 +07:00
parent 3e13cb55b3
commit 5c7b5bfd41
5 changed files with 71 additions and 0 deletions

35
client/staff.go Normal file
View File

@ -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
}

8
model/staff_request.go Normal file
View File

@ -0,0 +1,8 @@
package model
import "go.mongodb.org/mongo-driver/bson/primitive"
// GetListStaffInfoByIDsRequest ...
type GetListStaffInfoByIDsRequest struct {
StaffIDs []primitive.ObjectID `json:"staffIds"`
}

12
model/staff_response.go Normal file
View File

@ -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"`
}

View File

@ -9,6 +9,7 @@ var prefixes = struct {
Bank string Bank string
Supplier string Supplier string
Seller string Seller string
Staff string
}{ }{
Communication: "communication", Communication: "communication",
Order: "order", Order: "order",
@ -18,4 +19,5 @@ var prefixes = struct {
Supplier: "supplier", Supplier: "supplier",
Bank: "bank", Bank: "bank",
Seller: "seller", Seller: "seller",
Staff: "staff",
} }

14
subject/staff.go Normal file
View File

@ -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"),
}