From b32ceefab18129fdd9a1d2097d78cc52a1eea14a Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 14 Sep 2022 14:09:48 +0700 Subject: [PATCH 01/11] 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", } From e1a18df726b4898ca9d3d175974da335dd5d5f00 Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 14 Sep 2022 14:14:27 +0700 Subject: [PATCH 02/11] 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 From 0e35b6aec3e79aa43afb81a870753669021bc68a Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 14 Sep 2022 14:25:16 +0700 Subject: [PATCH 03/11] 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"` } From ee32f2d8bb6aa8c0b8e2e6002a1e7c1c10c98e9e Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 14 Sep 2022 17:23:01 +0700 Subject: [PATCH 04/11] 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"), } From 42a6d04413dba52ae893ec51c97217cd080b9b22 Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 14 Sep 2022 17:33:18 +0700 Subject: [PATCH 05/11] 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 -} From f731be7b62fd0cc37eaa097f33cae69fc3ae69b8 Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Wed, 14 Sep 2022 18:04:18 +0700 Subject: [PATCH 06/11] 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"` -} From fffcc281ccc4bbc3758aeae64f29a664f39f167b Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Wed, 14 Sep 2022 23:30:22 +0700 Subject: [PATCH 07/11] 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"), } From 0a82f40a252b79f9dfaa3d24d73b76973a1aa2b5 Mon Sep 17 00:00:00 2001 From: namhq Date: Mon, 10 Oct 2022 04:05:49 +0000 Subject: [PATCH 08/11] Update 'go.mod' --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index ac44201..bd87680 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/Selly-Modules/natsio +module git.selly.red/Selly-Modules/natsio go 1.16 From c11419a3ad3353b5c32da1d47c29ae3f8a0a5e45 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Mon, 10 Oct 2022 11:11:39 +0700 Subject: [PATCH 09/11] [Update] Package --- client/communication.go | 6 +++--- client/location.go | 6 +++--- client/news.go | 6 +++--- client/order.go | 6 +++--- client/seller.go | 6 +++--- client/supplier.go | 6 +++--- client/warehouse.go | 6 +++--- client/warehouse_dao.go | 6 +++--- go.sum | 13 +++++++++++-- 9 files changed, 35 insertions(+), 26 deletions(-) diff --git a/client/communication.go b/client/communication.go index 6dd94cb..1d8254d 100644 --- a/client/communication.go +++ b/client/communication.go @@ -3,9 +3,9 @@ package client import ( "encoding/json" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // Communication ... diff --git a/client/location.go b/client/location.go index 2e8d30e..18be423 100644 --- a/client/location.go +++ b/client/location.go @@ -4,9 +4,9 @@ import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // Location ... diff --git a/client/news.go b/client/news.go index 6bacf54..d33787a 100644 --- a/client/news.go +++ b/client/news.go @@ -3,9 +3,9 @@ package client import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // News ... diff --git a/client/order.go b/client/order.go index 7d23cee..2e7f0a3 100644 --- a/client/order.go +++ b/client/order.go @@ -4,9 +4,9 @@ import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // Order ... diff --git a/client/seller.go b/client/seller.go index 1d06208..30987bd 100644 --- a/client/seller.go +++ b/client/seller.go @@ -4,9 +4,9 @@ import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // Seller ... diff --git a/client/supplier.go b/client/supplier.go index 700d714..8de78fb 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -4,9 +4,9 @@ import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // Supplier ... diff --git a/client/warehouse.go b/client/warehouse.go index 5ae07db..944c2cb 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -4,9 +4,9 @@ import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // Warehouse ... diff --git a/client/warehouse_dao.go b/client/warehouse_dao.go index 69c2245..56c046f 100644 --- a/client/warehouse_dao.go +++ b/client/warehouse_dao.go @@ -3,9 +3,9 @@ package client import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // DistinctWithField ... diff --git a/go.sum b/go.sum index f3e58d6..85b108e 100644 --- a/go.sum +++ b/go.sum @@ -11,6 +11,7 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -24,10 +25,9 @@ github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47e github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= -github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/minio/highwayhash v1.0.1 h1:dZ6IIu8Z14VlC0VpfKofAhCy74wu/Qb5gcn52yWoz/0= github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/nats-io/jwt v1.2.2 h1:w3GMTO969dFg+UOKTmmyuu7IGdusK+7Ytlt//OYH/uU= github.com/nats-io/jwt v1.2.2/go.mod h1:/xX356yQA6LuXI9xWW7mZNpxgF2mBmGecH+Fj34sP5Q= @@ -43,6 +43,7 @@ github.com/nats-io/nkeys v0.3.0 h1:cgM5tL53EvYRU+2YLXIK0G2mJtK12Ft9oeooSZMA2G8= github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -52,10 +53,15 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M= github.com/thoas/go-funk v0.9.1/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= +github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= +github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs= github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= go.mongodb.org/mongo-driver v1.10.1 h1:NujsPveKwHaWuKUer/ceo9DzEe7HIj1SlJ6uvXZG0S4= go.mongodb.org/mongo-driver v1.10.1/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8= @@ -68,6 +74,7 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -80,10 +87,12 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 h1:NusfzzA6yGQ+ua51ck7E3omNUX/JuqbFSaRGqU8CcLI= golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= From 1c10210bb96d4e1b2c4688ef55c5e74c8bcd0fe9 Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 11 Oct 2022 14:13:15 +0700 Subject: [PATCH 10/11] rebuild --- client/bank.go | 55 ++++++++++++++++++++++++++++++++++++ client/bank_branch.go | 39 +++++++++++++++++++++++++ model/bank_branch_reponse.go | 11 ++++++++ model/bank_branch_request.go | 6 ++++ model/bank_response.go | 21 ++++++++++++++ subject/bank.go | 17 +++++++++++ 6 files changed, 149 insertions(+) create mode 100644 client/bank.go create mode 100644 client/bank_branch.go create mode 100644 model/bank_branch_reponse.go create mode 100644 model/bank_branch_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..3391911 --- /dev/null +++ b/client/bank.go @@ -0,0 +1,55 @@ +package client + +import ( + "encoding/json" + "errors" + + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" +) + +// Bank ... +type Bank struct{} + +// GetBank ... +func GetBank() Bank { + return Bank{} +} + +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 + } + + 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 +} + +func (s Bank) CheckBankAndBranchByID(p model.BankBranchRequest) bool { + msg, err := natsio.GetServer().Request(subject.Bank.CheckBankAndBranchByID, toBytes(p)) + if err != nil { + return false + } + + var r struct { + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return false + } + return r.Error == "" +} diff --git a/client/bank_branch.go b/client/bank_branch.go new file mode 100644 index 0000000..5890e75 --- /dev/null +++ b/client/bank_branch.go @@ -0,0 +1,39 @@ +package client + +import ( + "encoding/json" + "errors" + + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" +) + +// BankBranch ... +type BankBranch struct{} + +// GetBankBranch ... +func GetBankBranch() BankBranch { + return BankBranch{} +} + +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 + } + + 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/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_branch_request.go b/model/bank_branch_request.go new file mode 100644 index 0000000..6de1216 --- /dev/null +++ b/model/bank_branch_request.go @@ -0,0 +1,6 @@ +package model + +type BankBranchRequest struct { + BankID string `json:"bankId"` + BranchID string `json:"branchId"` +} diff --git a/model/bank_response.go b/model/bank_response.go new file mode 100644 index 0000000..74fc10e --- /dev/null +++ b/model/bank_response.go @@ -0,0 +1,21 @@ +package model + +// MultiLang ... +type MultiLang struct { + En string `json:"en"` + Vi string `json:"vi"` +} + +// BankBrief ... +type BankBrief struct { + ID string `json:"_id"` + Name MultiLang `json:"name"` + ShortName string `json:"shortName"` + Active bool `json:"active"` + 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"` +} diff --git a/subject/bank.go b/subject/bank.go new file mode 100644 index 0000000..9f7f8bb --- /dev/null +++ b/subject/bank.go @@ -0,0 +1,17 @@ +package subject + +import "fmt" + +func getBankValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Bank, val) +} + +var Bank = struct { + GetBankById string + GetBankBranchById string + CheckBankAndBranchByID string +}{ + GetBankById: getBankValue("get_bank_by_id"), + GetBankBranchById: getBankValue("get_bank_branch_by_id"), + CheckBankAndBranchByID: getBankValue("check_bank_and_brach_by_id"), +} From cb7f37dea9a235edf09374a455e427493962b628 Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 11 Oct 2022 14:17:07 +0700 Subject: [PATCH 11/11] rebuild --- subject/config.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subject/config.go b/subject/config.go index 7a69414..4a2f9f3 100644 --- a/subject/config.go +++ b/subject/config.go @@ -6,6 +6,7 @@ var prefixes = struct { News string Warehouse string Location string + Bank string Supplier string Seller string }{ @@ -15,5 +16,6 @@ var prefixes = struct { Warehouse: "warehouse", Location: "location", Supplier: "supplier", + Bank: "bank", Seller: "seller", }