42 lines
929 B
Go
42 lines
929 B
Go
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"
|
|
)
|
|
|
|
// Staff ...
|
|
type Staff struct{}
|
|
|
|
func GetStaff() Staff {
|
|
return Staff{}
|
|
}
|
|
|
|
// GetListStaffInfoByNotificationAction ...
|
|
func (s Staff) GetListStaffInfoByNotificationAction(p model.GetListStaffByNotificationActionRequest) (*model.ResponseListStaffInfoByNotificationAction, error) {
|
|
msg, err := natsio.GetServer().Request(subject.Staff.GetListStaffInfoByNotificationAction, toBytes(p))
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var r struct {
|
|
Data *model.ResponseListStaffInfoByNotificationAction `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
|
|
|
|
}
|