Merge pull request 'get staff by notification action' (#64) from feaure/staff-getinfo into develop
Reviewed-on: #64
This commit is contained in:
commit
d891c3a051
|
@ -0,0 +1,41 @@
|
|||
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
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package model
|
||||
|
||||
// GetListStaffByNotificationActionRequest ...
|
||||
type GetListStaffByNotificationActionRequest struct {
|
||||
CreatedBys []string `json:"createdBys"`
|
||||
ApprovedBys []string `json:"approvedBys"`
|
||||
CancelledBys []string `json:"cancelledBys"`
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package model
|
||||
|
||||
// ResponseListStaffInfoByNotificationAction ...
|
||||
type ResponseListStaffInfoByNotificationAction struct {
|
||||
CreatedBys []ResponseStaffInfo `json:"CreatedBys"`
|
||||
ApprovedBys []ResponseStaffInfo `json:"ApprovedBys"`
|
||||
CancelledBys []ResponseStaffInfo `json:"CancelledBys"`
|
||||
}
|
||||
|
||||
// ResponseStaffInfo ...
|
||||
type ResponseStaffInfo struct {
|
||||
ID string `json:"_id"`
|
||||
Name string `json:"name"`
|
||||
}
|
|
@ -17,6 +17,7 @@ var prefixes = struct {
|
|||
Withdraw string
|
||||
Notification string
|
||||
SocialPost string
|
||||
Staff string
|
||||
}{
|
||||
Communication: "communication",
|
||||
Order: "order",
|
||||
|
@ -34,4 +35,5 @@ var prefixes = struct {
|
|||
Withdraw: "withdraw",
|
||||
Notification: "notification",
|
||||
SocialPost: "social_post",
|
||||
Staff: "staff",
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package subject
|
||||
|
||||
import "fmt"
|
||||
|
||||
func getStaffValue(val string) string {
|
||||
return fmt.Sprintf("%s.%s", prefixes.Staff, val)
|
||||
}
|
||||
|
||||
var Staff = struct {
|
||||
GetListStaffInfoByNotificationAction string
|
||||
}{
|
||||
GetListStaffInfoByNotificationAction: getStaffValue("get_list_staff_info_by_notification_info"),
|
||||
}
|
Loading…
Reference in New Issue