Merge pull request #4 from Selly-Modules/update-permission

Update permission
This commit is contained in:
trunglt251292 2022-07-01 09:26:53 +07:00 committed by GitHub
commit 6c89c989e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"github.com/Selly-Modules/natsio"
"go.mongodb.org/mongo-driver/bson"
)
// Client ...
@ -69,3 +70,9 @@ func toBytes(data interface{}) []byte {
b, _ := json.Marshal(data)
return b
}
// bsonToBytes ...
func bsonToBytes(data interface{}) []byte {
b, _ := bson.Marshal(data)
return b
}

View File

@ -7,6 +7,8 @@ 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"

View File

@ -29,6 +29,16 @@ func (Request) UpdateStaff(payload Staff) (*Response, error) {
return requestNats(SubjectRequestNatsStaffUpdate, toBytes(payload))
}
// GetInfoStaff ...
func (Request) GetInfoStaff(payload GetInfoStaff) (*Response, error) {
return requestNats(SubjectRequestNatsStaffGetInfo, bsonToBytes(payload))
}
// GetListStaff ...
func (Request) GetListStaff(payload GetInfoStaff) (*Response, error) {
return requestNats(SubjectRequestNatsStaffGetList, bsonToBytes(payload))
}
// SaveLog ...
func (Request) SaveLog(payload Log) (*Response, error) {
return requestNats(SubjectRequestNatsAddLogs, toBytes(payload))

View File

@ -24,6 +24,16 @@ type GetTokenByPhoneResponse struct {
Token string `json:"token"`
}
// GetInfoStaff
// Convert to bson bytes
// When partner use. Bson unmarshal convert to struct
type GetInfoStaff struct {
Condition interface{}
Page int64
Limit int64
Sort bson.D
}
// Log ...
type Log struct {
Reference string `json:"reference"`
@ -73,6 +83,14 @@ type Config struct {
Nats natsio.Config
}
// Agent ...
type Agent struct {
Source string `json:"source"`
IP string `json:"ip"`
Platform string `json:"platform"`
Version string `json:"version"`
}
// StaffCheckPermissionBody ...
type StaffCheckPermissionBody struct {
StaffID string `json:"staffId"`
@ -81,6 +99,9 @@ type StaffCheckPermissionBody struct {
Source string `json:"source"`
Code string `json:"code,omitempty"`
IsRoot string `json:"isRoot"`
Agent Agent `json:"agent"`
DeviceId string `json:"deviceId"`
Payload PayloadCheckPermission `json:"payload"`
}
// PayloadCheckPermission ...