Merge branch 'build-auth-sms' of git.selly.red:Selly-Modules/natsio into develop

This commit is contained in:
Tue 2022-11-02 16:49:20 +07:00
commit bd5825b7f8
4 changed files with 48 additions and 0 deletions

View File

@ -16,6 +16,27 @@ func GetSupplierUser() SupplierUser {
return SupplierUser{}
}
func (s SupplierUser) LoginUser(p model.LoginUserRequest) (*model.LoginUserResponse, error) {
msg, err := natsio.GetServer().Request(subject.SupplierUser.LoginUser, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.LoginUserResponse `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
}
func (s SupplierUser) GetListOwner(p model.GetListOwnerRequest) (*model.GetListOwnerResponse, error) {
msg, err := natsio.GetServer().Request(subject.SupplierUser.GetListOwner, toBytes(p))
if err != nil {

View File

@ -1,5 +1,22 @@
package model
type LoginUserRequest struct {
Email string `json:"email"`
Password string `json:"password"`
DeviceID string `json:"deviceId"`
AppVersion string `json:"appVersion"`
UserAgent string `json:"userAgent"`
Model string `json:"model"`
Manufacturer string `json:"manufacturer"`
IP string `json:"ip"`
Language string `json:"language"`
FCMToken string `json:"FCMToken"`
AuthToken string `json:"authToken"`
OsName string `json:"osName"`
OsVersion string `json:"osVersion"`
IsMobile bool `json:"isMobile"`
}
type GetListOwnerRequest struct {
Page int `json:"page"`
Limit int `json:"limit"`

View File

@ -1,5 +1,13 @@
package model
// LoginUserResponse ...
type LoginUserResponse struct {
ID string `json:"_id"`
Token string `json:"token"`
RequireToChangePassword bool `json:"requireToChangePassword"`
SupplierID string `json:"supplierId"`
}
type GetListOwnerResponse struct {
SupplierUsers []SupplierUserBrief `json:"supplierUsers"`
Total int64 `json:"total"`

View File

@ -8,6 +8,7 @@ func getSupplierUserValue(val string) string {
var SupplierUser = struct {
// Users
LoginUser string
GetListOwner string
CreateOwner string
UpdateOwner string
@ -17,6 +18,7 @@ var SupplierUser = struct {
ResetPassword string
}{
// Users
LoginUser: getSupplierUserValue("login_user"),
GetListOwner: getSupplierUserValue("get_list_owner"),
CreateOwner: getSupplierUserValue("create_owner"),
UpdateOwner: getSupplierUserValue("update_owner"),