From 067db844897e007e19e9f94336820d30deccee0a Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Fri, 23 Dec 2022 03:32:15 +0700 Subject: [PATCH 01/13] add get,create, update supplier-holiday --- client/warehouse.go | 63 +++++++++++++++++++++++++++++++++++++ model/warehouse_request.go | 25 +++++++++++++++ model/warehouse_response.go | 17 ++++++++++ subject/warehouse.go | 6 ++++ 4 files changed, 111 insertions(+) diff --git a/client/warehouse.go b/client/warehouse.go index fb391ca..664df43 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -182,3 +182,66 @@ func (w Warehouse) UpdateORDeliveryStatus(p model.WarehouseORUpdateDeliveryStatu } return nil } + +// CreateSupplierHoliday ... +func (w Warehouse) CreateSupplierHoliday(p model.SupplierHolidayCreatePayload) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.CreateSupplierHoliday, toBytes(p)) + if err != nil { + return err + } + + var r struct { + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return fmt.Errorf("nats: create_supplier_holiday %v", err) + } + if r.Error != "" { + return errors.New(r.Error) + } + return nil +} + +// UpdateSupplierHoliday ... +func (w Warehouse) UpdateSupplierHoliday(p model.SupplierHolidayUpdatePayload) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateSupplierHoliday, toBytes(p)) + if err != nil { + return err + } + + var r struct { + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return fmt.Errorf("nats: create_supplier_holiday %v", err) + } + if r.Error != "" { + return errors.New(r.Error) + } + return nil +} + +// GetSupplierHoliday ... +func (w Warehouse) GetSupplierHoliday(p model.GetSupplierHolidayRequest) (*model.ResponseSupplierHoliday, error) { + msg, err := natsio.GetServer().Request(subject.Warehouse.GetSupplierHoliday, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseSupplierHoliday `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 +} diff --git a/model/warehouse_request.go b/model/warehouse_request.go index b6cecb1..c2b267a 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -113,3 +113,28 @@ type WarehouseORUpdateDeliveryStatus struct { OrderID string `json:"orderId"` DeliveryStatus string `json:"deliveryStatus"` } + +// SupplierHolidayCreatePayload ... +type SupplierHolidayCreatePayload struct { + Supplier string `json:"supplier"` + Title string `json:"title"` + From string `json:"from"` + To string `json:"to"` + Warehouses []string `json:"warehouses"` + IsApplyAll bool `json:"isApplyAll"` +} + +// SupplierHolidayUpdatePayload ... +type SupplierHolidayUpdatePayload struct { + Supplier string `json:"supplier"` + Title string `json:"title"` + From string `json:"from"` + To string `json:"to"` + Warehouses []string `json:"warehouses"` + IsApplyAll bool `json:"isApplyAll"` +} + +// GetSupplierHolidayRequest ... +type GetSupplierHolidayRequest struct { + Conditions interface{} `json:"conditions"` +} diff --git a/model/warehouse_response.go b/model/warehouse_response.go index 6359ae3..e5d556b 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -172,3 +172,20 @@ type GetWarehousesResponse struct { Limit int64 `json:"limit"` List []WarehouseInfo `json:"list"` } + +// ResponseWarehouseShort ... +type ResponseWarehouseShort struct { + ID string `json:"_id"` + Name string `json:"name"` +} + +// ResponseSupplierHoliday ... +type ResponseSupplierHoliday struct { + Title string `json:"title"` + From string `json:"from"` + To string `json:"to"` + Status string `json:"status"` + Reason string `json:"reason"` + IsApplyAll bool `json:"isApplyAll"` + Warehouses []ResponseWarehouseShort `json:"warehouses"` +} diff --git a/subject/warehouse.go b/subject/warehouse.go index bb184b5..51be4c7 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -26,6 +26,9 @@ var Warehouse = struct { UpdateIsClosedSupplier string GetWarehouses string UpdateORDeliveryStatus string + CreateSupplierHoliday string + UpdateSupplierHoliday string + GetSupplierHoliday string }{ CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), @@ -46,4 +49,7 @@ var Warehouse = struct { UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), GetWarehouses: getWarehouseValue("get_warehouses"), UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"), + CreateSupplierHoliday: getWarehouseValue("create_supplier_holiday"), + UpdateSupplierHoliday: getWarehouseValue("update_supplier_holiday"), + GetSupplierHoliday: getWarehouseValue("get_supplier_holiday"), } -- 2.34.1 From e00922334c0661b1ba08dd589ca763960c7f8a26 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Fri, 23 Dec 2022 11:23:31 +0700 Subject: [PATCH 02/13] fix add file source supplierHolidayPayloadCreate --- model/warehouse_request.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index c2b267a..6ea5bed 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -132,6 +132,7 @@ type SupplierHolidayUpdatePayload struct { To string `json:"to"` Warehouses []string `json:"warehouses"` IsApplyAll bool `json:"isApplyAll"` + Source string `json:"source"` } // GetSupplierHolidayRequest ... -- 2.34.1 From 5ec216067db1071740e21c4982aada9bf25631f5 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Fri, 23 Dec 2022 11:36:33 +0700 Subject: [PATCH 03/13] add field supplier-holiday --- model/warehouse_request.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 6ea5bed..550e870 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -122,6 +122,7 @@ type SupplierHolidayCreatePayload struct { To string `json:"to"` Warehouses []string `json:"warehouses"` IsApplyAll bool `json:"isApplyAll"` + Source string `json:"source"` } // SupplierHolidayUpdatePayload ... -- 2.34.1 From daac1da25daf78fb46456924e11fca0b2bb15c60 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Fri, 23 Dec 2022 14:47:09 +0700 Subject: [PATCH 04/13] delete suppler-holiday && add checkTokenSupplier --- client/supplier.go | 20 ++++++++++++ client/warehouse.go | 63 ------------------------------------- model/supplier_request.go | 5 +++ model/warehouse_request.go | 27 ---------------- model/warehouse_response.go | 17 ---------- subject/supplier.go | 2 ++ subject/warehouse.go | 6 ---- 7 files changed, 27 insertions(+), 113 deletions(-) diff --git a/client/supplier.go b/client/supplier.go index 9b53826..b10f982 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -178,3 +178,23 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh } return nil } + +// CheckTokenSupplier ... +func (s Supplier) CheckTokenSupplier(p model.CheckTokenSupplierPayload) (*model.ResponseSupplierInfo, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.CheckTokenSupplier, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Error string `json:"error"` + Data *model.ResponseSupplierInfo `json:"data"` + } + 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 +} diff --git a/client/warehouse.go b/client/warehouse.go index 664df43..fb391ca 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -182,66 +182,3 @@ func (w Warehouse) UpdateORDeliveryStatus(p model.WarehouseORUpdateDeliveryStatu } return nil } - -// CreateSupplierHoliday ... -func (w Warehouse) CreateSupplierHoliday(p model.SupplierHolidayCreatePayload) error { - msg, err := natsio.GetServer().Request(subject.Warehouse.CreateSupplierHoliday, toBytes(p)) - if err != nil { - return err - } - - var r struct { - Error string `json:"error"` - } - - if err = json.Unmarshal(msg.Data, &r); err != nil { - return fmt.Errorf("nats: create_supplier_holiday %v", err) - } - if r.Error != "" { - return errors.New(r.Error) - } - return nil -} - -// UpdateSupplierHoliday ... -func (w Warehouse) UpdateSupplierHoliday(p model.SupplierHolidayUpdatePayload) error { - msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateSupplierHoliday, toBytes(p)) - if err != nil { - return err - } - - var r struct { - Error string `json:"error"` - } - - if err = json.Unmarshal(msg.Data, &r); err != nil { - return fmt.Errorf("nats: create_supplier_holiday %v", err) - } - if r.Error != "" { - return errors.New(r.Error) - } - return nil -} - -// GetSupplierHoliday ... -func (w Warehouse) GetSupplierHoliday(p model.GetSupplierHolidayRequest) (*model.ResponseSupplierHoliday, error) { - msg, err := natsio.GetServer().Request(subject.Warehouse.GetSupplierHoliday, toBytes(p)) - if err != nil { - return nil, err - } - - var r struct { - Data *model.ResponseSupplierHoliday `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 -} diff --git a/model/supplier_request.go b/model/supplier_request.go index 18034af..63b5459 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -52,3 +52,8 @@ type SupplierCountReq struct { IDs []string `json:"ids"` Status string `json:"status"` // active,inactive } + +// CheckTokenSupplierPayload ... +type CheckTokenSupplierPayload struct { + Token string `json:"token"` +} diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 550e870..b6cecb1 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -113,30 +113,3 @@ type WarehouseORUpdateDeliveryStatus struct { OrderID string `json:"orderId"` DeliveryStatus string `json:"deliveryStatus"` } - -// SupplierHolidayCreatePayload ... -type SupplierHolidayCreatePayload struct { - Supplier string `json:"supplier"` - Title string `json:"title"` - From string `json:"from"` - To string `json:"to"` - Warehouses []string `json:"warehouses"` - IsApplyAll bool `json:"isApplyAll"` - Source string `json:"source"` -} - -// SupplierHolidayUpdatePayload ... -type SupplierHolidayUpdatePayload struct { - Supplier string `json:"supplier"` - Title string `json:"title"` - From string `json:"from"` - To string `json:"to"` - Warehouses []string `json:"warehouses"` - IsApplyAll bool `json:"isApplyAll"` - Source string `json:"source"` -} - -// GetSupplierHolidayRequest ... -type GetSupplierHolidayRequest struct { - Conditions interface{} `json:"conditions"` -} diff --git a/model/warehouse_response.go b/model/warehouse_response.go index e5d556b..6359ae3 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -172,20 +172,3 @@ type GetWarehousesResponse struct { Limit int64 `json:"limit"` List []WarehouseInfo `json:"list"` } - -// ResponseWarehouseShort ... -type ResponseWarehouseShort struct { - ID string `json:"_id"` - Name string `json:"name"` -} - -// ResponseSupplierHoliday ... -type ResponseSupplierHoliday struct { - Title string `json:"title"` - From string `json:"from"` - To string `json:"to"` - Status string `json:"status"` - Reason string `json:"reason"` - IsApplyAll bool `json:"isApplyAll"` - Warehouses []ResponseWarehouseShort `json:"warehouses"` -} diff --git a/subject/supplier.go b/subject/supplier.go index edc797f..fe041bf 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -12,10 +12,12 @@ var Supplier = struct { FindAll string FindAllOld string Count string + CheckTokenSupplier string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), FindAllOld: getSupplierValue("find_all_old"), Count: getSupplierValue("count"), + CheckTokenSupplier: getSupplierValue("check_token_supplier"), } diff --git a/subject/warehouse.go b/subject/warehouse.go index 51be4c7..bb184b5 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -26,9 +26,6 @@ var Warehouse = struct { UpdateIsClosedSupplier string GetWarehouses string UpdateORDeliveryStatus string - CreateSupplierHoliday string - UpdateSupplierHoliday string - GetSupplierHoliday string }{ CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), @@ -49,7 +46,4 @@ var Warehouse = struct { UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), GetWarehouses: getWarehouseValue("get_warehouses"), UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"), - CreateSupplierHoliday: getWarehouseValue("create_supplier_holiday"), - UpdateSupplierHoliday: getWarehouseValue("update_supplier_holiday"), - GetSupplierHoliday: getWarehouseValue("get_supplier_holiday"), } -- 2.34.1 From b5d7425114140cc612c11814b4b6bba2b98cc11a Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Fri, 23 Dec 2022 15:13:35 +0700 Subject: [PATCH 05/13] add field permission checkTokenSupplier --- model/supplier_request.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/model/supplier_request.go b/model/supplier_request.go index 63b5459..7ba0018 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -55,5 +55,6 @@ type SupplierCountReq struct { // CheckTokenSupplierPayload ... type CheckTokenSupplierPayload struct { - Token string `json:"token"` + Token string `json:"token"` + Permissions []string `json:"permissions"` } -- 2.34.1 From 54f5c45488413b1df64ba153edcd3f178d58057a Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Sat, 24 Dec 2022 13:50:58 +0700 Subject: [PATCH 06/13] edit response checkTokenSupplier --- client/supplier.go | 6 +++--- model/supplier_response.go | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client/supplier.go b/client/supplier.go index b10f982..56e0670 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -180,15 +180,15 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh } // CheckTokenSupplier ... -func (s Supplier) CheckTokenSupplier(p model.CheckTokenSupplierPayload) (*model.ResponseSupplierInfo, error) { +func (s Supplier) CheckTokenSupplier(p model.CheckTokenSupplierPayload) (*model.ResponseCheckTokenSupplier, error) { msg, err := natsio.GetServer().Request(subject.Supplier.CheckTokenSupplier, toBytes(p)) if err != nil { return nil, err } var r struct { - Error string `json:"error"` - Data *model.ResponseSupplierInfo `json:"data"` + Error string `json:"error"` + Data *model.ResponseCheckTokenSupplier `json:"data"` } if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err diff --git a/model/supplier_response.go b/model/supplier_response.go index 2b9dd10..21dce15 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -33,3 +33,10 @@ type SupplierAll struct { type SupplierCountRes struct { Total int64 `json:"total"` } + +// ResponseCheckTokenSupplier ... +type ResponseCheckTokenSupplier struct { + Invalid bool `json:"invalid"` + Reason string `json:"reason"` + Supplier ResponseSupplierInfo `json:"supplier"` +} -- 2.34.1 From 71be64db27fe0387b78d6b41fec14edeecb855c0 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Tue, 27 Dec 2022 16:16:08 +0700 Subject: [PATCH 07/13] edit requestPayload check token supplier --- model/supplier_request.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/supplier_request.go b/model/supplier_request.go index 7ba0018..88027f2 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -55,6 +55,6 @@ type SupplierCountReq struct { // CheckTokenSupplierPayload ... type CheckTokenSupplierPayload struct { - Token string `json:"token"` - Permissions []string `json:"permissions"` + Token string `json:"token"` + Permissions string `json:"permissions"` } -- 2.34.1 From 7f548f0931ee8804a2402bc024bc5cdd875c6741 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Tue, 27 Dec 2022 16:37:48 +0700 Subject: [PATCH 08/13] fix --- model/supplier_request.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/supplier_request.go b/model/supplier_request.go index 88027f2..7ba0018 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -55,6 +55,6 @@ type SupplierCountReq struct { // CheckTokenSupplierPayload ... type CheckTokenSupplierPayload struct { - Token string `json:"token"` - Permissions string `json:"permissions"` + Token string `json:"token"` + Permissions []string `json:"permissions"` } -- 2.34.1 From ec9dedad0d743f5e8bf689e881b480a6606d4bfa Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Tue, 27 Dec 2022 23:49:25 +0700 Subject: [PATCH 09/13] change res check-token-supllier --- model/supplier_response.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/supplier_response.go b/model/supplier_response.go index 21dce15..2c90904 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -36,7 +36,7 @@ type SupplierCountRes struct { // ResponseCheckTokenSupplier ... type ResponseCheckTokenSupplier struct { - Invalid bool `json:"invalid"` + IsValid bool `json:"isValid"` Reason string `json:"reason"` Supplier ResponseSupplierInfo `json:"supplier"` } -- 2.34.1 From 4fd0a89acd4eefb0e69d571824c28b59ff3e6877 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Thu, 29 Dec 2022 13:49:04 +0700 Subject: [PATCH 10/13] edit check token supplier user --- client/supplier.go | 20 -------------------- client/supplier_user.go | 20 ++++++++++++++++++++ model/supplier_request.go | 6 ------ model/supplier_response.go | 7 ------- model/supplier_user_request.go | 6 ++++++ model/supplier_user_response.go | 13 +++++++++++++ subject/supplier.go | 2 -- subject/supplier_user.go | 2 ++ 8 files changed, 41 insertions(+), 35 deletions(-) diff --git a/client/supplier.go b/client/supplier.go index 56e0670..9b53826 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -178,23 +178,3 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh } return nil } - -// CheckTokenSupplier ... -func (s Supplier) CheckTokenSupplier(p model.CheckTokenSupplierPayload) (*model.ResponseCheckTokenSupplier, error) { - msg, err := natsio.GetServer().Request(subject.Supplier.CheckTokenSupplier, toBytes(p)) - if err != nil { - return nil, err - } - - var r struct { - Error string `json:"error"` - Data *model.ResponseCheckTokenSupplier `json:"data"` - } - 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 -} diff --git a/client/supplier_user.go b/client/supplier_user.go index fb6a2db..535f973 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -138,3 +138,23 @@ func (s SupplierUser) ResetPassword(p model.ResetPasswordRequest) (*model.ResetP return r.Data, nil } + +// CheckTokenSupplier ... +func (s SupplierUser) CheckTokenSupplier(p model.CheckTokenSupplierUserPayload) (*model.ResponseCheckTokenSupplierUser, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.CheckToken, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Error string `json:"error"` + Data *model.ResponseCheckTokenSupplierUser `json:"data"` + } + 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 +} diff --git a/model/supplier_request.go b/model/supplier_request.go index 7ba0018..18034af 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -52,9 +52,3 @@ type SupplierCountReq struct { IDs []string `json:"ids"` Status string `json:"status"` // active,inactive } - -// CheckTokenSupplierPayload ... -type CheckTokenSupplierPayload struct { - Token string `json:"token"` - Permissions []string `json:"permissions"` -} diff --git a/model/supplier_response.go b/model/supplier_response.go index 2c90904..2b9dd10 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -33,10 +33,3 @@ type SupplierAll struct { type SupplierCountRes struct { Total int64 `json:"total"` } - -// ResponseCheckTokenSupplier ... -type ResponseCheckTokenSupplier struct { - IsValid bool `json:"isValid"` - Reason string `json:"reason"` - Supplier ResponseSupplierInfo `json:"supplier"` -} diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 66ccb17..2e1c066 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -49,3 +49,9 @@ type ResetPasswordRequest struct { ID string `json:"_id"` Password string `json:"password"` } + +// CheckTokenSupplierUserPayload ... +type CheckTokenSupplierUserPayload struct { + Token string `json:"token"` + Permissions []string `json:"permissions"` +} diff --git a/model/supplier_user_response.go b/model/supplier_user_response.go index 38a1d0c..3b98d1c 100644 --- a/model/supplier_user_response.go +++ b/model/supplier_user_response.go @@ -11,3 +11,16 @@ type CreateStaffResponse struct { type ResetPasswordResponse struct { Password string `json:"password"` } + +// ResponseCheckTokenSupplierUser ... +type ResponseCheckTokenSupplierUser struct { + IsValid bool `json:"isValid"` + Reason string `json:"reason"` + User ResponseSupplierUserInfo `json:"supplier"` +} + +type ResponseSupplierUserInfo struct { + ID string `json:"_id"` + Name string `json:"name"` + SupplierID string `json:"supplierId"` +} diff --git a/subject/supplier.go b/subject/supplier.go index fe041bf..edc797f 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -12,12 +12,10 @@ var Supplier = struct { FindAll string FindAllOld string Count string - CheckTokenSupplier string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), FindAllOld: getSupplierValue("find_all_old"), Count: getSupplierValue("count"), - CheckTokenSupplier: getSupplierValue("check_token_supplier"), } diff --git a/subject/supplier_user.go b/subject/supplier_user.go index adc2f1f..f954898 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -14,6 +14,7 @@ var SupplierUser = struct { UpdateStaff string UpdateStatus string ResetPassword string + CheckToken string }{ // Users CreateOwner: getSupplierUserValue("create_owner"), @@ -22,4 +23,5 @@ var SupplierUser = struct { UpdateStaff: getSupplierUserValue("update_staff"), UpdateStatus: getSupplierUserValue("update_status"), ResetPassword: getSupplierUserValue("reset_password"), + CheckToken: getSupplierUserValue("check_token"), } -- 2.34.1 From 64c7fca2cc345550887108e1c2989eaf967ebf73 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Thu, 29 Dec 2022 13:58:16 +0700 Subject: [PATCH 11/13] rename subj --- client/supplier_user.go | 2 +- subject/supplier_user.go | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/client/supplier_user.go b/client/supplier_user.go index 535f973..18ca0db 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -141,7 +141,7 @@ func (s SupplierUser) ResetPassword(p model.ResetPasswordRequest) (*model.ResetP // CheckTokenSupplier ... func (s SupplierUser) CheckTokenSupplier(p model.CheckTokenSupplierUserPayload) (*model.ResponseCheckTokenSupplierUser, error) { - msg, err := natsio.GetServer().Request(subject.SupplierUser.CheckToken, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.SupplierUser.CheckTokenSupplierUser, toBytes(p)) if err != nil { return nil, err } diff --git a/subject/supplier_user.go b/subject/supplier_user.go index f954898..5c99eb4 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -8,20 +8,20 @@ func getSupplierUserValue(val string) string { var SupplierUser = struct { // Users - CreateOwner string - UpdateOwner string - CreateStaff string - UpdateStaff string - UpdateStatus string - ResetPassword string - CheckToken string + CreateOwner string + UpdateOwner string + CreateStaff string + UpdateStaff string + UpdateStatus string + ResetPassword string + CheckTokenSupplierUser string }{ // Users - CreateOwner: getSupplierUserValue("create_owner"), - UpdateOwner: getSupplierUserValue("update_owner"), - CreateStaff: getSupplierUserValue("create_staff"), - UpdateStaff: getSupplierUserValue("update_staff"), - UpdateStatus: getSupplierUserValue("update_status"), - ResetPassword: getSupplierUserValue("reset_password"), - CheckToken: getSupplierUserValue("check_token"), + CreateOwner: getSupplierUserValue("create_owner"), + UpdateOwner: getSupplierUserValue("update_owner"), + CreateStaff: getSupplierUserValue("create_staff"), + UpdateStaff: getSupplierUserValue("update_staff"), + UpdateStatus: getSupplierUserValue("update_status"), + ResetPassword: getSupplierUserValue("reset_password"), + CheckTokenSupplierUser: getSupplierUserValue("check_token_supplier_user"), } -- 2.34.1 From 9b758ee7856a12748789322cf7379eff3985399f Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Thu, 29 Dec 2022 14:10:44 +0700 Subject: [PATCH 12/13] fix --- client/supplier_user.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/supplier_user.go b/client/supplier_user.go index 18ca0db..7da7f6a 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -139,8 +139,8 @@ func (s SupplierUser) ResetPassword(p model.ResetPasswordRequest) (*model.ResetP return r.Data, nil } -// CheckTokenSupplier ... -func (s SupplierUser) CheckTokenSupplier(p model.CheckTokenSupplierUserPayload) (*model.ResponseCheckTokenSupplierUser, error) { +// CheckTokenSupplierUser ... +func (s SupplierUser) CheckTokenSupplierUser(p model.CheckTokenSupplierUserPayload) (*model.ResponseCheckTokenSupplierUser, error) { msg, err := natsio.GetServer().Request(subject.SupplierUser.CheckTokenSupplierUser, toBytes(p)) if err != nil { return nil, err -- 2.34.1 From 39614ca4c544430d6ba3930ee041ed662785ceb5 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Tue, 10 Jan 2023 11:27:36 +0700 Subject: [PATCH 13/13] add get-detail-supplier-info --- client/supplier.go | 22 ++++++++++++++++++++++ model/supplier_request.go | 5 +++++ subject/supplier.go | 2 ++ 3 files changed, 29 insertions(+) diff --git a/client/supplier.go b/client/supplier.go index 9b53826..149aad6 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -38,6 +38,28 @@ func (s Supplier) GetListSupplierInfo(p model.GetSupplierRequest) ([]*model.Resp return r.Data, nil } +// GetDetailSupplierInfo ... +func (s Supplier) GetDetailSupplierInfo(p model.GetDetailSupplierRequest) (*model.ResponseSupplierInfo, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.GetDetailSupplierInfo, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseSupplierInfo `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 Supplier) GetSupplierContractBySupplierID(p model.GetSupplierContractRequest) (*model.ResponseSupplierContract, error) { msg, err := natsio.GetServer().Request(subject.Supplier.GetSupplierContractBySupplierID, toBytes(p)) if err != nil { diff --git a/model/supplier_request.go b/model/supplier_request.go index 18034af..5d6fbe2 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -9,6 +9,11 @@ type GetSupplierRequest struct { ListID []primitive.ObjectID `json:"listID"` } +// GetDetailSupplierRequest ... +type GetDetailSupplierRequest struct { + Supplier string `json:"supplier"` +} + type GetSupplierContractRequest struct { SupplierID primitive.ObjectID `json:"supplierID"` } diff --git a/subject/supplier.go b/subject/supplier.go index edc797f..4fc3d32 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -8,12 +8,14 @@ func getSupplierValue(val string) string { var Supplier = struct { GetListSupplierInfo string + GetDetailSupplierInfo string GetSupplierContractBySupplierID string FindAll string FindAllOld string Count string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), + GetDetailSupplierInfo: getSupplierValue("get_detail_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), FindAllOld: getSupplierValue("find_all_old"), -- 2.34.1