build authsms

This commit is contained in:
Tue 2022-11-01 10:43:20 +07:00
parent 9a69327679
commit 645effaa04
5 changed files with 55 additions and 0 deletions

View File

@ -16,6 +16,27 @@ func GetSupplierUser() SupplierUser {
return 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) { func (s SupplierUser) CreateSupplierOwnerUsers(p model.CreateOwnerRequest) (*model.CreateOwnerResponse, error) {
msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p)) msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p))
if err != nil { if err != nil {

View File

@ -49,3 +49,9 @@ type SupplierFreeShipInfoResponse struct {
SupplierID string `json:"supplierId"` SupplierID string `json:"supplierId"`
FreeShips []FreeShip `json:"freeShips"` FreeShips []FreeShip `json:"freeShips"`
} }
type SupplierShort struct {
ID string `json:"_id"`
Name string `json:"name"`
Logo interface{} `json:"logo"`
}

View File

@ -1,5 +1,12 @@
package model package model
type GetListOwnerRequest struct {
Page int `json:"page"`
Limit int `json:"limit"`
Status string `json:"status"`
SupplierID string `json:"supplierId"`
}
type CreateOwnerRequest struct { type CreateOwnerRequest struct {
Name string `json:"name"` Name string `json:"name"`
Phone string `json:"phone"` Phone string `json:"phone"`

View File

@ -1,5 +1,24 @@
package model 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 { type CreateOwnerResponse struct {
ID string `json:"_id"` ID string `json:"_id"`
} }

View File

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