From 1b03ec9c794524235562a66fbee0b77c74162ed0 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Thu, 30 Jun 2022 12:07:07 +0700 Subject: [PATCH] [Update] Get staff info --- constants.go | 1 + request.go | 5 +++++ struct.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/constants.go b/constants.go index c89d0fd..a107bb1 100644 --- a/constants.go +++ b/constants.go @@ -8,6 +8,7 @@ const ( SubjectRequestNatsStaffCreate = "authentication.request.staff.create" SubjectRequestNatsStaffUpdate = "authentication.request.staff.update" SubjectRequestNatsStaffGetInfo = "authentication.request.staff.get_info" + SubjectRequestNatsStaffGetList = "authentication.request.staff.list" SubjectRequestNatsAddLogs = "authentication.request.logs.create" SubjectRequestNatsLogsGetList = "authentication.request.logs.list" diff --git a/request.go b/request.go index 06044af..a80a6e1 100644 --- a/request.go +++ b/request.go @@ -34,6 +34,11 @@ func (Request) GetInfoStaff(payload GetInfoStaff) (*Response, error) { return requestNats(SubjectRequestNatsStaffGetInfo, toBytes(payload)) } +// GetListStaff ... +func (Request) GetListStaff(payload GetInfoStaff) (*Response, error) { + return requestNats(SubjectRequestNatsStaffGetList, toBytes(payload)) +} + // SaveLog ... func (Request) SaveLog(payload Log) (*Response, error) { return requestNats(SubjectRequestNatsAddLogs, toBytes(payload)) diff --git a/struct.go b/struct.go index 6cff8bf..0074aa6 100644 --- a/struct.go +++ b/struct.go @@ -3,6 +3,8 @@ package authentication import ( "github.com/Selly-Modules/natsio" "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" + "time" ) // CommonQuery ... @@ -128,3 +130,46 @@ type Response struct { Data []byte `json:"data,omitempty"` Message string `json:"message"` } + +// StaffInfo ... +type StaffInfo struct { + ID primitive.ObjectID `json:"_id"` + Name string `json:"name"` + SearchString string `json:"searchString"` + Email string `json:"email"` + Phone string `json:"phone"` + Active bool `json:"active"` + Role primitive.ObjectID `json:"role,omitempty"` + Avatar *FilePhoto `json:"avatar,omitempty"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + IsRoot bool `json:"isRoot"` + Permissions []string `json:"permissions"` + Source []string `json:"source"` + NotAllowedLoginAdmin bool `json:"notAllowedLoginAdmin"` +} + +// ListStaffInfo ... +type ListStaffInfo struct { + Staffs []StaffInfo `json:"staff"` +} + +// FilePhoto ... +type FilePhoto struct { + ID primitive.ObjectID `json:"_id"` + Name string `json:"name,omitempty"` + Dimensions *FileDimensions `json:"dimensions"` +} + +// FileSize ... +type FileSize struct { + Width int `json:"width"` + Height int `json:"height"` + URL string `json:"url"` +} + +// FileDimensions ... +type FileDimensions struct { + Small *FileSize `json:"sm"` + Medium *FileSize `json:"md"` +}