Update permission #4
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -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
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,8 +5,10 @@ const (
 | 
			
		|||
	SubjectRequestNatsGetPermission   = "authentication.request.staff.list_permission"
 | 
			
		||||
	SubjectRequestNatsSyncStaff       = "authentication.request.staff.sync_data"
 | 
			
		||||
 | 
			
		||||
	SubjectRequestNatsStaffCreate = "authentication.request.staff.create"
 | 
			
		||||
	SubjectRequestNatsStaffUpdate = "authentication.request.staff.update"
 | 
			
		||||
	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"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								request.go
								
								
								
								
							
							
						
						
									
										10
									
								
								request.go
								
								
								
								
							| 
						 | 
				
			
			@ -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))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										33
									
								
								struct.go
								
								
								
								
							
							
						
						
									
										33
									
								
								struct.go
								
								
								
								
							| 
						 | 
				
			
			@ -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,14 +83,25 @@ 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"`
 | 
			
		||||
	Token      string   `json:"token"`
 | 
			
		||||
	Permission []string `json:"permission"`
 | 
			
		||||
	Source     string   `json:"source"`
 | 
			
		||||
	Code       string   `json:"code,omitempty"`
 | 
			
		||||
	IsRoot     string   `json:"isRoot"`
 | 
			
		||||
	StaffID    string                 `json:"staffId"`
 | 
			
		||||
	Token      string                 `json:"token"`
 | 
			
		||||
	Permission []string               `json:"permission"`
 | 
			
		||||
	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 ...
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue