build auth sms
This commit is contained in:
parent
0d8e3969db
commit
56d210bf2d
|
@ -16,6 +16,27 @@ func GetSupplierUser() SupplierUser {
|
|||
return SupplierUser{}
|
||||
}
|
||||
|
||||
func (s SupplierUser) GetListOwner(p model.GetListOwnerRequest) (*model.GetListOwnerResponse, error) {
|
||||
msg, err := natsio.GetServer().Request(subject.SupplierUser.GetListOwner, toBytes(p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var r struct {
|
||||
Data *model.GetListOwnerResponse `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) CreateSupplierOwnerUsers(p model.CreateOwnerRequest) (*model.CreateOwnerResponse, error) {
|
||||
msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p))
|
||||
if err != nil {
|
||||
|
|
|
@ -29,3 +29,9 @@ type SupplierAll struct {
|
|||
Suppliers []SupplierBrief `json:"suppliers"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
type SupplierShort struct {
|
||||
ID string `json:"_id"`
|
||||
Name string `json:"name"`
|
||||
Logo interface{} `json:"logo"`
|
||||
}
|
|
@ -1,5 +1,12 @@
|
|||
package model
|
||||
|
||||
type GetListOwnerRequest struct {
|
||||
Page int `json:"page"`
|
||||
Limit int `json:"limit"`
|
||||
Status string `json:"status"`
|
||||
SupplierID string `json:"supplierId"`
|
||||
}
|
||||
|
||||
type CreateOwnerRequest struct {
|
||||
Name string `json:"name"`
|
||||
Phone string `json:"phone"`
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
package model
|
||||
|
||||
type GetListOwnerResponse struct {
|
||||
SupplierUsers []SupplierUserBrief `json:"supplierUsers"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
type SupplierUserBrief struct {
|
||||
ID string `json:"_id"`
|
||||
Role RoleBrief `json:"role"`
|
||||
Supplier SupplierShort `json:"supplier"`
|
||||
Name string `json:"name"`
|
||||
Phone string `json:"phone"`
|
||||
Email string `json:"email"`
|
||||
Status string `json:"status"`
|
||||
Avatar interface{} `json:"avatar"`
|
||||
Type string `json:"type"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type CreateOwnerResponse struct {
|
||||
ID string `json:"_id"`
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ func getSupplierUserValue(val string) string {
|
|||
|
||||
var SupplierUser = struct {
|
||||
// Users
|
||||
GetListOwner string
|
||||
CreateOwner string
|
||||
UpdateOwner string
|
||||
CreateStaff string
|
||||
|
@ -16,6 +17,7 @@ var SupplierUser = struct {
|
|||
ResetPassword string
|
||||
}{
|
||||
// Users
|
||||
GetListOwner: getSupplierUserValue("get_list_owner"),
|
||||
CreateOwner: getSupplierUserValue("create_owner"),
|
||||
UpdateOwner: getSupplierUserValue("update_owner"),
|
||||
CreateStaff: getSupplierUserValue("create_staff"),
|
||||
|
|
Loading…
Reference in New Issue