From 2bbb1aec3f0a1be20ce5f812b7b2d5693893f97e Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Tue, 24 May 2022 10:14:51 +0700 Subject: [PATCH] [Update] add request sync staff --- constants.go | 1 + request.go | 5 +++++ struct.go | 25 ++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/constants.go b/constants.go index f3c95f9..17ee75b 100644 --- a/constants.go +++ b/constants.go @@ -3,4 +3,5 @@ package authentication const ( SubjectRequestNatsCheckPermission = "authentication.request.staff.check_permission" SubjectRequestNatsGetPermission = "authentication.request.staff.list_permission" + SubjectRequestNatsSyncStaff = "authentication.request.staff.sync_data" ) diff --git a/request.go b/request.go index 88426ed..dc67886 100644 --- a/request.go +++ b/request.go @@ -13,3 +13,8 @@ func (Request) CheckPermission(payload StaffCheckPermissionBody) (*Response, err func (Request) GetPermission(payload StaffGetPermissions) (*Response, error) { return requestNats(SubjectRequestNatsGetPermission, toBytes(payload)) } + +// SyncData ... +func (Request) SyncData(payload ListStaff) (*Response, error) { + return requestNats(SubjectRequestNatsSyncStaff, toBytes(payload)) +} diff --git a/struct.go b/struct.go index 83ed60e..22fd526 100644 --- a/struct.go +++ b/struct.go @@ -1,6 +1,29 @@ package authentication -import "github.com/Selly-Modules/natsio" +import ( + "github.com/Selly-Modules/natsio" +) + +// Staff ... +type Staff struct { + ID string `json:"_id"` // ObjectID + Name string `json:"name"` + Phone string `json:"phone"` + Active bool `json:"active"` + Role string `json:"role,omitempty"` // ObjectID + Avatar []byte `json:"avatar,omitempty"` // FilePhoto + CreatedAt string `json:"createdAt"` // ISOString + UpdatedAt string `json:"updatedAt"` // ISOString + IsRoot bool `json:"isRoot"` + Permissions []string `json:"permissions"` + NotAllowedLoginAdmin bool `json:"notAllowedLoginAdmin"` + Source []string `json:"source"` +} + +// ListStaff ... +type ListStaff struct { + Staffs []Staff `json:"staffs"` +} // Config int client elasticsearch type Config struct {