From cc48a083f2f9f4c1b063c74ae755a940b7865cba Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Tue, 13 Sep 2022 11:47:46 +0700 Subject: [PATCH 01/16] [Update] Response warehouse --- model/warehouse_response.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/model/warehouse_response.go b/model/warehouse_response.go index 2429743..f2d60a9 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -25,6 +25,20 @@ type WarehouseConfiguration struct { Partner WarehousePartner `json:"partner"` Delivery WarehouseDelivery `json:"delivery"` Other WarehouseOther `json:"other"` + Food WarehouseFood `json:"food"` +} + +// WarehouseFood ... +type WarehouseFood struct { + ForceClosed bool `json:"forceClosed"` + IsClosed bool `json:"isClosed"` + TimeRange []TimeRange `json:"timeRange"` +} + +// TimeRange ... +type TimeRange struct { + From int64 `json:"from"` + To int64 `json:"to"` } // WarehouseOther ... @@ -109,6 +123,7 @@ type ResponseLatLng struct { type WarehouseNatsResponse struct { ID string `json:"_id"` Staff string `json:"staff"` + BusinessType string `json:"businessType"` Name string `json:"name"` SearchString string `json:"searchString"` Slug string `json:"slug"` -- 2.34.1 From b32ceefab18129fdd9a1d2097d78cc52a1eea14a Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 14 Sep 2022 14:09:48 +0700 Subject: [PATCH 02/16] add bank info --- client/bank.go | 39 +++++++++++++++++++++++++++++++++++++++ client/supplier.go | 21 +++++++++++++++++++++ model/bank_request.go | 6 ++++++ model/bank_response.go | 6 ++++++ subject/bank.go | 13 +++++++++++++ subject/config.go | 2 ++ 6 files changed, 87 insertions(+) create mode 100644 client/bank.go create mode 100644 model/bank_request.go create mode 100644 model/bank_response.go create mode 100644 subject/bank.go diff --git a/client/bank.go b/client/bank.go new file mode 100644 index 0000000..f083e8f --- /dev/null +++ b/client/bank.go @@ -0,0 +1,39 @@ +package client + +import ( + "encoding/json" + "errors" + + "github.com/Selly-Modules/natsio" + "github.com/Selly-Modules/natsio/model" + "github.com/Selly-Modules/natsio/subject" +) + +// Bank ... +type Bank struct{} + +// GetBank ... +func GetBank() Bank { + return Bank{} +} + +func (s Bank) GetBankInfoByID(bankID model.BankRequestPayload) (*model.BankBrief, error) { + msg, err := natsio.GetServer().Request(subject.Bank.GetBankById, toBytes(bankID)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.BankBrief `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/client/supplier.go b/client/supplier.go index 700d714..02d2875 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -79,3 +79,24 @@ func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.Suppl return r.Data, nil } + +func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*model.SupplierAll, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.SupplierAll `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/bank_request.go b/model/bank_request.go new file mode 100644 index 0000000..2093aca --- /dev/null +++ b/model/bank_request.go @@ -0,0 +1,6 @@ +package model + +// BankRequestPayload ... +type BankRequestPayload struct { + ID string `json:"_id"` +} diff --git a/model/bank_response.go b/model/bank_response.go new file mode 100644 index 0000000..917b81c --- /dev/null +++ b/model/bank_response.go @@ -0,0 +1,6 @@ +package model + +// BankBrief ... +type BankBrief struct { + ID string `json:"_id"` +} diff --git a/subject/bank.go b/subject/bank.go new file mode 100644 index 0000000..71bbdbe --- /dev/null +++ b/subject/bank.go @@ -0,0 +1,13 @@ +package subject + +import "fmt" + +func getBankValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Bank, val) +} + +var Bank = struct { + GetBankById string +}{ + GetBankById: getBankValue("get_bank_by_id"), +} diff --git a/subject/config.go b/subject/config.go index dfeea56..47b62a1 100644 --- a/subject/config.go +++ b/subject/config.go @@ -5,6 +5,7 @@ var prefixes = struct { Order string Warehouse string Location string + Bank string Supplier string }{ Communication: "communication", @@ -12,4 +13,5 @@ var prefixes = struct { Warehouse: "warehouse", Location: "location", Supplier: "supplier", + Bank: "bank", } -- 2.34.1 From e1a18df726b4898ca9d3d175974da335dd5d5f00 Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 14 Sep 2022 14:14:27 +0700 Subject: [PATCH 03/16] bank info --- client/bank.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/bank.go b/client/bank.go index f083e8f..0a5b7a3 100644 --- a/client/bank.go +++ b/client/bank.go @@ -17,7 +17,7 @@ func GetBank() Bank { return Bank{} } -func (s Bank) GetBankInfoByID(bankID model.BankRequestPayload) (*model.BankBrief, error) { +func (s Bank) GetBankById(bankID model.BankRequestPayload) (*model.BankBrief, error) { msg, err := natsio.GetServer().Request(subject.Bank.GetBankById, toBytes(bankID)) if err != nil { return nil, err -- 2.34.1 From 0e35b6aec3e79aa43afb81a870753669021bc68a Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 14 Sep 2022 14:25:16 +0700 Subject: [PATCH 04/16] bank info --- model/bank_response.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/model/bank_response.go b/model/bank_response.go index 917b81c..c27d7fd 100644 --- a/model/bank_response.go +++ b/model/bank_response.go @@ -1,6 +1,23 @@ package model +// MultiLang ... +type MultiLang struct { + En string `json:"en"` + Vi string `json:"vi"` +} + // BankBrief ... type BankBrief struct { - ID string `json:"_id"` + ID string `json:"_id"` + Name MultiLang `json:"name"` + ShortName string `json:"shortName"` + Active bool `json:"active"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` + BenBankName string `json:"benBankName"` + BankCode int `json:"bankCode"` + IsBranchRequired bool `json:"isBranchRequired"` + SearchString string `json:"searchString"` + BeneficiaryForVietinbank string `json:"beneficiaryForVietinbank"` + CreatedBy string `json:"createdBy,omitempty"` } -- 2.34.1 From 9f1f2faf9e1066b7fcf9fd76eb667e352493a5a5 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Wed, 14 Sep 2022 14:39:16 +0700 Subject: [PATCH 05/16] [Update] Response supplier --- model/supplier_response.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/model/supplier_response.go b/model/supplier_response.go index a87a29e..975a8de 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -2,8 +2,9 @@ package model // ResponseSupplierInfo ... type ResponseSupplierInfo struct { - ID string `json:"id"` - Name string `json:"name"` + ID string `json:"id"` + Name string `json:"name"` + BusinessType string `json:"businessType"` } // ResponseSupplierContract ... @@ -16,11 +17,12 @@ type ResponseSupplierContract struct { // SupplierBrief ... type SupplierBrief struct { - ID string `json:"_id"` - Name string `json:"name"` - Status string `json:"status"` - CreatedAt string `json:"createdAt"` - UpdatedAt string `json:"updatedAt"` + ID string `json:"_id"` + Name string `json:"name"` + Status string `json:"status"` + BusinessType string `json:"businessType"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` } type SupplierAll struct { -- 2.34.1 From ee32f2d8bb6aa8c0b8e2e6002a1e7c1c10c98e9e Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 14 Sep 2022 17:23:01 +0700 Subject: [PATCH 06/16] bank info --- client/bank.go | 2 +- client/bank_branch.go | 39 ++++++++++++++++++++++++++ client/warehouse.go | 18 ++++++++++++ model/bank_branch_reponse.go | 11 ++++++++ model/bank_request.go | 6 ---- model/bank_response.go | 2 -- model/warehouse_response.go | 8 ++++++ subject/bank.go | 5 ++-- subject/warehouse.go | 54 +++++++++++++++++++----------------- 9 files changed, 108 insertions(+), 37 deletions(-) create mode 100644 client/bank_branch.go create mode 100644 model/bank_branch_reponse.go delete mode 100644 model/bank_request.go diff --git a/client/bank.go b/client/bank.go index 0a5b7a3..5650b2f 100644 --- a/client/bank.go +++ b/client/bank.go @@ -17,7 +17,7 @@ func GetBank() Bank { return Bank{} } -func (s Bank) GetBankById(bankID model.BankRequestPayload) (*model.BankBrief, error) { +func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) { msg, err := natsio.GetServer().Request(subject.Bank.GetBankById, toBytes(bankID)) if err != nil { return nil, err diff --git a/client/bank_branch.go b/client/bank_branch.go new file mode 100644 index 0000000..75ccb9f --- /dev/null +++ b/client/bank_branch.go @@ -0,0 +1,39 @@ +package client + +import ( + "encoding/json" + "errors" + + "github.com/Selly-Modules/natsio" + "github.com/Selly-Modules/natsio/model" + "github.com/Selly-Modules/natsio/subject" +) + +// BankBranch ... +type BankBranch struct{} + +// GetBankBranch ... +func GetBankBranch() Bank { + return Bank{} +} + +func (s Bank) GetBankBranchById(bankBranchID string) (*model.BankBranchBrief, error) { + msg, err := natsio.GetServer().Request(subject.Bank.GetBankBranchById, toBytes(bankBranchID)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.BankBranchBrief `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/client/warehouse.go b/client/warehouse.go index 6c04925..0b85b6d 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -126,3 +126,21 @@ func (w Warehouse) GetConfigByWarehouseID(warehouseID string) (*model.WarehouseC } return r.Data, nil } + +// CreateWarehouseIntoServiceSupplier ... +func (w Warehouse) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehouseResponse) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, 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 +} diff --git a/model/bank_branch_reponse.go b/model/bank_branch_reponse.go new file mode 100644 index 0000000..1fa1432 --- /dev/null +++ b/model/bank_branch_reponse.go @@ -0,0 +1,11 @@ +package model + +// BankBranchBrief ... +type BankBranchBrief struct { + ID string `json:"_id"` + City string `json:"city"` + BankCode string `json:"bankCode"` + Bank string `json:"bank"` + Active bool `json:"active"` + Name string `json:"name"` +} diff --git a/model/bank_request.go b/model/bank_request.go deleted file mode 100644 index 2093aca..0000000 --- a/model/bank_request.go +++ /dev/null @@ -1,6 +0,0 @@ -package model - -// BankRequestPayload ... -type BankRequestPayload struct { - ID string `json:"_id"` -} diff --git a/model/bank_response.go b/model/bank_response.go index c27d7fd..74fc10e 100644 --- a/model/bank_response.go +++ b/model/bank_response.go @@ -12,8 +12,6 @@ type BankBrief struct { Name MultiLang `json:"name"` ShortName string `json:"shortName"` Active bool `json:"active"` - CreatedAt string `json:"createdAt"` - UpdatedAt string `json:"updatedAt"` BenBankName string `json:"benBankName"` BankCode int `json:"bankCode"` IsBranchRequired bool `json:"isBranchRequired"` diff --git a/model/warehouse_response.go b/model/warehouse_response.go index 2429743..e516950 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -120,3 +120,11 @@ type WarehouseNatsResponse struct { CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` } + +type CreateSupplierWarehouseResponse struct { + Supplier string `json:"supplier"` + Warehouse string `json:"warehouse"` + ProvinceCode int `json:"provinceCode"` + DistrictCode int `json:"districtCode"` + WardCode int `json:"wardCode"` +} diff --git a/subject/bank.go b/subject/bank.go index 71bbdbe..f6e8d67 100644 --- a/subject/bank.go +++ b/subject/bank.go @@ -7,7 +7,8 @@ func getBankValue(val string) string { } var Bank = struct { - GetBankById string + GetBankById string + GetBankBranchById string }{ - GetBankById: getBankValue("get_bank_by_id"), + GetBankBranchById: getBankValue("get_bank_by_id"), } diff --git a/subject/warehouse.go b/subject/warehouse.go index 5d0a81c..2824c33 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -7,31 +7,33 @@ func getWarehouseValue(val string) string { } var Warehouse = struct { - CreateOutboundRequest string - UpdateOutboundRequestLogistic string - CancelOutboundRequest string - GetConfiguration string - SyncORStatus string - WebhookTNC string - WebhookGlobalCare string - FindOne string - FindByCondition string - Distinct string - Count string - AfterUpdateWarehouse string - AfterCreateWarehouse string + CreateOutboundRequest string + UpdateOutboundRequestLogistic string + CancelOutboundRequest string + GetConfiguration string + SyncORStatus string + WebhookTNC string + WebhookGlobalCare string + FindOne string + FindByCondition string + Distinct string + Count string + AfterUpdateWarehouse string + AfterCreateWarehouse string + CreateWarehouseIntoServiceSupplier string }{ - AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), - AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), - CreateOutboundRequest: getWarehouseValue("create_outbound_request"), - UpdateOutboundRequestLogistic: getWarehouseValue("update_outbound_request_logistic_info"), - CancelOutboundRequest: getWarehouseValue("cancel_outbound_request"), - GetConfiguration: getWarehouseValue("get_configuration"), - SyncORStatus: getWarehouseValue("sync_or_status"), - WebhookTNC: getWarehouseValue("webhook_tnc"), - WebhookGlobalCare: getWarehouseValue("webhook_global_care"), - FindOne: getWarehouseValue("find_one"), - FindByCondition: getWarehouseValue("find_all_by_condition"), - Distinct: getWarehouseValue("distinct"), - Count: getWarehouseValue("count"), + AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), + AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), + CreateOutboundRequest: getWarehouseValue("create_outbound_request"), + UpdateOutboundRequestLogistic: getWarehouseValue("update_outbound_request_logistic_info"), + CancelOutboundRequest: getWarehouseValue("cancel_outbound_request"), + GetConfiguration: getWarehouseValue("get_configuration"), + SyncORStatus: getWarehouseValue("sync_or_status"), + WebhookTNC: getWarehouseValue("webhook_tnc"), + WebhookGlobalCare: getWarehouseValue("webhook_global_care"), + FindOne: getWarehouseValue("find_one"), + FindByCondition: getWarehouseValue("find_all_by_condition"), + Distinct: getWarehouseValue("distinct"), + Count: getWarehouseValue("count"), + CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), } -- 2.34.1 From 42a6d04413dba52ae893ec51c97217cd080b9b22 Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 14 Sep 2022 17:33:18 +0700 Subject: [PATCH 07/16] bank info --- client/supplier.go | 18 ++++++++++++++++++ client/warehouse.go | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/client/supplier.go b/client/supplier.go index 02d2875..8c5a193 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -100,3 +100,21 @@ func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*mod return r.Data, nil } + +// CreateWarehouseIntoServiceSupplier ... +func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehouseResponse) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, 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 +} diff --git a/client/warehouse.go b/client/warehouse.go index 0b85b6d..6c04925 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -126,21 +126,3 @@ func (w Warehouse) GetConfigByWarehouseID(warehouseID string) (*model.WarehouseC } return r.Data, nil } - -// CreateWarehouseIntoServiceSupplier ... -func (w Warehouse) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehouseResponse) error { - msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, 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 -} -- 2.34.1 From f731be7b62fd0cc37eaa097f33cae69fc3ae69b8 Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Wed, 14 Sep 2022 18:04:18 +0700 Subject: [PATCH 08/16] push --- model/supplier_request.go | 8 ++++++++ model/warehouse_response.go | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/model/supplier_request.go b/model/supplier_request.go index 04d15d5..0a5306a 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -22,3 +22,11 @@ type SupplierRequestPayload struct { PIC string ContractStatus string } + +type CreateSupplierWarehousePayload struct { + Supplier string `json:"supplier"` + Warehouse string `json:"warehouse"` + ProvinceCode int `json:"provinceCode"` + DistrictCode int `json:"districtCode"` + WardCode int `json:"wardCode"` +} diff --git a/model/warehouse_response.go b/model/warehouse_response.go index e516950..2429743 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -120,11 +120,3 @@ type WarehouseNatsResponse struct { CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` } - -type CreateSupplierWarehouseResponse struct { - Supplier string `json:"supplier"` - Warehouse string `json:"warehouse"` - ProvinceCode int `json:"provinceCode"` - DistrictCode int `json:"districtCode"` - WardCode int `json:"wardCode"` -} -- 2.34.1 From fffcc281ccc4bbc3758aeae64f29a664f39f167b Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Wed, 14 Sep 2022 23:30:22 +0700 Subject: [PATCH 09/16] push --- client/supplier.go | 20 +++++++++++++++++++- model/supplier_request.go | 8 ++++++++ subject/warehouse.go | 2 ++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/client/supplier.go b/client/supplier.go index 8c5a193..c41d843 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -102,7 +102,7 @@ func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*mod } // CreateWarehouseIntoServiceSupplier ... -func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehouseResponse) error { +func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) error { msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, toBytes(p)) if err != nil { return err @@ -118,3 +118,21 @@ func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWareh } return nil } + +// UpdateWarehouseIntoServiceSupplier ... +func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWarehousePayload) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateWarehouseIntoServiceSupplier, 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 +} diff --git a/model/supplier_request.go b/model/supplier_request.go index 0a5306a..5a19924 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -30,3 +30,11 @@ type CreateSupplierWarehousePayload struct { DistrictCode int `json:"districtCode"` WardCode int `json:"wardCode"` } + +type UpdateSupplierWarehousePayload struct { + Supplier string `json:"supplier"` + Warehouse string `json:"warehouse"` + ProvinceCode int `json:"provinceCode"` + DistrictCode int `json:"districtCode"` + WardCode int `json:"wardCode"` +} diff --git a/subject/warehouse.go b/subject/warehouse.go index 2824c33..0941b56 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -21,6 +21,7 @@ var Warehouse = struct { AfterUpdateWarehouse string AfterCreateWarehouse string CreateWarehouseIntoServiceSupplier string + UpdateWarehouseIntoServiceSupplier string }{ AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), @@ -36,4 +37,5 @@ var Warehouse = struct { Distinct: getWarehouseValue("distinct"), Count: getWarehouseValue("count"), CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), + UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), } -- 2.34.1 From 4546d0e89b596ac003a86dd0a9ea8315356638ac Mon Sep 17 00:00:00 2001 From: Tue Date: Thu, 15 Sep 2022 11:20:34 +0700 Subject: [PATCH 10/16] add bank branch info --- client/supplier.go | 21 --------------------- subject/bank.go | 3 ++- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/client/supplier.go b/client/supplier.go index c41d843..41a1849 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -80,27 +80,6 @@ func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.Suppl return r.Data, nil } -func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*model.SupplierAll, error) { - msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID)) - if err != nil { - return nil, err - } - - var r struct { - Data *model.SupplierAll `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 -} - // CreateWarehouseIntoServiceSupplier ... func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) error { msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, toBytes(p)) diff --git a/subject/bank.go b/subject/bank.go index f6e8d67..a991d5d 100644 --- a/subject/bank.go +++ b/subject/bank.go @@ -10,5 +10,6 @@ var Bank = struct { GetBankById string GetBankBranchById string }{ - GetBankBranchById: getBankValue("get_bank_by_id"), + GetBankById: getBankValue("get_bank_by_id"), + GetBankBranchById: getBankValue("get_bank_branch_by_id"), } -- 2.34.1 From fb8a8bd471bab82311c8356d2be2fab685d2afa1 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Fri, 16 Sep 2022 14:49:53 +0700 Subject: [PATCH 11/16] [Update] Add request updateIsClosedSupplier --- client/warehouse.go | 18 ++++++++++++++++++ model/warehouse_request.go | 11 +++++++++++ subject/warehouse.go | 2 ++ 3 files changed, 31 insertions(+) diff --git a/client/warehouse.go b/client/warehouse.go index 6c04925..43b3168 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -17,6 +17,24 @@ func GetWarehouse() Warehouse { return Warehouse{} } +// UpdateIsClosedSupplier ... +func (w Warehouse) UpdateIsClosedSupplier(p model.WarehouseNatsResponse) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateIsClosedSupplier, 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 +} + // AfterCreateWarehouse ... func (w Warehouse) AfterCreateWarehouse(p model.WarehouseNatsResponse) error { msg, err := natsio.GetServer().Request(subject.Warehouse.AfterCreateWarehouse, toBytes(p)) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 543fc68..b546725 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -69,3 +69,14 @@ type SyncORStatusRequest struct { ORCode string `json:"orCode"` OrderCode string `json:"orderCode"` } + +// UpdateSupplierIsClosedRequest ... +type UpdateSupplierIsClosedRequest struct { + Suppliers []SupplierIsClosed `json:"suppliers"` +} + +// SupplierIsClosed ... +type SupplierIsClosed struct { + Supplier string `json:"supplier"` + IsClosed bool `json:"isClosed"` +} diff --git a/subject/warehouse.go b/subject/warehouse.go index 5d0a81c..a0480ae 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -20,6 +20,7 @@ var Warehouse = struct { Count string AfterUpdateWarehouse string AfterCreateWarehouse string + UpdateIsClosedSupplier string }{ AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), @@ -34,4 +35,5 @@ var Warehouse = struct { FindByCondition: getWarehouseValue("find_all_by_condition"), Distinct: getWarehouseValue("distinct"), Count: getWarehouseValue("count"), + UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), } -- 2.34.1 From 92040d0b9f453256437f88a03956e31c0835b1cd Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Fri, 16 Sep 2022 15:36:32 +0700 Subject: [PATCH 12/16] [Update] Payload --- client/warehouse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/warehouse.go b/client/warehouse.go index 43b3168..fdb70b8 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -18,7 +18,7 @@ func GetWarehouse() Warehouse { } // UpdateIsClosedSupplier ... -func (w Warehouse) UpdateIsClosedSupplier(p model.WarehouseNatsResponse) error { +func (w Warehouse) UpdateIsClosedSupplier(p model.UpdateSupplierIsClosedRequest) error { msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateIsClosedSupplier, toBytes(p)) if err != nil { return err -- 2.34.1 From 44f0e4be441b4f30079d1b38e7518b38d7dc6ace Mon Sep 17 00:00:00 2001 From: Tue Date: Sat, 17 Sep 2022 10:55:37 +0700 Subject: [PATCH 13/16] bank info --- client/bank_branch.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/bank_branch.go b/client/bank_branch.go index 75ccb9f..51fd052 100644 --- a/client/bank_branch.go +++ b/client/bank_branch.go @@ -13,8 +13,8 @@ import ( type BankBranch struct{} // GetBankBranch ... -func GetBankBranch() Bank { - return Bank{} +func GetBankBranch() BankBranch { + return BankBranch{} } func (s Bank) GetBankBranchById(bankBranchID string) (*model.BankBranchBrief, error) { -- 2.34.1 From 22cd1eb18f1d9ef48652b4ba40b3945060291645 Mon Sep 17 00:00:00 2001 From: Tue Date: Sat, 17 Sep 2022 10:59:30 +0700 Subject: [PATCH 14/16] bank info --- client/bank_branch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/bank_branch.go b/client/bank_branch.go index 51fd052..0ca9460 100644 --- a/client/bank_branch.go +++ b/client/bank_branch.go @@ -17,7 +17,7 @@ func GetBankBranch() BankBranch { return BankBranch{} } -func (s Bank) GetBankBranchById(bankBranchID string) (*model.BankBranchBrief, error) { +func (s BankBranch) GetBankBranchById(bankBranchID string) (*model.BankBranchBrief, error) { msg, err := natsio.GetServer().Request(subject.Bank.GetBankBranchById, toBytes(bankBranchID)) if err != nil { return nil, err -- 2.34.1 From 48e585dc163b66da7b1a279b0974c1515687c4a3 Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 19 Sep 2022 11:10:23 +0700 Subject: [PATCH 15/16] update OR request model --- model/warehouse_request.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 543fc68..4e15ff7 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -29,9 +29,11 @@ type InsuranceOpts struct { // OutboundRequestItem ... type OutboundRequestItem struct { - SupplierSKU string `json:"supplierSKU"` - Quantity int64 `json:"quantity"` - UnitCode string `json:"unitCode"` + SupplierSKU string `json:"supplierSKU"` + Quantity int64 `json:"quantity"` + UnitCode string `json:"unitCode"` + Price float64 `json:"price"` + Name string `json:"name"` } // CustomerInfo ... -- 2.34.1 From 89967955ea2af42c918b213a4183f2d3a471db93 Mon Sep 17 00:00:00 2001 From: phuanbui Date: Mon, 19 Sep 2022 11:48:30 +0700 Subject: [PATCH 16/16] get list seller by ids --- client/seller.go | 25 +++++++++++++++++++++++++ model/seller_request.go | 5 +++++ model/seller_response.go | 5 +++++ subject/seller.go | 6 ++++-- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/client/seller.go b/client/seller.go index ec3ab83..5944bdb 100644 --- a/client/seller.go +++ b/client/seller.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "errors" + "github.com/Selly-Modules/natsio" "github.com/Selly-Modules/natsio/model" "github.com/Selly-Modules/natsio/subject" @@ -38,3 +39,27 @@ func (s Seller) GetSellerInfoByID(p model.GetSellerByIDRequest) (*model.Response return r.Data, nil } + +// GetListSellerInfoByIDs ... +func (s Seller) GetListSellerInfoByIDs(p model.GetListSellerByIDsRequest) (*model.ResponseListSellerInfo, error) { + msg, err := natsio.GetServer().Request(subject.Seller.GetListSellerInfoByIDs, toBytes(p)) + + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseListSellerInfo `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/seller_request.go b/model/seller_request.go index 997cd97..29732b9 100644 --- a/model/seller_request.go +++ b/model/seller_request.go @@ -6,3 +6,8 @@ import "go.mongodb.org/mongo-driver/bson/primitive" type GetSellerByIDRequest struct { SellerID primitive.ObjectID `json:"sellerId"` } + +// GetListSellerByIDsRequest ... +type GetListSellerByIDsRequest struct { + SellerIDs []primitive.ObjectID `json:"sellerIds"` +} diff --git a/model/seller_response.go b/model/seller_response.go index 6b7d698..5dd5271 100644 --- a/model/seller_response.go +++ b/model/seller_response.go @@ -6,3 +6,8 @@ type ResponseSellerInfo struct { Name string `json:"name"` Code string `json:"code"` } + +// ResponseListSellerInfo ... +type ResponseListSellerInfo struct { + Sellers []ResponseSellerInfo `json:"sellers"` +} diff --git a/subject/seller.go b/subject/seller.go index 033f993..ab3ac20 100644 --- a/subject/seller.go +++ b/subject/seller.go @@ -8,7 +8,9 @@ func getSellerValue(val string) string { // Seller ... var Seller = struct { - GetSellerInfoByID string + GetSellerInfoByID string + GetListSellerInfoByIDs string }{ - GetSellerInfoByID: getSellerValue("get_seller_info_by_id"), + GetSellerInfoByID: getSellerValue("get_seller_info_by_id"), + GetListSellerInfoByIDs: getSellerValue("get_list_seller_info_by_ids"), } -- 2.34.1