Merge pull request #4 from Selly-Modules/update-permission
Update permission
This commit is contained in:
commit
6c89c989e3
|
@ -5,6 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Selly-Modules/natsio"
|
"github.com/Selly-Modules/natsio"
|
||||||
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client ...
|
// Client ...
|
||||||
|
@ -69,3 +70,9 @@ func toBytes(data interface{}) []byte {
|
||||||
b, _ := json.Marshal(data)
|
b, _ := json.Marshal(data)
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bsonToBytes ...
|
||||||
|
func bsonToBytes(data interface{}) []byte {
|
||||||
|
b, _ := bson.Marshal(data)
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ const (
|
||||||
|
|
||||||
SubjectRequestNatsStaffCreate = "authentication.request.staff.create"
|
SubjectRequestNatsStaffCreate = "authentication.request.staff.create"
|
||||||
SubjectRequestNatsStaffUpdate = "authentication.request.staff.update"
|
SubjectRequestNatsStaffUpdate = "authentication.request.staff.update"
|
||||||
|
SubjectRequestNatsStaffGetInfo = "authentication.request.staff.get_info"
|
||||||
|
SubjectRequestNatsStaffGetList = "authentication.request.staff.list"
|
||||||
|
|
||||||
SubjectRequestNatsAddLogs = "authentication.request.logs.create"
|
SubjectRequestNatsAddLogs = "authentication.request.logs.create"
|
||||||
SubjectRequestNatsLogsGetList = "authentication.request.logs.list"
|
SubjectRequestNatsLogsGetList = "authentication.request.logs.list"
|
||||||
|
|
10
request.go
10
request.go
|
@ -29,6 +29,16 @@ func (Request) UpdateStaff(payload Staff) (*Response, error) {
|
||||||
return requestNats(SubjectRequestNatsStaffUpdate, toBytes(payload))
|
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 ...
|
// SaveLog ...
|
||||||
func (Request) SaveLog(payload Log) (*Response, error) {
|
func (Request) SaveLog(payload Log) (*Response, error) {
|
||||||
return requestNats(SubjectRequestNatsAddLogs, toBytes(payload))
|
return requestNats(SubjectRequestNatsAddLogs, toBytes(payload))
|
||||||
|
|
21
struct.go
21
struct.go
|
@ -24,6 +24,16 @@ type GetTokenByPhoneResponse struct {
|
||||||
Token string `json:"token"`
|
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 ...
|
// Log ...
|
||||||
type Log struct {
|
type Log struct {
|
||||||
Reference string `json:"reference"`
|
Reference string `json:"reference"`
|
||||||
|
@ -73,6 +83,14 @@ type Config struct {
|
||||||
Nats natsio.Config
|
Nats natsio.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Agent ...
|
||||||
|
type Agent struct {
|
||||||
|
Source string `json:"source"`
|
||||||
|
IP string `json:"ip"`
|
||||||
|
Platform string `json:"platform"`
|
||||||
|
Version string `json:"version"`
|
||||||
|
}
|
||||||
|
|
||||||
// StaffCheckPermissionBody ...
|
// StaffCheckPermissionBody ...
|
||||||
type StaffCheckPermissionBody struct {
|
type StaffCheckPermissionBody struct {
|
||||||
StaffID string `json:"staffId"`
|
StaffID string `json:"staffId"`
|
||||||
|
@ -81,6 +99,9 @@ type StaffCheckPermissionBody struct {
|
||||||
Source string `json:"source"`
|
Source string `json:"source"`
|
||||||
Code string `json:"code,omitempty"`
|
Code string `json:"code,omitempty"`
|
||||||
IsRoot string `json:"isRoot"`
|
IsRoot string `json:"isRoot"`
|
||||||
|
Agent Agent `json:"agent"`
|
||||||
|
DeviceId string `json:"deviceId"`
|
||||||
|
Payload PayloadCheckPermission `json:"payload"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PayloadCheckPermission ...
|
// PayloadCheckPermission ...
|
||||||
|
|
Loading…
Reference in New Issue