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

This commit is contained in:
Tue 2022-11-08 18:05:00 +07:00
commit 77547914e0
3 changed files with 71 additions and 18 deletions

View File

@ -37,6 +37,26 @@ func (s SupplierUser) LoginUser(p model.LoginUserRequest) (*model.LoginUserRespo
return r.Data, nil
}
func (s SupplierUser) Logout(p model.LogoutRequest) error {
msg, err := natsio.GetServer().Request(subject.SupplierUser.Logout, toBytes(p))
if err != nil {
return err
}
var r struct {
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}
func (s SupplierUser) GetListUser(p model.GetListUserRequest) (*model.GetListUserResponse, error) {
msg, err := natsio.GetServer().Request(subject.SupplierUser.GetListUser, toBytes(p))
if err != nil {
@ -201,3 +221,23 @@ func (s SupplierUser) ResetPassword(p model.ResetPasswordRequest) (*model.ResetP
return r.Data, nil
}
func (s SupplierUser) ChangePassword(p model.ChangePasswordRequest) error {
msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateStatus, toBytes(p))
if err != nil {
return err
}
var r struct {
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}

View File

@ -17,6 +17,10 @@ type LoginUserRequest struct {
IsMobile bool `json:"isMobile"`
}
type LogoutRequest struct {
ID string `json:"_id"`
}
type GetListUserRequest struct {
Page int `json:"page"`
Limit int `json:"limit"`
@ -75,3 +79,8 @@ type UpdateStatusRequest struct {
type ResetPasswordRequest struct {
ID string `json:"_id"`
}
type ChangePasswordRequest struct {
ID string `json:"_id"`
Password string `json:"password"`
}

View File

@ -8,24 +8,28 @@ func getSupplierUserValue(val string) string {
var SupplierUser = struct {
// Users
LoginUser string
GetListUser string
DetailUser string
CreateOwner string
UpdateOwner string
CreateStaff string
UpdateStaff string
UpdateStatus string
ResetPassword string
LoginUser string
Logout string
GetListUser string
DetailUser string
CreateOwner string
UpdateOwner string
CreateStaff string
UpdateStaff string
UpdateStatus string
ResetPassword string
ChangePassword string
}{
// Users
LoginUser: getSupplierUserValue("login_user"),
GetListUser: getSupplierUserValue("get_list_user"),
DetailUser: getSupplierUserValue("detail_user"),
CreateOwner: getSupplierUserValue("create_owner"),
UpdateOwner: getSupplierUserValue("update_owner"),
CreateStaff: getSupplierUserValue("create_staff"),
UpdateStaff: getSupplierUserValue("update_staff"),
UpdateStatus: getSupplierUserValue("update_status"),
ResetPassword: getSupplierUserValue("reset_password"),
LoginUser: getSupplierUserValue("login_user"),
Logout: getSupplierUserValue("logout"),
GetListUser: getSupplierUserValue("get_list_user"),
DetailUser: getSupplierUserValue("detail_user"),
CreateOwner: getSupplierUserValue("create_owner"),
UpdateOwner: getSupplierUserValue("update_owner"),
CreateStaff: getSupplierUserValue("create_staff"),
UpdateStaff: getSupplierUserValue("update_staff"),
UpdateStatus: getSupplierUserValue("update_status"),
ResetPassword: getSupplierUserValue("reset_password"),
ChangePassword: getSupplierUserValue("change_password"),
}