From b32ceefab18129fdd9a1d2097d78cc52a1eea14a Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 14 Sep 2022 14:09:48 +0700 Subject: [PATCH 01/26] 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 02/26] 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 03/26] 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 ee32f2d8bb6aa8c0b8e2e6002a1e7c1c10c98e9e Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 14 Sep 2022 17:23:01 +0700 Subject: [PATCH 04/26] 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 05/26] 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 06/26] 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 07/26] 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 08/26] 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 44f0e4be441b4f30079d1b38e7518b38d7dc6ace Mon Sep 17 00:00:00 2001 From: Tue Date: Sat, 17 Sep 2022 10:55:37 +0700 Subject: [PATCH 09/26] 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 10/26] 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 11/26] 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 b5ba7c7bf1866b83b1062cc7545a43a37fe0e691 Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 19 Sep 2022 14:18:51 +0700 Subject: [PATCH 12/26] update OR nats model --- model/warehouse_request.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 4e15ff7..7bf920f 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -58,6 +58,7 @@ type UpdateOutboundRequestLogisticInfoPayload struct { ShippingLabel string `json:"shippingLabel"` TrackingCode string `json:"trackingCode"` ORCode string `json:"orCode"` + TPLCode string `json:"tplCode"` } // CancelOutboundRequest ... -- 2.34.1 From 9e4e6868a495e446c59d3ac82d033fafb256d340 Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 19 Sep 2022 15:01:54 +0700 Subject: [PATCH 13/26] add warehouse subject --- subject/warehouse.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subject/warehouse.go b/subject/warehouse.go index 5d0a81c..b6be006 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -14,6 +14,7 @@ var Warehouse = struct { SyncORStatus string WebhookTNC string WebhookGlobalCare string + WebhookOnPoint string FindOne string FindByCondition string Distinct string @@ -30,6 +31,7 @@ var Warehouse = struct { SyncORStatus: getWarehouseValue("sync_or_status"), WebhookTNC: getWarehouseValue("webhook_tnc"), WebhookGlobalCare: getWarehouseValue("webhook_global_care"), + WebhookOnPoint: getWarehouseValue("webhook_on_point"), FindOne: getWarehouseValue("find_one"), FindByCondition: getWarehouseValue("find_all_by_condition"), Distinct: getWarehouseValue("distinct"), -- 2.34.1 From 3c5c95b103193e5866d396f116c035273c56c450 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Tue, 20 Sep 2022 10:56:45 +0700 Subject: [PATCH 14/26] [Update] --- client/news.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/news.go b/client/news.go index 162162d..4167c0a 100644 --- a/client/news.go +++ b/client/news.go @@ -8,8 +8,16 @@ import ( "github.com/Selly-Modules/natsio/subject" ) +// News ... +type News struct{} + +// GetNews ... +func GetNews() News { + return News{} +} + // GetProductNoticesByInventory ... -func (w Warehouse) GetProductNoticesByInventory(p model.GetProductNoticesByInventoryRequest) (*model.GetProductNoticesByInventoryResponse, error) { +func (n News) GetProductNoticesByInventory(p model.GetProductNoticesByInventoryRequest) (*model.GetProductNoticesByInventoryResponse, error) { msg, err := natsio.GetServer().Request(subject.News.GetProductNoticesByInventory, bsonToBytes(p)) if err != nil { return nil, err -- 2.34.1 From 73181bc5836149a8c1cc07f0ae7c4af08476b162 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 21 Sep 2022 17:40:49 +0700 Subject: [PATCH 15/26] add order func --- client/order.go | 21 +++++++++++++++++++++ model/order_request.go | 10 ++++++++++ model/order_response.go | 34 ++++++++++++++++++++++++++++++++++ subject/order.go | 2 ++ 4 files changed, 67 insertions(+) create mode 100644 model/order_response.go diff --git a/client/order.go b/client/order.go index 7d23cee..db325a1 100644 --- a/client/order.go +++ b/client/order.go @@ -98,3 +98,24 @@ func (o Order) ORNotUpdateStatus(p model.OrderORsNotUpdateStatus) error { } return nil } + +// GetSupplierOrders ... +func (o Order) GetSupplierOrders(p model.OrderSupplierQuery) (*model.SupplierOrderList, error) { + msg, err := natsio.GetServer().Request(subject.Order.GetSupplierOrders, toBytes(p)) + if err != nil { + return nil, err + } + var ( + r struct { + Data model.SupplierOrderList `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/order_request.go b/model/order_request.go index af4989d..ba920f4 100644 --- a/model/order_request.go +++ b/model/order_request.go @@ -38,3 +38,13 @@ type OrderUpdateLogisticInfoFailed struct { type OrderORsNotUpdateStatus struct { ORCodes []string `json:"orCodes"` } + +// OrderSupplierQuery ... +type OrderSupplierQuery struct { + Limit int64 `json:"limit"` + Page int64 `json:"page"` + FromDate string `json:"fromDate"` + ToDate string `json:"toDate"` + SupplierID string `json:"supplierId"` + WarehouseIDs []string `json:"warehouseIDs"` +} diff --git a/model/order_response.go b/model/order_response.go new file mode 100644 index 0000000..cbde555 --- /dev/null +++ b/model/order_response.go @@ -0,0 +1,34 @@ +package model + +import "time" + +// SupplierOrderList ... +type SupplierOrderList struct { + List []SupplierOrder `json:"list"` + Total int64 `json:"total" example:"100"` + Limit int64 `json:"limit" example:"20"` +} + +// SupplierOrder ... +type SupplierOrder struct { + ID string `json:"_id"` + Code string `json:"code"` + CreatedAt time.Time `json:"createdAt"` + Status string `json:"status"` + Items []SupplierOrderItem `json:"items"` + Delivery SupplierOrderDelivery `json:"delivery"` +} + +// SupplierOrderItem ... +type SupplierOrderItem struct { + ID string `json:"_id" example:"1231"` + SupplierSKU string `json:"supplierSku" example:"SUPPLIER_SKU"` + Quantity int64 `json:"quantity" example:"2"` +} + +// SupplierOrderDelivery ... +type SupplierOrderDelivery struct { + Code string `json:"code" example:"123187287"` + Status string `json:"status" enums:"waiting_to_confirm,waiting_to_pick,picking,picked,delay_pickup,pickup_failed,delivering,delay_delivery,delivered,cancelled,delivery_failed,waiting_to_return,returning,delay_return,compensation,returned"` + TPLCode string `json:"tplCode" enums:"SLY,GHTK,GHN,SSC,SPY,VTP,SE,NTL,BEST"` +} diff --git a/subject/order.go b/subject/order.go index 1452de3..017f2be 100644 --- a/subject/order.go +++ b/subject/order.go @@ -12,10 +12,12 @@ var Order = struct { ChangeDeliveryStatus string UpdateLogisticInfoFailed string ORNotUpdateStatus string + GetSupplierOrders string }{ UpdateORStatus: getOrderValue("update_outbound_request_status"), CancelDelivery: getOrderValue("cancel_delivery"), ChangeDeliveryStatus: getOrderValue("change_delivery_status"), UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"), ORNotUpdateStatus: getOrderValue("outbound_request_not_update_status"), + GetSupplierOrders: getOrderValue("get_supplier_orders"), } -- 2.34.1 From d06719b0e6b4377ebbd82e1cd9da5fd12cafd2f2 Mon Sep 17 00:00:00 2001 From: Sinh Date: Thu, 22 Sep 2022 09:34:16 +0700 Subject: [PATCH 16/26] define api get supplier orders --- model/order_response.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/model/order_response.go b/model/order_response.go index cbde555..c08f87a 100644 --- a/model/order_response.go +++ b/model/order_response.go @@ -11,12 +11,13 @@ type SupplierOrderList struct { // SupplierOrder ... type SupplierOrder struct { - ID string `json:"_id"` - Code string `json:"code"` - CreatedAt time.Time `json:"createdAt"` - Status string `json:"status"` - Items []SupplierOrderItem `json:"items"` - Delivery SupplierOrderDelivery `json:"delivery"` + ID string `json:"_id"` + Code string `json:"code"` + CreatedAt time.Time `json:"createdAt"` + Status string `json:"status"` + WarehouseStatus string `json:"warehouseStatus"` + Items []SupplierOrderItem `json:"items"` + Delivery SupplierOrderDelivery `json:"delivery"` } // SupplierOrderItem ... -- 2.34.1 From 021df099ccfc55b15d0bbc52b6f391b8d6d85197 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 22 Sep 2022 14:56:31 +0700 Subject: [PATCH 17/26] update location --- client/location_dao.go | 180 +++++++++++++++++++++++++++++++++++++ model/location_response.go | 120 +++++++++++++++++-------- subject/location.go | 34 +++++-- 3 files changed, 291 insertions(+), 43 deletions(-) create mode 100644 client/location_dao.go diff --git a/client/location_dao.go b/client/location_dao.go new file mode 100644 index 0000000..3c09c55 --- /dev/null +++ b/client/location_dao.go @@ -0,0 +1,180 @@ +package client + +import ( + "encoding/json" + "errors" + "github.com/Selly-Modules/natsio" + "github.com/Selly-Modules/natsio/model" + "github.com/Selly-Modules/natsio/subject" +) + +// FindOneProvinceByCondition ... +func (l Location) FindOneProvinceByCondition(p model.FindOneCondition) (*model.LocationProvinceDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.FindOneProvinceByCondition, bsonToBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data *model.LocationProvinceDetailResponse `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 +} + +// FindOneDistrictByCondition ... +func (l Location) FindOneDistrictByCondition(p model.FindOneCondition) (*model.LocationDistrictDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.FindOneDistrictByCondition, bsonToBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data *model.LocationDistrictDetailResponse `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 +} + +// FindOneWardByCondition ... +func (l Location) FindOneWardByCondition(p model.FindOneCondition) (*model.LocationWardDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.FindOneWardByCondition, bsonToBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data *model.LocationWardDetailResponse `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 +} + +// FindProvinceByCondition ... +func (l Location) FindProvinceByCondition(p model.FindWithCondition) ([]*model.LocationProvinceDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.FindProvinceByCondition, bsonToBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data []*model.LocationProvinceDetailResponse `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 +} + +// FindDistrictByCondition ... +func (l Location) FindDistrictByCondition(p model.FindWithCondition) ([]*model.LocationDistrictDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.FindDistrictByCondition, bsonToBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data []*model.LocationDistrictDetailResponse `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 +} + +// FindWardByCondition ... +func (l Location) FindWardByCondition(p model.FindWithCondition) ([]*model.LocationWardDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.FindWardByCondition, bsonToBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data []*model.LocationWardDetailResponse `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 +} + +// CountProvinceByCondition ... +func (l Location) CountProvinceByCondition(p model.FindWithCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountProvinceByCondition, bsonToBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} + +// CountDistrictByCondition ... +func (l Location) CountDistrictByCondition(p model.FindWithCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountDistrictByCondition, bsonToBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} + +// CountWardByCondition ... +func (l Location) CountWardByCondition(p model.FindWithCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountWardByCondition, bsonToBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} diff --git a/model/location_response.go b/model/location_response.go index 484d89e..2674041 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -1,43 +1,93 @@ package model -type ResponseLocationAddress struct { - Province LocationProvince `json:"province"` - District LocationDistrict `json:"district"` - Ward LocationWard `json:"ward"` -} +import "time" -// LocationProvince ... -type LocationProvince struct { - ID string `json:"id"` - Name string `json:"name"` - Code int `json:"code"` -} +type ( + // ResponseLocationAddress ... + ResponseLocationAddress struct { + Province LocationProvince `json:"province"` + District LocationDistrict `json:"district"` + Ward LocationWard `json:"ward"` + } -// LocationDistrict ... -type LocationDistrict struct { - ID string `json:"id"` - Name string `json:"name"` - Code int `json:"code"` -} + // LocationProvince ... + LocationProvince struct { + ID string `json:"id"` + Name string `json:"name"` + Code int `json:"code"` + RegionCode string `json:"regionCode"` + MainRegionCode string `json:"mainRegionCode"` + } -// LocationWard ... -type LocationWard struct { - ID string `json:"id"` - Name string `json:"name"` - Code int `json:"code"` -} + // LocationDistrict ... + LocationDistrict struct { + ID string `json:"id"` + Name string `json:"name"` + Code int `json:"code"` + } -// LocationProvinceResponse ... -type LocationProvinceResponse struct { - Provinces []LocationProvince `json:"provinces"` -} + // LocationWard ... + LocationWard struct { + ID string `json:"id"` + Name string `json:"name"` + Code int `json:"code"` + } -// LocationDistrictResponse ... -type LocationDistrictResponse struct { - Districts []LocationDistrict `json:"districts"` -} + // LocationProvinceResponse ... + LocationProvinceResponse struct { + Provinces []LocationProvince `json:"provinces"` + } -// LocationWardResponse ... -type LocationWardResponse struct { - Wards []LocationWard `json:"wards"` -} + // LocationDistrictResponse ... + LocationDistrictResponse struct { + Districts []LocationDistrict `json:"districts"` + } + + // LocationWardResponse ... + LocationWardResponse struct { + Wards []LocationWard `json:"wards"` + } + + // LocationProvinceDetailResponse ... + LocationProvinceDetailResponse struct { + ID string `json:"_id"` + Name string `json:"name"` + SearchString string `json:"searchString"` + Slug string `json:"slug"` + Code int `json:"code"` + CountryCode string `json:"countryCode"` + RegionCode string `json:"regionCode"` + MainRegionCode string `json:"mainRegionCode"` + TotalDistricts int `json:"totalDistricts"` + TotalWards int `json:"totalWards"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + } + + // LocationDistrictDetailResponse ... + LocationDistrictDetailResponse struct { + ID string `json:"_id"` + Name string `json:"name"` + SearchString string `json:"searchString"` + Slug string `json:"slug"` + Code int `json:"code"` + ProvinceCode int `json:"provinceCode"` + Area int `json:"area"` + TotalWards int `json:"totalWards"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + } + + // LocationWardDetailResponse ... + LocationWardDetailResponse struct { + ID string `json:"_id"` + Name string `json:"name"` + SearchString string `json:"searchString"` + Slug string `json:"slug"` + Code int `json:"code"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + } +) diff --git a/subject/location.go b/subject/location.go index b19a59b..7525c25 100644 --- a/subject/location.go +++ b/subject/location.go @@ -7,13 +7,31 @@ func getLocationValue(val string) string { } var Location = struct { - GetLocationByCode string - GetProvincesByCodes string - GetDistrictsByCodes string - GetWardsByCodes string + GetLocationByCode string + GetProvincesByCodes string + GetDistrictsByCodes string + GetWardsByCodes string + FindOneProvinceByCondition string + FindOneDistrictByCondition string + FindOneWardByCondition string + FindProvinceByCondition string + FindDistrictByCondition string + FindWardByCondition string + CountProvinceByCondition string + CountDistrictByCondition string + CountWardByCondition string }{ - GetLocationByCode: getLocationValue("get_location_warehouse"), - GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), - GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), - GetWardsByCodes: getLocationValue("get_wards_by_codes"), + GetLocationByCode: getLocationValue("get_location_warehouse"), + GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), + GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), + GetWardsByCodes: getLocationValue("get_wards_by_codes"), + FindOneProvinceByCondition: getLocationValue("find_one_province_by_condition"), + FindOneDistrictByCondition: getLocationValue("find_one_district_by_condition"), + FindOneWardByCondition: getLocationValue("find_one_ward_by_condition"), + FindProvinceByCondition: getLocationValue("find_province_by_condition"), + FindDistrictByCondition: getLocationValue("find_district_by_condition"), + FindWardByCondition: getLocationValue("find_ward_by_condition"), + CountProvinceByCondition: getLocationValue("count_province_by_condition"), + CountDistrictByCondition: getLocationValue("count_district_by_condition"), + CountWardByCondition: getLocationValue("count_ward_by_condition"), } -- 2.34.1 From 7a3e50ef97b87d5c87ca6b3ecffaf95c10f20e0e Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Wed, 5 Oct 2022 17:59:44 +0700 Subject: [PATCH 18/26] update location --- client/location.go | 201 ++++++++++++++++++++++++++++++++++++-- client/location_dao.go | 180 ---------------------------------- model/location_request.go | 57 +++++++---- subject/location.go | 52 +++++----- 4 files changed, 261 insertions(+), 229 deletions(-) delete mode 100644 client/location_dao.go diff --git a/client/location.go b/client/location.go index 2e8d30e..96d235c 100644 --- a/client/location.go +++ b/client/location.go @@ -28,7 +28,7 @@ func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*mode Data *model.ResponseLocationAddress `json:"data"` Error string `json:"error"` } - if err := json.Unmarshal(msg.Data, &r); err != nil { + if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err } @@ -38,7 +38,7 @@ func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*mode return r.Data, nil } -// GetProvincesByCodes ... ... +// GetProvincesByCodes ... func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.LocationProvinceResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCodes, toBytes(p)) if err != nil { @@ -46,11 +46,11 @@ func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.Lo } var r struct { - Data *model.LocationProvinceResponse `json:"data"'` + Data *model.LocationProvinceResponse `json:"data"` Error string `json:"error"` } - if err := json.Unmarshal(msg.Data, &r); err != nil { + if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err } @@ -71,7 +71,7 @@ func (l Location) GetDistrictsByCodes(p model.DistrictRequestPayload) (*model.Lo Error string `json:"error"` } - if err := json.Unmarshal(msg.Data, &r); err != nil { + if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err } @@ -94,7 +94,7 @@ func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWa Error string `json:"error"` } - if err := json.Unmarshal(msg.Data, &r); err != nil { + if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err } @@ -104,3 +104,192 @@ func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWa return r.Data, nil } + +// GetProvinceByCondition ... +func (l Location) GetProvinceByCondition(p model.ProvinceRequestCondition) (*model.LocationProvinceDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetProvinceByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.LocationProvinceDetailResponse `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 +} + +// GetProvincesByCondition ... +func (l Location) GetProvincesByCondition(p model.DistrictRequestCondition) ([]*model.LocationProvinceDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data []*model.LocationProvinceDetailResponse `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 +} + +// GetDistrictByCondition ... +func (l Location) GetDistrictByCondition(p model.ProvinceRequestCondition) (*model.LocationProvinceDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetDistrictByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.LocationProvinceDetailResponse `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 +} + +// GetDistrictsByCondition ... +func (l Location) GetDistrictsByCondition(p model.ProvinceRequestCondition) ([]*model.LocationDistrictDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data []*model.LocationDistrictDetailResponse `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 +} + +// GetWardByCondition ... +func (l Location) GetWardByCondition(p model.DistrictRequestCondition) (*model.LocationWardDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetWardByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.LocationWardDetailResponse `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 +} + +// GetWardsByCondition ... +func (l Location) GetWardsByCondition(p model.ProvinceRequestCondition) ([]*model.LocationWardDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data []*model.LocationWardDetailResponse `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 +} + +// CountProvinceByCondition ... +func (l Location) CountProvinceByCondition(p model.WardRequestCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountProvinceByCondition, toBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} + +// CountDistrictByCondition ... +func (l Location) CountDistrictByCondition(p model.FindWithCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountDistrictByCondition, toBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} + +// CountWardByCondition ... +func (l Location) CountWardByCondition(p model.FindWithCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountWardByCondition, toBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} diff --git a/client/location_dao.go b/client/location_dao.go deleted file mode 100644 index 3c09c55..0000000 --- a/client/location_dao.go +++ /dev/null @@ -1,180 +0,0 @@ -package client - -import ( - "encoding/json" - "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" -) - -// FindOneProvinceByCondition ... -func (l Location) FindOneProvinceByCondition(p model.FindOneCondition) (*model.LocationProvinceDetailResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.FindOneProvinceByCondition, bsonToBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data *model.LocationProvinceDetailResponse `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 -} - -// FindOneDistrictByCondition ... -func (l Location) FindOneDistrictByCondition(p model.FindOneCondition) (*model.LocationDistrictDetailResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.FindOneDistrictByCondition, bsonToBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data *model.LocationDistrictDetailResponse `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 -} - -// FindOneWardByCondition ... -func (l Location) FindOneWardByCondition(p model.FindOneCondition) (*model.LocationWardDetailResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.FindOneWardByCondition, bsonToBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data *model.LocationWardDetailResponse `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 -} - -// FindProvinceByCondition ... -func (l Location) FindProvinceByCondition(p model.FindWithCondition) ([]*model.LocationProvinceDetailResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.FindProvinceByCondition, bsonToBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data []*model.LocationProvinceDetailResponse `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 -} - -// FindDistrictByCondition ... -func (l Location) FindDistrictByCondition(p model.FindWithCondition) ([]*model.LocationDistrictDetailResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.FindDistrictByCondition, bsonToBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data []*model.LocationDistrictDetailResponse `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 -} - -// FindWardByCondition ... -func (l Location) FindWardByCondition(p model.FindWithCondition) ([]*model.LocationWardDetailResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.FindWardByCondition, bsonToBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data []*model.LocationWardDetailResponse `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 -} - -// CountProvinceByCondition ... -func (l Location) CountProvinceByCondition(p model.FindWithCondition) (int64, error) { - msg, err := natsio.GetServer().Request(subject.Location.CountProvinceByCondition, bsonToBytes(p)) - if err != nil { - return 0, err - } - var r struct { - Data int64 `json:"data"` - Error string `json:"error"` - } - if err = json.Unmarshal(msg.Data, &r); err != nil { - return 0, err - } - if r.Error != "" { - return 0, errors.New(r.Error) - } - return r.Data, nil -} - -// CountDistrictByCondition ... -func (l Location) CountDistrictByCondition(p model.FindWithCondition) (int64, error) { - msg, err := natsio.GetServer().Request(subject.Location.CountDistrictByCondition, bsonToBytes(p)) - if err != nil { - return 0, err - } - var r struct { - Data int64 `json:"data"` - Error string `json:"error"` - } - if err = json.Unmarshal(msg.Data, &r); err != nil { - return 0, err - } - if r.Error != "" { - return 0, errors.New(r.Error) - } - return r.Data, nil -} - -// CountWardByCondition ... -func (l Location) CountWardByCondition(p model.FindWithCondition) (int64, error) { - msg, err := natsio.GetServer().Request(subject.Location.CountWardByCondition, bsonToBytes(p)) - if err != nil { - return 0, err - } - var r struct { - Data int64 `json:"data"` - Error string `json:"error"` - } - if err = json.Unmarshal(msg.Data, &r); err != nil { - return 0, err - } - if r.Error != "" { - return 0, errors.New(r.Error) - } - return r.Data, nil -} diff --git a/model/location_request.go b/model/location_request.go index 4533db7..22bdea7 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -1,23 +1,46 @@ package model // LocationRequestPayload ... -type LocationRequestPayload struct { - Province int `json:"province"` - District int `json:"district"` - Ward int `json:"ward"` -} +type ( + LocationRequestPayload struct { + Province int `json:"province"` + District int `json:"district"` + Ward int `json:"ward"` + } -// ProvinceRequestPayload ... -type ProvinceRequestPayload struct { - Codes []int `json:"codes"` -} + // ProvinceRequestPayload ... + ProvinceRequestPayload struct { + Codes []int `json:"codes"` + } -// DistrictRequestPayload ... -type DistrictRequestPayload struct { - Codes []int `json:"codes"` -} + // ProvinceRequestCondition ... + ProvinceRequestCondition struct { + Code int `json:"code"` + Codes []int `json:"codes"` + } -// WardRequestPayload ... -type WardRequestPayload struct { - Codes []int `json:"codes"` -} + // DistrictRequestPayload ... + DistrictRequestPayload struct { + Codes []int `json:"codes"` + } + + // DistrictRequestCondition ... + DistrictRequestCondition struct { + Code int `json:"code"` + Codes int `json:"codes"` + ProvinceCode int `json:"provinceCode"` + } + + // WardRequestPayload ... + WardRequestPayload struct { + Codes []int `json:"codes"` + } + + // WardRequestCondition ... + WardRequestCondition struct { + Code int `json:"code"` + Codes []int `json:"codes"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` + } +) diff --git a/subject/location.go b/subject/location.go index 7525c25..40a21e4 100644 --- a/subject/location.go +++ b/subject/location.go @@ -7,31 +7,31 @@ func getLocationValue(val string) string { } var Location = struct { - GetLocationByCode string - GetProvincesByCodes string - GetDistrictsByCodes string - GetWardsByCodes string - FindOneProvinceByCondition string - FindOneDistrictByCondition string - FindOneWardByCondition string - FindProvinceByCondition string - FindDistrictByCondition string - FindWardByCondition string - CountProvinceByCondition string - CountDistrictByCondition string - CountWardByCondition string + GetLocationByCode string + GetProvincesByCodes string + GetDistrictsByCodes string + GetWardsByCodes string + GetProvinceByCondition string + GetProvincesByCondition string + GetDistrictByCondition string + GetDistrictsByCondition string + GetWardByCondition string + GetWardsByCondition string + CountProvinceByCondition string + CountDistrictByCondition string + CountWardByCondition string }{ - GetLocationByCode: getLocationValue("get_location_warehouse"), - GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), - GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), - GetWardsByCodes: getLocationValue("get_wards_by_codes"), - FindOneProvinceByCondition: getLocationValue("find_one_province_by_condition"), - FindOneDistrictByCondition: getLocationValue("find_one_district_by_condition"), - FindOneWardByCondition: getLocationValue("find_one_ward_by_condition"), - FindProvinceByCondition: getLocationValue("find_province_by_condition"), - FindDistrictByCondition: getLocationValue("find_district_by_condition"), - FindWardByCondition: getLocationValue("find_ward_by_condition"), - CountProvinceByCondition: getLocationValue("count_province_by_condition"), - CountDistrictByCondition: getLocationValue("count_district_by_condition"), - CountWardByCondition: getLocationValue("count_ward_by_condition"), + GetLocationByCode: getLocationValue("get_location_warehouse"), + GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), + GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), + GetWardsByCodes: getLocationValue("get_wards_by_codes"), + GetProvinceByCondition: getLocationValue("get_province_by_condition"), + GetProvincesByCondition: getLocationValue("get_provinces_by_condition"), + GetDistrictByCondition: getLocationValue("get_district_by_condition"), + GetDistrictsByCondition: getLocationValue("get_districts_byCondition"), + GetWardByCondition: getLocationValue("get_ward_by_condition"), + GetWardsByCondition: getLocationValue("get_wards_by_condition"), + CountProvinceByCondition: getLocationValue("count_province_by_condition"), + CountDistrictByCondition: getLocationValue("count_district_by_condition"), + CountWardByCondition: getLocationValue("count_ward_by_condition"), } -- 2.34.1 From 863e924a5e47a001088ec3cd74a7d166ae899a61 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Wed, 5 Oct 2022 18:12:42 +0700 Subject: [PATCH 19/26] update location --- client/location.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/location.go b/client/location.go index 96d235c..6e08261 100644 --- a/client/location.go +++ b/client/location.go @@ -128,7 +128,7 @@ func (l Location) GetProvinceByCondition(p model.ProvinceRequestCondition) (*mod } // GetProvincesByCondition ... -func (l Location) GetProvincesByCondition(p model.DistrictRequestCondition) ([]*model.LocationProvinceDetailResponse, error) { +func (l Location) GetProvincesByCondition(p model.ProvinceRequestCondition) ([]*model.LocationProvinceDetailResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCondition, toBytes(p)) if err != nil { return nil, err @@ -150,7 +150,7 @@ func (l Location) GetProvincesByCondition(p model.DistrictRequestCondition) ([]* } // GetDistrictByCondition ... -func (l Location) GetDistrictByCondition(p model.ProvinceRequestCondition) (*model.LocationProvinceDetailResponse, error) { +func (l Location) GetDistrictByCondition(p model.DistrictRequestCondition) (*model.LocationProvinceDetailResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetDistrictByCondition, toBytes(p)) if err != nil { return nil, err @@ -172,7 +172,7 @@ func (l Location) GetDistrictByCondition(p model.ProvinceRequestCondition) (*mod } // GetDistrictsByCondition ... -func (l Location) GetDistrictsByCondition(p model.ProvinceRequestCondition) ([]*model.LocationDistrictDetailResponse, error) { +func (l Location) GetDistrictsByCondition(p model.DistrictRequestCondition) ([]*model.LocationDistrictDetailResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCondition, toBytes(p)) if err != nil { return nil, err @@ -194,7 +194,7 @@ func (l Location) GetDistrictsByCondition(p model.ProvinceRequestCondition) ([]* } // GetWardByCondition ... -func (l Location) GetWardByCondition(p model.DistrictRequestCondition) (*model.LocationWardDetailResponse, error) { +func (l Location) GetWardByCondition(p model.WardRequestCondition) (*model.LocationWardDetailResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetWardByCondition, toBytes(p)) if err != nil { return nil, err @@ -216,7 +216,7 @@ func (l Location) GetWardByCondition(p model.DistrictRequestCondition) (*model.L } // GetWardsByCondition ... -func (l Location) GetWardsByCondition(p model.ProvinceRequestCondition) ([]*model.LocationWardDetailResponse, error) { +func (l Location) GetWardsByCondition(p model.WardRequestCondition) ([]*model.LocationWardDetailResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCondition, toBytes(p)) if err != nil { return nil, err @@ -238,7 +238,7 @@ func (l Location) GetWardsByCondition(p model.ProvinceRequestCondition) ([]*mode } // CountProvinceByCondition ... -func (l Location) CountProvinceByCondition(p model.WardRequestCondition) (int64, error) { +func (l Location) CountProvinceByCondition(p model.ProvinceRequestCondition) (int64, error) { msg, err := natsio.GetServer().Request(subject.Location.CountProvinceByCondition, toBytes(p)) if err != nil { return 0, err @@ -257,7 +257,7 @@ func (l Location) CountProvinceByCondition(p model.WardRequestCondition) (int64, } // CountDistrictByCondition ... -func (l Location) CountDistrictByCondition(p model.FindWithCondition) (int64, error) { +func (l Location) CountDistrictByCondition(p model.DistrictRequestCondition) (int64, error) { msg, err := natsio.GetServer().Request(subject.Location.CountDistrictByCondition, toBytes(p)) if err != nil { return 0, err @@ -276,7 +276,7 @@ func (l Location) CountDistrictByCondition(p model.FindWithCondition) (int64, er } // CountWardByCondition ... -func (l Location) CountWardByCondition(p model.FindWithCondition) (int64, error) { +func (l Location) CountWardByCondition(p model.WardRequestCondition) (int64, error) { msg, err := natsio.GetServer().Request(subject.Location.CountWardByCondition, toBytes(p)) if err != nil { return 0, err -- 2.34.1 From a86a0978864179eb55f19a99cf60196d67c824a5 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Wed, 5 Oct 2022 18:15:36 +0700 Subject: [PATCH 20/26] update location --- model/location_request.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/model/location_request.go b/model/location_request.go index 22bdea7..674b8bd 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -26,9 +26,9 @@ type ( // DistrictRequestCondition ... DistrictRequestCondition struct { - Code int `json:"code"` - Codes int `json:"codes"` - ProvinceCode int `json:"provinceCode"` + Code int `json:"code"` + Codes []int `json:"codes"` + ProvinceCode int `json:"provinceCode"` } // WardRequestPayload ... -- 2.34.1 From 29b2b861ff5ba54382305e5b5c4110fd839b16a2 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 6 Oct 2022 09:19:21 +0700 Subject: [PATCH 21/26] update location add find by slug --- model/location_request.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/model/location_request.go b/model/location_request.go index 674b8bd..98096ff 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -15,8 +15,9 @@ type ( // ProvinceRequestCondition ... ProvinceRequestCondition struct { - Code int `json:"code"` - Codes []int `json:"codes"` + Code int `json:"code"` + Codes []int `json:"codes"` + Slug string `json:"slug"` } // DistrictRequestPayload ... @@ -26,9 +27,10 @@ type ( // DistrictRequestCondition ... DistrictRequestCondition struct { - Code int `json:"code"` - Codes []int `json:"codes"` - ProvinceCode int `json:"provinceCode"` + Code int `json:"code"` + Codes []int `json:"codes"` + ProvinceCode int `json:"provinceCode"` + Slug string `json:"slug"` } // WardRequestPayload ... @@ -38,9 +40,10 @@ type ( // WardRequestCondition ... WardRequestCondition struct { - Code int `json:"code"` - Codes []int `json:"codes"` - DistrictCode int `json:"districtCode"` - ProvinceCode int `json:"provinceCode"` + Code int `json:"code"` + Codes []int `json:"codes"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` + Slug string `json:"slug"` } ) -- 2.34.1 From b9b55d144e9dcae3a757c068c4728df34a2b91c1 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 6 Oct 2022 10:20:47 +0700 Subject: [PATCH 22/26] update fix GetDistrictByCondition --- client/location.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/location.go b/client/location.go index 6e08261..76f9a3f 100644 --- a/client/location.go +++ b/client/location.go @@ -150,14 +150,14 @@ func (l Location) GetProvincesByCondition(p model.ProvinceRequestCondition) ([]* } // GetDistrictByCondition ... -func (l Location) GetDistrictByCondition(p model.DistrictRequestCondition) (*model.LocationProvinceDetailResponse, error) { +func (l Location) GetDistrictByCondition(p model.DistrictRequestCondition) (*model.LocationDistrictDetailResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetDistrictByCondition, toBytes(p)) if err != nil { return nil, err } var r struct { - Data *model.LocationProvinceDetailResponse `json:"data"` + Data *model.LocationDistrictDetailResponse `json:"data"` Error string `json:"error"` } -- 2.34.1 From cebb3214cfcac46f61a7f6c1b90fa816d92f5165 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 6 Oct 2022 10:55:49 +0700 Subject: [PATCH 23/26] update location add slug & DistinctWithField --- client/location.go | 19 ++++++++++++++ model/location_request.go | 18 ++++++++++--- subject/location.go | 54 ++++++++++++++++++++------------------- 3 files changed, 62 insertions(+), 29 deletions(-) diff --git a/client/location.go b/client/location.go index 76f9a3f..d8b3380 100644 --- a/client/location.go +++ b/client/location.go @@ -293,3 +293,22 @@ func (l Location) CountWardByCondition(p model.WardRequestCondition) (int64, err } return r.Data, nil } + +// DistinctWithField ... +func (l Location) DistinctWithField(p model.ProvinceDistinctWithField) ([]interface{}, error) { + msg, err := natsio.GetServer().Request(subject.Location.ProvinceDistinctWithField, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data []interface{} `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/location_request.go b/model/location_request.go index 98096ff..5816b52 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -15,9 +15,10 @@ type ( // ProvinceRequestCondition ... ProvinceRequestCondition struct { - Code int `json:"code"` - Codes []int `json:"codes"` - Slug string `json:"slug"` + Code int `json:"code"` + Codes []int `json:"codes"` + Slug string `json:"slug"` + Slugs []string `json:"slugs"` } // DistrictRequestPayload ... @@ -31,6 +32,7 @@ type ( Codes []int `json:"codes"` ProvinceCode int `json:"provinceCode"` Slug string `json:"slug"` + ProvinceSlug string `json:"provinceSlug"` } // WardRequestPayload ... @@ -45,5 +47,15 @@ type ( DistrictCode int `json:"districtCode"` ProvinceCode int `json:"provinceCode"` Slug string `json:"slug"` + DistrictSlug string `json:"districtSlug"` + ProvinceSlug string `json:"provinceSlug"` + } + + // ProvinceDistinctWithField ... + ProvinceDistinctWithField struct { + Conditions struct { + Region string `json:"region"` + } `json:"conditions"` + Field string `json:"filed"` } ) diff --git a/subject/location.go b/subject/location.go index 40a21e4..c625ca4 100644 --- a/subject/location.go +++ b/subject/location.go @@ -7,31 +7,33 @@ func getLocationValue(val string) string { } var Location = struct { - GetLocationByCode string - GetProvincesByCodes string - GetDistrictsByCodes string - GetWardsByCodes string - GetProvinceByCondition string - GetProvincesByCondition string - GetDistrictByCondition string - GetDistrictsByCondition string - GetWardByCondition string - GetWardsByCondition string - CountProvinceByCondition string - CountDistrictByCondition string - CountWardByCondition string + GetLocationByCode string + GetProvincesByCodes string + GetDistrictsByCodes string + GetWardsByCodes string + GetProvinceByCondition string + GetProvincesByCondition string + GetDistrictByCondition string + GetDistrictsByCondition string + GetWardByCondition string + GetWardsByCondition string + CountProvinceByCondition string + CountDistrictByCondition string + CountWardByCondition string + ProvinceDistinctWithField string }{ - GetLocationByCode: getLocationValue("get_location_warehouse"), - GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), - GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), - GetWardsByCodes: getLocationValue("get_wards_by_codes"), - GetProvinceByCondition: getLocationValue("get_province_by_condition"), - GetProvincesByCondition: getLocationValue("get_provinces_by_condition"), - GetDistrictByCondition: getLocationValue("get_district_by_condition"), - GetDistrictsByCondition: getLocationValue("get_districts_byCondition"), - GetWardByCondition: getLocationValue("get_ward_by_condition"), - GetWardsByCondition: getLocationValue("get_wards_by_condition"), - CountProvinceByCondition: getLocationValue("count_province_by_condition"), - CountDistrictByCondition: getLocationValue("count_district_by_condition"), - CountWardByCondition: getLocationValue("count_ward_by_condition"), + GetLocationByCode: getLocationValue("get_location_warehouse"), + GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), + GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), + GetWardsByCodes: getLocationValue("get_wards_by_codes"), + GetProvinceByCondition: getLocationValue("get_province_by_condition"), + GetProvincesByCondition: getLocationValue("get_provinces_by_condition"), + GetDistrictByCondition: getLocationValue("get_district_by_condition"), + GetDistrictsByCondition: getLocationValue("get_districts_byCondition"), + GetWardByCondition: getLocationValue("get_ward_by_condition"), + GetWardsByCondition: getLocationValue("get_wards_by_condition"), + CountProvinceByCondition: getLocationValue("count_province_by_condition"), + CountDistrictByCondition: getLocationValue("count_district_by_condition"), + CountWardByCondition: getLocationValue("count_ward_by_condition"), + ProvinceDistinctWithField: getLocationValue("province_distinct_with_field"), } -- 2.34.1 From 3e13cb55b32ff8f8d73c8a61da534cb137329f35 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 6 Oct 2022 11:22:10 +0700 Subject: [PATCH 24/26] update location request condition --- model/location_request.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/model/location_request.go b/model/location_request.go index 5816b52..69245aa 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -15,10 +15,12 @@ type ( // ProvinceRequestCondition ... ProvinceRequestCondition struct { - Code int `json:"code"` - Codes []int `json:"codes"` - Slug string `json:"slug"` - Slugs []string `json:"slugs"` + Code int `json:"code"` + Codes []int `json:"codes"` + Slug string `json:"slug"` + Slugs []string `json:"slugs"` + Keyword string `json:"keyword"` + Region string `json:"region"` } // DistrictRequestPayload ... @@ -33,6 +35,7 @@ type ( ProvinceCode int `json:"provinceCode"` Slug string `json:"slug"` ProvinceSlug string `json:"provinceSlug"` + Keyword string `json:"keyword"` } // WardRequestPayload ... -- 2.34.1 From ed0f16623ad22857148aa4a216117292317b0819 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Fri, 7 Oct 2022 15:23:02 +0700 Subject: [PATCH 25/26] add old slug to location response struct --- model/location_response.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/model/location_response.go b/model/location_response.go index 2674041..1595908 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -54,6 +54,7 @@ type ( Name string `json:"name"` SearchString string `json:"searchString"` Slug string `json:"slug"` + OldSlug string `json:"oldSlug"` Code int `json:"code"` CountryCode string `json:"countryCode"` RegionCode string `json:"regionCode"` @@ -70,6 +71,7 @@ type ( Name string `json:"name"` SearchString string `json:"searchString"` Slug string `json:"slug"` + OldSlug string `json:"oldSlug"` Code int `json:"code"` ProvinceCode int `json:"provinceCode"` Area int `json:"area"` @@ -84,6 +86,7 @@ type ( Name string `json:"name"` SearchString string `json:"searchString"` Slug string `json:"slug"` + OldSlugs []string `json:"oldSlugs"` Code int `json:"code"` DistrictCode int `json:"districtCode"` ProvinceCode int `json:"provinceCode"` -- 2.34.1 From 42874f493736868645f4b47b8dfcb0a1b1854ccc Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Mon, 10 Oct 2022 09:06:20 +0700 Subject: [PATCH 26/26] seller-add-field-planPackage --- model/seller_response.go | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/model/seller_response.go b/model/seller_response.go index aec57b9..01c80e5 100644 --- a/model/seller_response.go +++ b/model/seller_response.go @@ -21,16 +21,25 @@ type ResponseListSellerInfoSupportChat struct { // ResponseSellerInfoSupportChat ... type ResponseSellerInfoSupportChat struct { - ID string `json:"_id"` - Name string `json:"name"` - Code string `json:"code"` - Membership SellerMembershipInfo `json:"membership"` - Info SellerContactInfo `json:"info"` - Team *TeamInfo `json:"team,omitempty"` - Statistic SellerStatistic `json:"statistic"` - TrackingTime *SellerTrackingTime `json:"trackingTime"` - Invitee *InviteeInfo `json:"invitee"` - CreatedAt time.Time `json:"createdAt"` + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Membership SellerMembershipInfo `json:"membership"` + Info SellerContactInfo `json:"info"` + Team *TeamInfo `json:"team,omitempty"` + Statistic SellerStatistic `json:"statistic"` + TrackingTime *SellerTrackingTime `json:"trackingTime"` + Invitee *InviteeInfo `json:"invitee"` + CreatedAt time.Time `json:"createdAt"` + PlanPackage *SellerPlanPackageInfo `json:"planPackage"` +} + +// SellerPlanPackageInfo ... +type SellerPlanPackageInfo struct { + ID string `json:"_id"` + Name string `json:"name"` + Level int `json:"level"` + CreatedAt time.Time `json:"createdAt"` } // SellerTrackingTime ... -- 2.34.1