2022-05-23 07:04:01 +00:00
|
|
|
package authentication
|
|
|
|
|
2022-05-24 03:14:51 +00:00
|
|
|
import (
|
|
|
|
"github.com/Selly-Modules/natsio"
|
2022-05-30 03:10:33 +00:00
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
2022-05-24 03:14:51 +00:00
|
|
|
)
|
|
|
|
|
2022-05-30 03:10:33 +00:00
|
|
|
// CommonQuery ...
|
|
|
|
type CommonQuery struct {
|
|
|
|
Page int64 `json:"page"`
|
|
|
|
Limit int64 `json:"limit"`
|
|
|
|
Keyword string `json:"keyword"`
|
|
|
|
Sort bson.D `json:"sort"`
|
|
|
|
StaffID string `json:"staffID"`
|
|
|
|
}
|
|
|
|
|
2022-06-03 06:53:17 +00:00
|
|
|
// GetTokenByPhoneBody ...
|
|
|
|
type GetTokenByPhoneBody struct {
|
|
|
|
Phone string `json:"phone"`
|
|
|
|
}
|
|
|
|
|
2022-06-03 06:56:32 +00:00
|
|
|
// GetTokenByPhoneResponse ...
|
|
|
|
type GetTokenByPhoneResponse struct {
|
|
|
|
Token string `json:"token"`
|
|
|
|
}
|
|
|
|
|
2022-06-30 04:26:22 +00:00
|
|
|
// GetInfoStaff ...
|
|
|
|
type GetInfoStaff struct {
|
|
|
|
Condition interface{} `json:"condition"`
|
|
|
|
}
|
|
|
|
|
2022-05-27 07:45:10 +00:00
|
|
|
// Log ...
|
|
|
|
type Log struct {
|
|
|
|
Reference string `json:"reference"`
|
|
|
|
Payload PayloadCheckPermission `json:"payload"`
|
|
|
|
Source string `json:"source"`
|
|
|
|
Permission []string `json:"permission"`
|
|
|
|
Action string `json:"action"`
|
|
|
|
}
|
|
|
|
|
2022-05-30 03:10:33 +00:00
|
|
|
// LogsResponse ...
|
|
|
|
type LogsResponse struct {
|
|
|
|
ID string `json:"_id"`
|
|
|
|
Staff string `json:"staff"`
|
|
|
|
Payload PayloadCheckPermission `json:"payload"`
|
|
|
|
Action string `json:"action"`
|
|
|
|
CreatedAt string `json:"createdAt"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListPageResponse ...
|
|
|
|
type ListPageResponse struct {
|
|
|
|
Data []interface{} `json:"data"`
|
|
|
|
Total int64 `json:"total"`
|
|
|
|
Page int64 `json:"page"`
|
|
|
|
Limit int64 `json:"limit"`
|
|
|
|
}
|
|
|
|
|
2022-05-24 03:14:51 +00:00
|
|
|
// Staff ...
|
|
|
|
type Staff struct {
|
2022-05-25 06:57:11 +00:00
|
|
|
Reference string `json:"reference"` // ObjectID
|
2022-05-25 03:46:34 +00:00
|
|
|
Name string `json:"name"`
|
2022-05-26 02:30:35 +00:00
|
|
|
Email string `json:"email"`
|
2022-05-25 03:46:34 +00:00
|
|
|
Phone string `json:"phone"`
|
|
|
|
Active bool `json:"active"`
|
|
|
|
IsRoot bool `json:"isRoot"`
|
|
|
|
Permissions []string `json:"permissions"`
|
2022-05-27 07:45:10 +00:00
|
|
|
Source []string `json:"source"`
|
2022-05-24 03:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ListStaff ...
|
|
|
|
type ListStaff struct {
|
|
|
|
Staffs []Staff `json:"staffs"`
|
|
|
|
}
|
2022-05-23 07:04:01 +00:00
|
|
|
|
|
|
|
// Config int client elasticsearch
|
|
|
|
type Config struct {
|
|
|
|
ApiKey string
|
|
|
|
Nats natsio.Config
|
|
|
|
}
|
|
|
|
|
2022-06-29 02:00:30 +00:00
|
|
|
// Agent ...
|
|
|
|
type Agent struct {
|
|
|
|
Source string `json:"source"`
|
|
|
|
IP string `json:"ip"`
|
|
|
|
Platform string `json:"platform"`
|
|
|
|
Version string `json:"version"`
|
|
|
|
}
|
|
|
|
|
2022-05-23 07:04:01 +00:00
|
|
|
// StaffCheckPermissionBody ...
|
|
|
|
type StaffCheckPermissionBody struct {
|
2022-06-29 02:00:30 +00:00
|
|
|
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"`
|
2022-05-25 01:58:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// PayloadCheckPermission ...
|
|
|
|
type PayloadCheckPermission struct {
|
|
|
|
URL string `json:"url"`
|
|
|
|
Body string `json:"body"`
|
|
|
|
Method string `json:"method"`
|
2022-05-23 07:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// StaffCheckPermissionResponse ...
|
|
|
|
type StaffCheckPermissionResponse struct {
|
|
|
|
Message string `json:"message"`
|
|
|
|
IsValid bool `json:"isValid"`
|
2022-06-14 07:31:02 +00:00
|
|
|
Code int `json:"code"`
|
2022-05-23 07:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// StaffGetPermissions ...
|
|
|
|
type StaffGetPermissions struct {
|
|
|
|
StaffID string `json:"staffId"`
|
|
|
|
Source string `json:"source"`
|
2022-05-26 02:30:35 +00:00
|
|
|
Prefix string `json:"prefix"`
|
2022-05-23 07:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// StaffGetPermissionsResponse ...
|
|
|
|
type StaffGetPermissionsResponse struct {
|
|
|
|
Permissions []string `json:"permissions"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequestBody ...
|
|
|
|
type RequestBody struct {
|
|
|
|
Body []byte `json:"body"`
|
|
|
|
ApiKey string `json:"apiKey"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Response
|
|
|
|
// response to service es
|
|
|
|
type Response struct {
|
|
|
|
Success bool `json:"success"`
|
|
|
|
Data []byte `json:"data,omitempty"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
}
|