build auth sms
This commit is contained in:
		
							parent
							
								
									2872e4f75b
								
							
						
					
					
						commit
						3507d17029
					
				| 
						 | 
				
			
			@ -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
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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"),
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue