From 283974d869d76a8ae4ad9ee57e6b6dca10b992de Mon Sep 17 00:00:00 2001 From: Tue Date: Fri, 4 Nov 2022 17:28:33 +0700 Subject: [PATCH] build auth sms --- client/supplier_user.go | 21 +++++++++++++++++++++ model/supplier_user_request.go | 4 ++++ subject/supplier_user.go | 2 ++ 3 files changed, 27 insertions(+) diff --git a/client/supplier_user.go b/client/supplier_user.go index 2a1939a..8f0762b 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -58,6 +58,27 @@ func (s SupplierUser) GetListUser(p model.GetListUserRequest) (*model.GetListUse return r.Data, nil } +func (s SupplierUser) DetailUser(p model.DetailUserRequest) (*model.SupplierUserBrief, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.DetailUser, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.SupplierUserBrief `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 { diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 84afd1d..fe359bb 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -25,6 +25,10 @@ type GetListUserRequest struct { SupplierID string `json:"supplierId"` } +type DetailUserRequest struct { + ID string `json:"_id"` +} + type CreateOwnerRequest struct { Name string `json:"name"` Phone string `json:"phone"` diff --git a/subject/supplier_user.go b/subject/supplier_user.go index 2ad5b4d..e70c032 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -10,6 +10,7 @@ var SupplierUser = struct { // Users LoginUser string GetListUser string + DetailUser string CreateOwner string UpdateOwner string CreateStaff string @@ -20,6 +21,7 @@ var SupplierUser = struct { // 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"),