get list permission authsms

This commit is contained in:
QuanTT0110 2022-10-21 11:49:48 +07:00
parent b5fe2c5a71
commit f0eb62f3f5
3 changed files with 30 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import (
"git.selly.red/Selly-Modules/natsio" "git.selly.red/Selly-Modules/natsio"
"git.selly.red/Selly-Modules/natsio/model" "git.selly.red/Selly-Modules/natsio/model"
"git.selly.red/Selly-Modules/natsio/subject" "git.selly.red/Selly-Modules/natsio/subject"
"go.mongodb.org/mongo-driver/bson"
) )
// AuthSMS ... // AuthSMS ...
@ -36,3 +37,24 @@ func (s AuthSMS) CreateUserSMSViaAuthSMS(p model.CreateUserSMSRequest) (*model.C
return r.Data, nil return r.Data, nil
} }
func (s AuthSMS) GetListPermission() (*model.GetListPermissionResponse, error) {
msg, err := natsio.GetServer().Request(subject.AuthSMS.GetListPermission, toBytes(bson.M{}))
if err != nil {
return nil, err
}
var r struct {
Data *model.GetListPermissionResponse `json:"data"`
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return nil, err
}
if r.Error != "" {
return nil, errors.New(r.Error)
}
return r.Data, nil
}

View File

@ -3,3 +3,7 @@ package model
type CreateUserSMSResponse struct { type CreateUserSMSResponse struct {
ID string `json:"_id"` ID string `json:"_id"`
} }
type GetListPermissionResponse struct {
Permission []string `json:"permission"`
}

View File

@ -7,7 +7,9 @@ func getAuthSMSValue(val string) string {
} }
var AuthSMS = struct { var AuthSMS = struct {
CreateUserSMS string CreateUserSMS string
GetListPermission string
}{ }{
CreateUserSMS: getAuthSMSValue("create_user_sms"), CreateUserSMS: getAuthSMSValue("create_user_sms"),
GetListPermission: getAuthSMSValue("get_list_permission"),
} }