From 29bdeb7d40610ae6d202ff08db89aa16cd547b99 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Tue, 24 May 2022 14:31:45 +0700 Subject: [PATCH] [Update] add request sync roles --- constants.go | 1 + request.go | 5 +++++ struct.go | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/constants.go b/constants.go index 17ee75b..df612b2 100644 --- a/constants.go +++ b/constants.go @@ -4,4 +4,5 @@ const ( SubjectRequestNatsCheckPermission = "authentication.request.staff.check_permission" SubjectRequestNatsGetPermission = "authentication.request.staff.list_permission" SubjectRequestNatsSyncStaff = "authentication.request.staff.sync_data" + SubjectRequestNatsSyncRole = "authentication.request.role.sync_data" ) diff --git a/request.go b/request.go index dc67886..0dc0589 100644 --- a/request.go +++ b/request.go @@ -18,3 +18,8 @@ func (Request) GetPermission(payload StaffGetPermissions) (*Response, error) { func (Request) SyncData(payload ListStaff) (*Response, error) { return requestNats(SubjectRequestNatsSyncStaff, toBytes(payload)) } + +// SyncRoleData ... +func (Request) SyncRoleData(payload ListRole) (*Response, error) { + return requestNats(SubjectRequestNatsSyncRole, toBytes(payload)) +} diff --git a/struct.go b/struct.go index 22fd526..71bf10f 100644 --- a/struct.go +++ b/struct.go @@ -4,6 +4,20 @@ import ( "github.com/Selly-Modules/natsio" ) +// Role ... +type Role struct { + ID string `bson:"_id"` + Name string `bson:"name"` + CreatedAt string `bson:"createdAt"` + UpdatedAt string `bson:"updatedAt"` + Permissions []string `bson:"permissions"` +} + +// ListRole ... +type ListRole struct { + Roles []Role `json:"roles"` +} + // Staff ... type Staff struct { ID string `json:"_id"` // ObjectID