From 4546d0e89b596ac003a86dd0a9ea8315356638ac Mon Sep 17 00:00:00 2001 From: Tue Date: Thu, 15 Sep 2022 11:20:34 +0700 Subject: [PATCH 001/103] 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"), } From 44f0e4be441b4f30079d1b38e7518b38d7dc6ace Mon Sep 17 00:00:00 2001 From: Tue Date: Sat, 17 Sep 2022 10:55:37 +0700 Subject: [PATCH 002/103] 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) { From 22cd1eb18f1d9ef48652b4ba40b3945060291645 Mon Sep 17 00:00:00 2001 From: Tue Date: Sat, 17 Sep 2022 10:59:30 +0700 Subject: [PATCH 003/103] 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 From 3c5c95b103193e5866d396f116c035273c56c450 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Tue, 20 Sep 2022 10:56:45 +0700 Subject: [PATCH 004/103] [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 From 6b168cd98a49d6a3d7e2a556a82abc1ad6b7aa9f Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 21 Sep 2022 14:06:59 +0700 Subject: [PATCH 005/103] bank info --- client/bank.go | 16 ++++++++++++++++ model/bank_branch_request.go | 6 ++++++ subject/bank.go | 10 ++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 model/bank_branch_request.go diff --git a/client/bank.go b/client/bank.go index 5650b2f..86b3d94 100644 --- a/client/bank.go +++ b/client/bank.go @@ -37,3 +37,19 @@ func (s Bank) GetBankById(bankID string) (*model.BankBrief, 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/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/subject/bank.go b/subject/bank.go index a991d5d..9f7f8bb 100644 --- a/subject/bank.go +++ b/subject/bank.go @@ -7,9 +7,11 @@ func getBankValue(val string) string { } var Bank = struct { - GetBankById string - GetBankBranchById string + GetBankById string + GetBankBranchById string + CheckBankAndBranchByID string }{ - GetBankById: getBankValue("get_bank_by_id"), - GetBankBranchById: getBankValue("get_bank_branch_by_id"), + GetBankById: getBankValue("get_bank_by_id"), + GetBankBranchById: getBankValue("get_bank_branch_by_id"), + CheckBankAndBranchByID: getBankValue("check_bank_and_brach_by_id"), } From 021df099ccfc55b15d0bbc52b6f391b8d6d85197 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 22 Sep 2022 14:56:31 +0700 Subject: [PATCH 006/103] 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"), } From 7a3e50ef97b87d5c87ca6b3ecffaf95c10f20e0e Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Wed, 5 Oct 2022 17:59:44 +0700 Subject: [PATCH 007/103] 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"), } From 863e924a5e47a001088ec3cd74a7d166ae899a61 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Wed, 5 Oct 2022 18:12:42 +0700 Subject: [PATCH 008/103] 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 From a86a0978864179eb55f19a99cf60196d67c824a5 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Wed, 5 Oct 2022 18:15:36 +0700 Subject: [PATCH 009/103] 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 ... From 29b2b861ff5ba54382305e5b5c4110fd839b16a2 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 6 Oct 2022 09:19:21 +0700 Subject: [PATCH 010/103] 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"` } ) From b9b55d144e9dcae3a757c068c4728df34a2b91c1 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 6 Oct 2022 10:20:47 +0700 Subject: [PATCH 011/103] 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"` } From cebb3214cfcac46f61a7f6c1b90fa816d92f5165 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 6 Oct 2022 10:55:49 +0700 Subject: [PATCH 012/103] 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"), } From 3e13cb55b32ff8f8d73c8a61da534cb137329f35 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 6 Oct 2022 11:22:10 +0700 Subject: [PATCH 013/103] 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 ... From ed0f16623ad22857148aa4a216117292317b0819 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Fri, 7 Oct 2022 15:23:02 +0700 Subject: [PATCH 014/103] 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"` From d71d7f0eb43878d93e3e6b773b9f65429bee0cc9 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 13 Oct 2022 10:23:11 +0700 Subject: [PATCH 015/103] [location] add Keyword to WardRequestCondition struct --- model/location_request.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/location_request.go b/model/location_request.go index 69245aa..e4312ce 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -52,6 +52,7 @@ type ( Slug string `json:"slug"` DistrictSlug string `json:"districtSlug"` ProvinceSlug string `json:"provinceSlug"` + Keyword string `json:"keyword"` } // ProvinceDistinctWithField ... From b7d963cc90a9916d5d05fe77a5f6a915a256086d Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Mon, 17 Oct 2022 15:09:50 +0700 Subject: [PATCH 016/103] get list warehouse freeship --- client/supplier.go | 23 +++++++++++++++++++++++ model/supplier_response.go | 4 ++++ subject/supplier.go | 2 ++ 3 files changed, 29 insertions(+) diff --git a/client/supplier.go b/client/supplier.go index 0452b82..b091b78 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "errors" + "go.mongodb.org/mongo-driver/bson" "git.selly.red/Selly-Modules/natsio" "git.selly.red/Selly-Modules/natsio/model" @@ -115,3 +116,25 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh } return nil } + +// GetWarehouseFreeship ... +func (s Supplier) GetWarehouseFreeship() (*model.ResponseListWarehouseIDByBusinessType, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.GetListWarehouseFreeship, toBytes(bson.M{})) + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseListWarehouseIDByBusinessType `json:"data"` + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + + return r.Data, nil +} diff --git a/model/supplier_response.go b/model/supplier_response.go index 975a8de..3796e50 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -29,3 +29,7 @@ type SupplierAll struct { Suppliers []SupplierBrief `json:"suppliers"` Total int64 `json:"total"` } + +type ResponseListWarehouseIDByBusinessType struct { + Warehouses []string `json:"warehouses"` +} diff --git a/subject/supplier.go b/subject/supplier.go index 17ca8d0..f249ef1 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -10,8 +10,10 @@ var Supplier = struct { GetListSupplierInfo string GetSupplierContractBySupplierID string FindAll string + GetListWarehouseFreeship string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), + GetListWarehouseFreeship: getSupplierValue("get_list_warehouse_freeship"), } From 87158679a73a2b694e0906820a2dbc14ddc85a7f Mon Sep 17 00:00:00 2001 From: Tue Date: Thu, 20 Oct 2022 14:32:32 +0700 Subject: [PATCH 017/103] update auth sms --- client/authsms.go | 38 ++++++++++++++++++++++++++++++++++++++ model/authsms_request.go | 8 ++++++++ model/authsms_response.go | 5 +++++ subject/authsms.go | 13 +++++++++++++ subject/config.go | 2 ++ 5 files changed, 66 insertions(+) create mode 100644 client/authsms.go create mode 100644 model/authsms_request.go create mode 100644 model/authsms_response.go create mode 100644 subject/authsms.go diff --git a/client/authsms.go b/client/authsms.go new file mode 100644 index 0000000..d98be55 --- /dev/null +++ b/client/authsms.go @@ -0,0 +1,38 @@ +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" +) + +// AuthSMS ... +type AuthSMS struct{} + +// GetAutSMS ... +func GetAutSMS() AuthSMS { + return AuthSMS{} +} + +func (s AuthSMS) CreateUserSMSViaAuthSMS(p model.CreateUserSMSRequest) (*model.CreateUserSMSResponse, error) { + msg, err := natsio.GetServer().Request(subject.AuthSMS.CreateUserSMS, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.CreateUserSMSResponse `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/authsms_request.go b/model/authsms_request.go new file mode 100644 index 0000000..c0b3078 --- /dev/null +++ b/model/authsms_request.go @@ -0,0 +1,8 @@ +package model + +type CreateUserSMSRequest struct { + Name string `json:"name"` + Phone string `json:"phone"` + Email string `json:"email"` + Supplier string `json:"supplier"` +} diff --git a/model/authsms_response.go b/model/authsms_response.go new file mode 100644 index 0000000..0effbbc --- /dev/null +++ b/model/authsms_response.go @@ -0,0 +1,5 @@ +package model + +type CreateUserSMSResponse struct { + ID string `json:"_id"` +} diff --git a/subject/authsms.go b/subject/authsms.go new file mode 100644 index 0000000..4b7a0ad --- /dev/null +++ b/subject/authsms.go @@ -0,0 +1,13 @@ +package subject + +import "fmt" + +func getAuthSMSValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.AuthSMS, val) +} + +var AuthSMS = struct { + CreateUserSMS string +}{ + CreateUserSMS: getAuthSMSValue("create_user_sms"), +} diff --git a/subject/config.go b/subject/config.go index 4a2f9f3..ccc480e 100644 --- a/subject/config.go +++ b/subject/config.go @@ -9,6 +9,7 @@ var prefixes = struct { Bank string Supplier string Seller string + AuthSMS string }{ Communication: "communication", Order: "order", @@ -18,4 +19,5 @@ var prefixes = struct { Supplier: "supplier", Bank: "bank", Seller: "seller", + AuthSMS: "auth_sms", } From f0eb62f3f5097686a2aaf7d1f787ec98feeb9640 Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Fri, 21 Oct 2022 11:49:48 +0700 Subject: [PATCH 018/103] get list permission authsms --- client/authsms.go | 22 ++++++++++++++++++++++ model/authsms_response.go | 4 ++++ subject/authsms.go | 6 ++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/client/authsms.go b/client/authsms.go index d98be55..64d395b 100644 --- a/client/authsms.go +++ b/client/authsms.go @@ -6,6 +6,7 @@ import ( "git.selly.red/Selly-Modules/natsio" "git.selly.red/Selly-Modules/natsio/model" "git.selly.red/Selly-Modules/natsio/subject" + "go.mongodb.org/mongo-driver/bson" ) // AuthSMS ... @@ -36,3 +37,24 @@ func (s AuthSMS) CreateUserSMSViaAuthSMS(p model.CreateUserSMSRequest) (*model.C return r.Data, nil } + +func (s AuthSMS) GetListPermission() (*model.GetListPermissionResponse, error) { + msg, err := natsio.GetServer().Request(subject.AuthSMS.GetListPermission, toBytes(bson.M{})) + if err != nil { + return nil, err + } + + var r struct { + Data *model.GetListPermissionResponse `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/authsms_response.go b/model/authsms_response.go index 0effbbc..d1e6b24 100644 --- a/model/authsms_response.go +++ b/model/authsms_response.go @@ -3,3 +3,7 @@ package model type CreateUserSMSResponse struct { ID string `json:"_id"` } + +type GetListPermissionResponse struct { + Permission []string `json:"permission"` +} diff --git a/subject/authsms.go b/subject/authsms.go index 4b7a0ad..b89ca3c 100644 --- a/subject/authsms.go +++ b/subject/authsms.go @@ -7,7 +7,9 @@ func getAuthSMSValue(val string) string { } var AuthSMS = struct { - CreateUserSMS string + CreateUserSMS string + GetListPermission string }{ - CreateUserSMS: getAuthSMSValue("create_user_sms"), + CreateUserSMS: getAuthSMSValue("create_user_sms"), + GetListPermission: getAuthSMSValue("get_list_permission"), } From 27b14aa1228f302b64cc7ffd63a1e52632981fc2 Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Tue, 25 Oct 2022 12:00:37 +0700 Subject: [PATCH 019/103] get freeships by supplier ids --- client/supplier.go | 19 +++++++++++++++++++ model/supplier_request.go | 4 ++++ model/supplier_response.go | 11 +++++++++++ subject/config.go | 2 ++ subject/selly.go | 13 +++++++++++++ 5 files changed, 49 insertions(+) create mode 100644 subject/selly.go diff --git a/client/supplier.go b/client/supplier.go index b091b78..65553a1 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -138,3 +138,22 @@ func (s Supplier) GetWarehouseFreeship() (*model.ResponseListWarehouseIDByBusine return r.Data, nil } + +// GetFreeshipsBySupplierIDs ... +func (s Supplier) GetFreeshipsBySupplierIDs(p model.GetFreeshipsBySupplierIds) (*model.ResponseListFreeshipsBySupplierIds, error) { + msg, err := natsio.GetServer().Request(subject.Selly.GetFreeshipsBySupplierIds, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data *model.ResponseListFreeshipsBySupplierIds `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + return r.Data, nil +} diff --git a/model/supplier_request.go b/model/supplier_request.go index 5a19924..d0d7d68 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -38,3 +38,7 @@ type UpdateSupplierWarehousePayload struct { DistrictCode int `json:"districtCode"` WardCode int `json:"wardCode"` } + +type GetFreeshipsBySupplierIds struct { + SupplierIDs []string `json:"supplierIds"` +} diff --git a/model/supplier_response.go b/model/supplier_response.go index 3796e50..eaebef5 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -33,3 +33,14 @@ type SupplierAll struct { type ResponseListWarehouseIDByBusinessType struct { Warehouses []string `json:"warehouses"` } + +type Freeship struct { + ID string `json:"_id"` + ShortName string `json:"shortName"` + MilestoneText []string `json:"milestoneText"` +} + +type ResponseListFreeshipsBySupplierIds struct { + SupplierID string `json:"supplierId"` + Freeships []Freeship `json:"freeships"` +} diff --git a/subject/config.go b/subject/config.go index ccc480e..916e22d 100644 --- a/subject/config.go +++ b/subject/config.go @@ -10,6 +10,7 @@ var prefixes = struct { Supplier string Seller string AuthSMS string + Selly string }{ Communication: "communication", Order: "order", @@ -20,4 +21,5 @@ var prefixes = struct { Bank: "bank", Seller: "seller", AuthSMS: "auth_sms", + Selly: "selly", } diff --git a/subject/selly.go b/subject/selly.go new file mode 100644 index 0000000..27494cd --- /dev/null +++ b/subject/selly.go @@ -0,0 +1,13 @@ +package subject + +import "fmt" + +func getSellyValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Selly, val) +} + +var Selly = struct { + GetFreeshipsBySupplierIds string +}{ + GetFreeshipsBySupplierIds: getSellyValue("get_freeships_by_supplier_ids"), +} From 20f460b4ef27d6d44b74e1a099904ab4112472b5 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 26 Oct 2022 17:56:15 +0700 Subject: [PATCH 020/103] create supplier cashflow --- client/supplier.go | 19 +++++++++++++++++++ model/common_request.go | 6 ++++++ model/supplier_request.go | 10 ++++++++++ model/supplier_response.go | 4 ++++ subject/supplier.go | 2 ++ 5 files changed, 41 insertions(+) diff --git a/client/supplier.go b/client/supplier.go index 1ed20d0..f742f94 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -136,3 +136,22 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh } return nil } + +// CreateCashflow ... +func (s Supplier) CreateCashflow(p model.SupplierCashflowCreatePayload) (*model.SupplierCashflowCreateResponse, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.CreateCashflow, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Error string `json:"error"` + Data *model.SupplierCashflowCreateResponse `json:"data"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + return r.Data, nil +} diff --git a/model/common_request.go b/model/common_request.go index 0ce5163..c3cbac7 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -20,3 +20,9 @@ type ActionBy struct { ID string `json:"id"` Name string `json:"name"` } + +// ClickAction ... +type ClickAction struct { + Type string `json:"type"` + Value string `json:"value"` +} diff --git a/model/supplier_request.go b/model/supplier_request.go index 5a19924..0a4b6fa 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -38,3 +38,13 @@ type UpdateSupplierWarehousePayload struct { DistrictCode int `json:"districtCode"` WardCode int `json:"wardCode"` } + +// SupplierCashflowCreatePayload ... +type SupplierCashflowCreatePayload struct { + Supplier string `json:"supplier"` + Action string `json:"action"` + Name string `json:"name"` + TargetID string `json:"targetId"` + Value float64 `json:"value"` + ClickAction *ClickAction `json:"clickAction"` +} diff --git a/model/supplier_response.go b/model/supplier_response.go index 975a8de..8efdb2c 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -29,3 +29,7 @@ type SupplierAll struct { Suppliers []SupplierBrief `json:"suppliers"` Total int64 `json:"total"` } + +type SupplierCashflowCreateResponse struct { + ID string `json:"id"` +} diff --git a/subject/supplier.go b/subject/supplier.go index 17ca8d0..1b86c12 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -10,8 +10,10 @@ var Supplier = struct { GetListSupplierInfo string GetSupplierContractBySupplierID string FindAll string + CreateCashflow string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), + CreateCashflow: getSupplierValue("create_cashflow"), } From 112c1c0f7d4dd5d50222996e005537e21d172483 Mon Sep 17 00:00:00 2001 From: Tue Date: Thu, 27 Oct 2022 09:17:20 +0700 Subject: [PATCH 021/103] build auth sms --- client/authsms.go | 60 ----------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 client/authsms.go diff --git a/client/authsms.go b/client/authsms.go deleted file mode 100644 index 64d395b..0000000 --- a/client/authsms.go +++ /dev/null @@ -1,60 +0,0 @@ -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" - "go.mongodb.org/mongo-driver/bson" -) - -// AuthSMS ... -type AuthSMS struct{} - -// GetAutSMS ... -func GetAutSMS() AuthSMS { - return AuthSMS{} -} - -func (s AuthSMS) CreateUserSMSViaAuthSMS(p model.CreateUserSMSRequest) (*model.CreateUserSMSResponse, error) { - msg, err := natsio.GetServer().Request(subject.AuthSMS.CreateUserSMS, toBytes(p)) - if err != nil { - return nil, err - } - - var r struct { - Data *model.CreateUserSMSResponse `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 AuthSMS) GetListPermission() (*model.GetListPermissionResponse, error) { - msg, err := natsio.GetServer().Request(subject.AuthSMS.GetListPermission, toBytes(bson.M{})) - if err != nil { - return nil, err - } - - var r struct { - Data *model.GetListPermissionResponse `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 -} From 33bc508f1f648b46f21fe89c767d5597c1ce1a17 Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Thu, 27 Oct 2022 09:37:07 +0700 Subject: [PATCH 022/103] get bank and branches by bank ids --- client/bank.go | 10 ++++----- client/bank_branch.go | 39 ------------------------------------ client/supplier.go | 2 +- model/bank_branch_reponse.go | 11 ---------- model/bank_branch_request.go | 6 ------ model/bank_request.go | 10 +++++++++ model/bank_response.go | 39 +++++++++++++++++++++++++++--------- subject/bank.go | 10 ++++----- subject/selly.go | 2 ++ subject/supplier.go | 2 -- 10 files changed, 51 insertions(+), 80 deletions(-) delete mode 100644 client/bank_branch.go delete mode 100644 model/bank_branch_reponse.go delete mode 100644 model/bank_branch_request.go create mode 100644 model/bank_request.go diff --git a/client/bank.go b/client/bank.go index 3391911..69e6d26 100644 --- a/client/bank.go +++ b/client/bank.go @@ -17,15 +17,15 @@ func GetBank() Bank { return Bank{} } -func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) { - msg, err := natsio.GetServer().Request(subject.Bank.GetBankById, toBytes(bankID)) +func (s Bank) GetBankAndBranchByBankIDs(p model.GetBankAndBranchesRequest) ([]*model.ResponseBankAndBranches, error) { + msg, err := natsio.GetServer().Request(subject.Bank.GetBankAndBranchesByBankIDs, toBytes(p)) if err != nil { return nil, err } var r struct { - Data *model.BankBrief `json:"data"` - Error string `json:"error"` + Data []*model.ResponseBankAndBranches `json:"data"` + Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil { @@ -38,7 +38,7 @@ func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) { return r.Data, nil } -func (s Bank) CheckBankAndBranchByID(p model.BankBranchRequest) bool { +func (s Bank) CheckBankAndBranchByID(p model.CheckBankAndBranchByIDRequest) bool { msg, err := natsio.GetServer().Request(subject.Bank.CheckBankAndBranchByID, toBytes(p)) if err != nil { return false diff --git a/client/bank_branch.go b/client/bank_branch.go deleted file mode 100644 index 5890e75..0000000 --- a/client/bank_branch.go +++ /dev/null @@ -1,39 +0,0 @@ -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/client/supplier.go b/client/supplier.go index 65553a1..f9bbb6d 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -119,7 +119,7 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh // GetWarehouseFreeship ... func (s Supplier) GetWarehouseFreeship() (*model.ResponseListWarehouseIDByBusinessType, error) { - msg, err := natsio.GetServer().Request(subject.Supplier.GetListWarehouseFreeship, toBytes(bson.M{})) + msg, err := natsio.GetServer().Request(subject.Selly.GetListWarehouseFreeship, toBytes(bson.M{})) if err != nil { return nil, err } diff --git a/model/bank_branch_reponse.go b/model/bank_branch_reponse.go deleted file mode 100644 index 1fa1432..0000000 --- a/model/bank_branch_reponse.go +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index 6de1216..0000000 --- a/model/bank_branch_request.go +++ /dev/null @@ -1,6 +0,0 @@ -package model - -type BankBranchRequest struct { - BankID string `json:"bankId"` - BranchID string `json:"branchId"` -} diff --git a/model/bank_request.go b/model/bank_request.go new file mode 100644 index 0000000..f53b794 --- /dev/null +++ b/model/bank_request.go @@ -0,0 +1,10 @@ +package model + +type CheckBankAndBranchByIDRequest struct { + BankID string `json:"bankId"` + BranchID string `json:"branchId"` +} + +type GetBankAndBranchesRequest struct { + BankIDs []string `json:"bankIds"` +} diff --git a/model/bank_response.go b/model/bank_response.go index 74fc10e..565cf21 100644 --- a/model/bank_response.go +++ b/model/bank_response.go @@ -1,21 +1,40 @@ package model +import "time" + // MultiLang ... type MultiLang struct { En string `json:"en"` Vi string `json:"vi"` } +// BankBranchBrief ... +type BranchBrief struct { + ID string `json:"_id"` + City string `json:"city"` + BankCode string `json:"bankCode"` + BankID string `json:"bankId"` + Active bool `json:"active"` + Name string `json:"name"` +} + // 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"` + 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"` + BeneficiaryForVietinbank string `json:"beneficiaryForVietinbank"` + CreatedBy string `json:"createdBy,omitempty"` + CreatedAt time.Time `json:"createdAt"` + BranchTotal int64 `json:"branchTotal"` + Logo interface{} `json:"logo"` +} + +type ResponseBankAndBranches struct { + Bank BankBrief `json:"bank"` + Branches []BranchBrief `json:"branches"` } diff --git a/subject/bank.go b/subject/bank.go index 9f7f8bb..caf8fa1 100644 --- a/subject/bank.go +++ b/subject/bank.go @@ -7,11 +7,9 @@ func getBankValue(val string) string { } var Bank = struct { - GetBankById string - GetBankBranchById string - CheckBankAndBranchByID string + GetBankAndBranchesByBankIDs string + CheckBankAndBranchByID string }{ - GetBankById: getBankValue("get_bank_by_id"), - GetBankBranchById: getBankValue("get_bank_branch_by_id"), - CheckBankAndBranchByID: getBankValue("check_bank_and_brach_by_id"), + GetBankAndBranchesByBankIDs: getBankValue("get_bank_and_branches_by_bank_ids"), + CheckBankAndBranchByID: getBankValue("check_bank_and_branch_by_id"), } diff --git a/subject/selly.go b/subject/selly.go index 27494cd..f4b6010 100644 --- a/subject/selly.go +++ b/subject/selly.go @@ -8,6 +8,8 @@ func getSellyValue(val string) string { var Selly = struct { GetFreeshipsBySupplierIds string + GetListWarehouseFreeship string }{ GetFreeshipsBySupplierIds: getSellyValue("get_freeships_by_supplier_ids"), + GetListWarehouseFreeship: getSupplierValue("get_list_warehouse_freeship"), } diff --git a/subject/supplier.go b/subject/supplier.go index f249ef1..17ca8d0 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -10,10 +10,8 @@ var Supplier = struct { GetListSupplierInfo string GetSupplierContractBySupplierID string FindAll string - GetListWarehouseFreeship string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), - GetListWarehouseFreeship: getSupplierValue("get_list_warehouse_freeship"), } From 86cfda6dce5e9f7cdf56ae245bfab752f9e5da2b Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 27 Oct 2022 11:11:45 +0700 Subject: [PATCH 023/103] [location] create RequestCondition --- model/common_request.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/model/common_request.go b/model/common_request.go index c3cbac7..e83fa2c 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -26,3 +26,19 @@ type ClickAction struct { Type string `json:"type"` Value string `json:"value"` } + +// RequestCondition ... +type RequestCondition struct { + Code int `json:"code"` + Codes []int `json:"codes"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` + + Slug string `json:"slug"` + Slugs []string `json:"slugs"` + DistrictSlug string `json:"districtSlug"` + ProvinceSlug string `json:"provinceSlug"` + + Keyword string `json:"keyword"` + Region string `json:"region"` +} From 389a26ad6f8076bcef850a7445e2f6a187803dd8 Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Thu, 27 Oct 2022 11:30:17 +0700 Subject: [PATCH 024/103] fix get bank info --- client/bank.go | 9 +++++---- model/bank_request.go | 5 +++-- model/bank_response.go | 6 +++--- subject/bank.go | 8 ++++---- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/client/bank.go b/client/bank.go index 69e6d26..9a6fc30 100644 --- a/client/bank.go +++ b/client/bank.go @@ -17,15 +17,16 @@ func GetBank() Bank { return Bank{} } -func (s Bank) GetBankAndBranchByBankIDs(p model.GetBankAndBranchesRequest) ([]*model.ResponseBankAndBranches, error) { - msg, err := natsio.GetServer().Request(subject.Bank.GetBankAndBranchesByBankIDs, toBytes(p)) +// GetBankInfo ... +func (s Bank) GetBankInfo(p model.GetBankInfoRequest) (*model.ResponseBankInfo, error) { + msg, err := natsio.GetServer().Request(subject.Bank.GetBankInfo, toBytes(p)) if err != nil { return nil, err } var r struct { - Data []*model.ResponseBankAndBranches `json:"data"` - Error string `json:"error"` + Data *model.ResponseBankInfo `json:"data"` + Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil { diff --git a/model/bank_request.go b/model/bank_request.go index f53b794..3b76615 100644 --- a/model/bank_request.go +++ b/model/bank_request.go @@ -5,6 +5,7 @@ type CheckBankAndBranchByIDRequest struct { BranchID string `json:"branchId"` } -type GetBankAndBranchesRequest struct { - BankIDs []string `json:"bankIds"` +type GetBankInfoRequest struct { + BankID string `json:"bankId"` + BranchID string `json:"branchId"` } diff --git a/model/bank_response.go b/model/bank_response.go index 565cf21..4880d03 100644 --- a/model/bank_response.go +++ b/model/bank_response.go @@ -34,7 +34,7 @@ type BankBrief struct { Logo interface{} `json:"logo"` } -type ResponseBankAndBranches struct { - Bank BankBrief `json:"bank"` - Branches []BranchBrief `json:"branches"` +type ResponseBankInfo struct { + Bank BankBrief `json:"bank"` + Branch BranchBrief `json:"branch"` } diff --git a/subject/bank.go b/subject/bank.go index caf8fa1..601ecb4 100644 --- a/subject/bank.go +++ b/subject/bank.go @@ -7,9 +7,9 @@ func getBankValue(val string) string { } var Bank = struct { - GetBankAndBranchesByBankIDs string - CheckBankAndBranchByID string + GetBankInfo string + CheckBankAndBranchByID string }{ - GetBankAndBranchesByBankIDs: getBankValue("get_bank_and_branches_by_bank_ids"), - CheckBankAndBranchByID: getBankValue("check_bank_and_branch_by_id"), + GetBankInfo: getBankValue("get_bank_info"), + CheckBankAndBranchByID: getBankValue("check_bank_and_branch_by_id"), } From 72aaea5b878eba5a3d75bffe61d5cbd2f1d9ca88 Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Thu, 27 Oct 2022 11:58:19 +0700 Subject: [PATCH 025/103] fix get bank info --- client/bank.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/bank.go b/client/bank.go index 9a6fc30..27eac4e 100644 --- a/client/bank.go +++ b/client/bank.go @@ -18,15 +18,15 @@ func GetBank() Bank { } // GetBankInfo ... -func (s Bank) GetBankInfo(p model.GetBankInfoRequest) (*model.ResponseBankInfo, error) { +func (s Bank) GetBankInfo(p []model.GetBankInfoRequest) ([]*model.ResponseBankInfo, error) { msg, err := natsio.GetServer().Request(subject.Bank.GetBankInfo, toBytes(p)) if err != nil { return nil, err } var r struct { - Data *model.ResponseBankInfo `json:"data"` - Error string `json:"error"` + Data []*model.ResponseBankInfo `json:"data"` + Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil { From 6e5080c43096dc2ee395c818a3562837a245f3c8 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 27 Oct 2022 13:41:58 +0700 Subject: [PATCH 026/103] [location] update location client --- client/location.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/client/location.go b/client/location.go index 25f9000..7af3895 100644 --- a/client/location.go +++ b/client/location.go @@ -106,7 +106,7 @@ func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWa } // GetProvinceByCondition ... -func (l Location) GetProvinceByCondition(p model.ProvinceRequestCondition) (*model.LocationProvinceDetailResponse, error) { +func (l Location) GetProvinceByCondition(p model.RequestCondition) (*model.LocationProvinceDetailResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetProvinceByCondition, toBytes(p)) if err != nil { return nil, err @@ -128,7 +128,7 @@ func (l Location) GetProvinceByCondition(p model.ProvinceRequestCondition) (*mod } // GetProvincesByCondition ... -func (l Location) GetProvincesByCondition(p model.ProvinceRequestCondition) ([]*model.LocationProvinceDetailResponse, error) { +func (l Location) GetProvincesByCondition(p model.RequestCondition) ([]*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.ProvinceRequestCondition) ([]* } // GetDistrictByCondition ... -func (l Location) GetDistrictByCondition(p model.DistrictRequestCondition) (*model.LocationDistrictDetailResponse, error) { +func (l Location) GetDistrictByCondition(p model.RequestCondition) (*model.LocationDistrictDetailResponse, 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.DistrictRequestCondition) (*mod } // GetDistrictsByCondition ... -func (l Location) GetDistrictsByCondition(p model.DistrictRequestCondition) ([]*model.LocationDistrictDetailResponse, error) { +func (l Location) GetDistrictsByCondition(p model.RequestCondition) ([]*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.DistrictRequestCondition) ([]* } // GetWardByCondition ... -func (l Location) GetWardByCondition(p model.WardRequestCondition) (*model.LocationWardDetailResponse, error) { +func (l Location) GetWardByCondition(p model.RequestCondition) (*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.WardRequestCondition) (*model.Locat } // GetWardsByCondition ... -func (l Location) GetWardsByCondition(p model.WardRequestCondition) ([]*model.LocationWardDetailResponse, error) { +func (l Location) GetWardsByCondition(p model.RequestCondition) ([]*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.WardRequestCondition) ([]*model.Lo } // CountProvinceByCondition ... -func (l Location) CountProvinceByCondition(p model.ProvinceRequestCondition) (int64, error) { +func (l Location) CountProvinceByCondition(p model.RequestCondition) (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.ProvinceRequestCondition) (in } // CountDistrictByCondition ... -func (l Location) CountDistrictByCondition(p model.DistrictRequestCondition) (int64, error) { +func (l Location) CountDistrictByCondition(p model.RequestCondition) (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.DistrictRequestCondition) (in } // CountWardByCondition ... -func (l Location) CountWardByCondition(p model.WardRequestCondition) (int64, error) { +func (l Location) CountWardByCondition(p model.RequestCondition) (int64, error) { msg, err := natsio.GetServer().Request(subject.Location.CountWardByCondition, toBytes(p)) if err != nil { return 0, err From 0bed9a6dfbbad2d17daaedcdf87d78de82156e9e Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 27 Oct 2022 14:30:40 +0700 Subject: [PATCH 027/103] [location] refactor code --- client/location.go | 208 +++++++++++++++++++++++++++++++++++++ model/common_request.go | 16 +++ model/location_request.go | 76 +++++++++++--- model/location_response.go | 123 +++++++++++++++------- subject/location.go | 36 +++++-- 5 files changed, 399 insertions(+), 60 deletions(-) diff --git a/client/location.go b/client/location.go index 18be423..db19312 100644 --- a/client/location.go +++ b/client/location.go @@ -104,3 +104,211 @@ func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWa return r.Data, nil } + +// GetProvinceByCondition ... +func (l Location) GetProvinceByCondition(p model.RequestCondition) (*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.RequestCondition) ([]*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.RequestCondition) (*model.LocationDistrictDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetDistrictByCondition, 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 +} + +// GetDistrictsByCondition ... +func (l Location) GetDistrictsByCondition(p model.RequestCondition) ([]*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.RequestCondition) (*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.RequestCondition) ([]*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.RequestCondition) (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.RequestCondition) (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.RequestCondition) (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 +} + +// 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/common_request.go b/model/common_request.go index 0ce5163..4ffd6e1 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -20,3 +20,19 @@ type ActionBy struct { ID string `json:"id"` Name string `json:"name"` } + +// RequestCondition ... +type RequestCondition struct { + Code int `json:"code"` + Codes []int `json:"codes"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` + + Slug string `json:"slug"` + Slugs []string `json:"slugs"` + DistrictSlug string `json:"districtSlug"` + ProvinceSlug string `json:"provinceSlug"` + + Keyword string `json:"keyword"` + Region string `json:"region"` +} diff --git a/model/location_request.go b/model/location_request.go index 4533db7..e4312ce 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -1,23 +1,65 @@ 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"` + Slug string `json:"slug"` + Slugs []string `json:"slugs"` + Keyword string `json:"keyword"` + Region string `json:"region"` + } -// 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"` + Slug string `json:"slug"` + ProvinceSlug string `json:"provinceSlug"` + Keyword string `json:"keyword"` + } + + // 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"` + Slug string `json:"slug"` + DistrictSlug string `json:"districtSlug"` + ProvinceSlug string `json:"provinceSlug"` + Keyword string `json:"keyword"` + } + + // ProvinceDistinctWithField ... + ProvinceDistinctWithField struct { + Conditions struct { + Region string `json:"region"` + } `json:"conditions"` + Field string `json:"filed"` + } +) diff --git a/model/location_response.go b/model/location_response.go index 484d89e..1595908 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -1,43 +1,96 @@ 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"` + OldSlug string `json:"oldSlug"` + 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"` + OldSlug string `json:"oldSlug"` + 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"` + OldSlugs []string `json:"oldSlugs"` + 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..c625ca4 100644 --- a/subject/location.go +++ b/subject/location.go @@ -7,13 +7,33 @@ func getLocationValue(val string) string { } var Location = struct { - GetLocationByCode string - GetProvincesByCodes string - GetDistrictsByCodes string - GetWardsByCodes 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"), + 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"), } From 73e2a8a7c8fc2ad12e37cef28d0968d598aca964 Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Thu, 27 Oct 2022 15:52:39 +0700 Subject: [PATCH 028/103] get supplier freeship info --- client/supplier.go | 12 ++++++------ model/supplier_request.go | 4 ++-- model/supplier_response.go | 9 +++++---- subject/selly.go | 15 --------------- subject/supplier.go | 2 ++ 5 files changed, 15 insertions(+), 27 deletions(-) delete mode 100644 subject/selly.go diff --git a/client/supplier.go b/client/supplier.go index 5d14796..38619c1 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -119,7 +119,7 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh // GetWarehouseFreeship ... func (s Supplier) GetWarehouseFreeship() (*model.ResponseListWarehouseIDByBusinessType, error) { - msg, err := natsio.GetServer().Request(subject.Selly.GetListWarehouseFreeship, toBytes(bson.M{})) + msg, err := natsio.GetServer().Request(subject.Supplier.GetListWarehouseFreeship, toBytes(bson.M{})) if err != nil { return nil, err } @@ -139,15 +139,15 @@ func (s Supplier) GetWarehouseFreeship() (*model.ResponseListWarehouseIDByBusine return r.Data, nil } -// GetFreeshipsBySupplierIDs ... -func (s Supplier) GetFreeshipsBySupplierIDs(p model.GetFreeshipsBySupplierIds) (*model.ResponseListFreeshipsBySupplierIds, error) { - msg, err := natsio.GetServer().Request(subject.Selly.GetFreeshipsBySupplierIds, toBytes(p)) +// GetFreeShipInfo ... +func (s Supplier) GetFreeShipInfo(p []model.SupplierFreeShipInfoRequestPayload) ([]*model.SupplierFreeShipInfoResponse, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.GetFreeShipInfo, toBytes(p)) if err != nil { return nil, err } var r struct { - Data *model.ResponseListFreeshipsBySupplierIds `json:"data"` - Error string `json:"error"` + Data []*model.SupplierFreeShipInfoResponse `json:"data"` + Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err diff --git a/model/supplier_request.go b/model/supplier_request.go index c76f195..c461656 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -49,6 +49,6 @@ type SupplierCashflowCreatePayload struct { ClickAction *ClickAction `json:"clickAction"` } -type GetFreeshipsBySupplierIds struct { - SupplierIDs []string `json:"supplierIds"` +type SupplierFreeShipInfoRequestPayload struct { + SupplierID string `json:"supplierId"` } diff --git a/model/supplier_response.go b/model/supplier_response.go index aabd6f3..d1cb146 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -38,13 +38,14 @@ type SupplierCashflowCreateResponse struct { ID string `json:"id"` } -type Freeship struct { +type FreeShip struct { ID string `json:"_id"` ShortName string `json:"shortName"` MilestoneText []string `json:"milestoneText"` + Order int `json:"-"` } -type ResponseListFreeshipsBySupplierIds struct { - SupplierID string `json:"supplierId"` - Freeships []Freeship `json:"freeships"` +type SupplierFreeShipInfoResponse struct { + SupplierID string `json:"supplierId"` + FreeShip FreeShip `json:"freeShip"` } diff --git a/subject/selly.go b/subject/selly.go deleted file mode 100644 index f4b6010..0000000 --- a/subject/selly.go +++ /dev/null @@ -1,15 +0,0 @@ -package subject - -import "fmt" - -func getSellyValue(val string) string { - return fmt.Sprintf("%s.%s", prefixes.Selly, val) -} - -var Selly = struct { - GetFreeshipsBySupplierIds string - GetListWarehouseFreeship string -}{ - GetFreeshipsBySupplierIds: getSellyValue("get_freeships_by_supplier_ids"), - GetListWarehouseFreeship: getSupplierValue("get_list_warehouse_freeship"), -} diff --git a/subject/supplier.go b/subject/supplier.go index da95ef9..a581494 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -12,10 +12,12 @@ var Supplier = struct { FindAll string GetListWarehouseFreeship string CreateCashflow string + GetFreeShipInfo string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), GetListWarehouseFreeship: getSupplierValue("get_list_warehouse_freeship"), CreateCashflow: getSupplierValue("create_cashflow"), + GetFreeShipInfo: getSupplierValue("get_free_ship_info"), } From cb45dbb694526c498e0c853fd7ceb21e26ac9cd0 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 27 Oct 2022 16:03:11 +0700 Subject: [PATCH 029/103] [location] add slug to ResponseLocationAdress --- model/location_response.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/model/location_response.go b/model/location_response.go index 1595908..f0b4116 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -15,6 +15,7 @@ type ( ID string `json:"id"` Name string `json:"name"` Code int `json:"code"` + Slug string `json:"slug"` RegionCode string `json:"regionCode"` MainRegionCode string `json:"mainRegionCode"` } @@ -24,6 +25,7 @@ type ( ID string `json:"id"` Name string `json:"name"` Code int `json:"code"` + Slug string `json:"slug"` } // LocationWard ... @@ -31,6 +33,7 @@ type ( ID string `json:"id"` Name string `json:"name"` Code int `json:"code"` + Slug string `json:"slug"` } // LocationProvinceResponse ... @@ -53,7 +56,6 @@ type ( ID string `json:"_id"` Name string `json:"name"` SearchString string `json:"searchString"` - Slug string `json:"slug"` OldSlug string `json:"oldSlug"` Code int `json:"code"` CountryCode string `json:"countryCode"` @@ -70,7 +72,6 @@ type ( ID string `json:"_id"` Name string `json:"name"` SearchString string `json:"searchString"` - Slug string `json:"slug"` OldSlug string `json:"oldSlug"` Code int `json:"code"` ProvinceCode int `json:"provinceCode"` @@ -85,7 +86,6 @@ type ( ID string `json:"_id"` Name string `json:"name"` SearchString string `json:"searchString"` - Slug string `json:"slug"` OldSlugs []string `json:"oldSlugs"` Code int `json:"code"` DistrictCode int `json:"districtCode"` From 37c20ac3c7db7cf85a72320736907c5f13b7299d Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Thu, 27 Oct 2022 16:16:09 +0700 Subject: [PATCH 030/103] get supplier freeship info --- model/supplier_response.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/supplier_response.go b/model/supplier_response.go index d1cb146..77dc9f8 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -46,6 +46,6 @@ type FreeShip struct { } type SupplierFreeShipInfoResponse struct { - SupplierID string `json:"supplierId"` - FreeShip FreeShip `json:"freeShip"` + SupplierID string `json:"supplierId"` + FreeShip []FreeShip `json:"freeShip"` } From 006accb41597d6b9c74ad0c5136503a17a366acd Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Thu, 27 Oct 2022 16:29:38 +0700 Subject: [PATCH 031/103] [Update] Response warehouse --- model/warehouse_response.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/warehouse_response.go b/model/warehouse_response.go index c667290..0b6cee0 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -119,6 +119,7 @@ type CommonLocation struct { ID string `json:"id"` Name string `json:"name"` Code int `json:"code"` + Slug string `json:"slug"` } // ResponseLatLng ... From 0f4ba104796cd0f0066071049521df851ebb934a Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Thu, 27 Oct 2022 17:16:45 +0700 Subject: [PATCH 032/103] get supplier freeship info --- model/supplier_response.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/supplier_response.go b/model/supplier_response.go index 77dc9f8..48ccb80 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -47,5 +47,5 @@ type FreeShip struct { type SupplierFreeShipInfoResponse struct { SupplierID string `json:"supplierId"` - FreeShip []FreeShip `json:"freeShip"` + FreeShips []FreeShip `json:"freeShips"` } From a86003caf00a17a4626e05ce05edff6215cb8403 Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Fri, 28 Oct 2022 11:19:15 +0700 Subject: [PATCH 033/103] fix get supplier free ship info --- client/supplier.go | 10 +++++----- model/supplier_request.go | 2 +- model/supplier_response.go | 10 +++++----- subject/supplier.go | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/client/supplier.go b/client/supplier.go index 38619c1..1488a1b 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -117,15 +117,15 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh return nil } -// GetWarehouseFreeship ... -func (s Supplier) GetWarehouseFreeship() (*model.ResponseListWarehouseIDByBusinessType, error) { - msg, err := natsio.GetServer().Request(subject.Supplier.GetListWarehouseFreeship, toBytes(bson.M{})) +// GetListWarehouseFreeShip ... +func (s Supplier) GetListWarehouseFreeShip() (*model.SupplierListWarehouseFreeShipResponse, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.GetListWarehouseFreeShip, toBytes(bson.M{})) if err != nil { return nil, err } var r struct { - Data *model.ResponseListWarehouseIDByBusinessType `json:"data"` + Data *model.SupplierListWarehouseFreeShipResponse `json:"data"` Error string `json:"error"` } @@ -140,7 +140,7 @@ func (s Supplier) GetWarehouseFreeship() (*model.ResponseListWarehouseIDByBusine } // GetFreeShipInfo ... -func (s Supplier) GetFreeShipInfo(p []model.SupplierFreeShipInfoRequestPayload) ([]*model.SupplierFreeShipInfoResponse, error) { +func (s Supplier) GetFreeShipInfo(p model.SupplierFreeShipInfoRequestPayload) ([]*model.SupplierFreeShipInfoResponse, error) { msg, err := natsio.GetServer().Request(subject.Supplier.GetFreeShipInfo, toBytes(p)) if err != nil { return nil, err diff --git a/model/supplier_request.go b/model/supplier_request.go index c461656..d01c551 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -50,5 +50,5 @@ type SupplierCashflowCreatePayload struct { } type SupplierFreeShipInfoRequestPayload struct { - SupplierID string `json:"supplierId"` + SupplierID []string `json:"supplierId"` } diff --git a/model/supplier_response.go b/model/supplier_response.go index 48ccb80..7584160 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -30,7 +30,7 @@ type SupplierAll struct { Total int64 `json:"total"` } -type ResponseListWarehouseIDByBusinessType struct { +type SupplierListWarehouseFreeShipResponse struct { Warehouses []string `json:"warehouses"` } @@ -39,10 +39,10 @@ type SupplierCashflowCreateResponse struct { } type FreeShip struct { - ID string `json:"_id"` - ShortName string `json:"shortName"` - MilestoneText []string `json:"milestoneText"` - Order int `json:"-"` + ID string `json:"_id"` + ShortName string `json:"shortName"` + ListMilestoneText []string `json:"milestoneText"` + Order int `json:"-"` } type SupplierFreeShipInfoResponse struct { diff --git a/subject/supplier.go b/subject/supplier.go index a581494..12cc3ea 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -10,14 +10,14 @@ var Supplier = struct { GetListSupplierInfo string GetSupplierContractBySupplierID string FindAll string - GetListWarehouseFreeship string + GetListWarehouseFreeShip string CreateCashflow string GetFreeShipInfo string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), - GetListWarehouseFreeship: getSupplierValue("get_list_warehouse_freeship"), + GetListWarehouseFreeShip: getSupplierValue("get_list_warehouse_free_ship"), CreateCashflow: getSupplierValue("create_cashflow"), GetFreeShipInfo: getSupplierValue("get_free_ship_info"), } From 2602b22e40b2a32f2ab75ed4b045162dc40d3dcf Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Fri, 28 Oct 2022 11:39:29 +0700 Subject: [PATCH 034/103] fix get supplier free ship info --- model/supplier_request.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/supplier_request.go b/model/supplier_request.go index d01c551..17c7266 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -50,5 +50,5 @@ type SupplierCashflowCreatePayload struct { } type SupplierFreeShipInfoRequestPayload struct { - SupplierID []string `json:"supplierId"` + SupplierIDs []string `json:"supplierIds"` } From 7f03b98f90ded8fa011e92e6c097b6f7ec9efe4c Mon Sep 17 00:00:00 2001 From: Tue Date: Mon, 31 Oct 2022 10:04:13 +0700 Subject: [PATCH 035/103] build authsms --- client/supplier_permission.go | 79 +++++++++++++++++++++++++++ client/supplier_role.go | 44 ++++++++++++++- model/supplier_permission_request.go | 24 ++++++++ model/supplier_permission_response.go | 19 +++++++ model/supplier_role_request.go | 11 ++++ model/supplier_role_response.go | 14 +++++ subject/config.go | 50 +++++++++-------- subject/supplier_permission.go | 17 ++++++ subject/supplier_role.go | 14 +++-- 9 files changed, 243 insertions(+), 29 deletions(-) create mode 100644 client/supplier_permission.go create mode 100644 model/supplier_permission_request.go create mode 100644 model/supplier_permission_response.go create mode 100644 subject/supplier_permission.go diff --git a/client/supplier_permission.go b/client/supplier_permission.go new file mode 100644 index 0000000..86ac1ba --- /dev/null +++ b/client/supplier_permission.go @@ -0,0 +1,79 @@ +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" +) + +// SupplierPermission ... +type SupplierPermission struct{} + +// GetSupplierPermission ... +func GetSupplierPermission() SupplierPermission { + return SupplierPermission{} +} + +func (s SupplierPermission) GetListPermission(p model.GetListPermissionRequest) (*model.GetListPermissionResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierPermission.GetList, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.GetListPermissionResponse `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 SupplierPermission) CreatePermission(p model.CreatePermissionRequest) (*model.CreatePermissionResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierPermission.Create, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.CreatePermissionResponse `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 SupplierPermission) UpdatePermission(p model.UpdatePermissionRequest) error { + msg, err := natsio.GetServer().Request(subject.SupplierPermission.Update, 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/supplier_role.go b/client/supplier_role.go index 3bf068d..1fe6d9d 100644 --- a/client/supplier_role.go +++ b/client/supplier_role.go @@ -16,8 +16,29 @@ func GetSupplierRole() SupplierRole { return SupplierRole{} } +func (s SupplierRole) GetListRole(p model.GetListRoleRequest) (*model.GetListRoleResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierRole.GetList, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.GetListRoleResponse `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 SupplierRole) CreateRole(p model.CreateRoleRequest) (*model.CreateRoleResponse, error) { - msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.SupplierRole.Create, toBytes(p)) if err != nil { return nil, err } @@ -56,3 +77,24 @@ func (s SupplierRole) UpdateRole(p model.UpdateRoleRequest) error { return nil } + +func (s SupplierRole) DetailRole(p model.DetailRoleRequest) (*model.RoleBrief, error) { + msg, err := natsio.GetServer().Request(subject.SupplierRole.Detail, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.RoleBrief `json:"data"` + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + + return r.Data, nil +} diff --git a/model/supplier_permission_request.go b/model/supplier_permission_request.go new file mode 100644 index 0000000..e3d63c7 --- /dev/null +++ b/model/supplier_permission_request.go @@ -0,0 +1,24 @@ +package model + +type GetListPermissionRequest struct { + Page int `json:"page"` + Limit int `json:"limit"` + Group string `json:"group"` +} + +type DetailPermissionRequest struct { + ID string `json:"_id"` +} + +type CreatePermissionRequest struct { + Name string `json:"name"` + Code string `json:"code"` + Group string `json:"group"` +} + +type UpdatePermissionRequest struct { + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Group string `json:"group"` +} diff --git a/model/supplier_permission_response.go b/model/supplier_permission_response.go new file mode 100644 index 0000000..cbbb019 --- /dev/null +++ b/model/supplier_permission_response.go @@ -0,0 +1,19 @@ +package model + +type GetListPermissionResponse struct { + Permissions []PermissionBrief `json:"permissions"` + Total int64 `json:"total"` +} + +type PermissionBrief struct { + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Group string `json:"group"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` +} + +type CreatePermissionResponse struct { + ID string `json:"_id"` +} diff --git a/model/supplier_role_request.go b/model/supplier_role_request.go index 6402622..dce6112 100644 --- a/model/supplier_role_request.go +++ b/model/supplier_role_request.go @@ -1,5 +1,16 @@ package model +type GetListRoleRequest struct { + Page int `json:"page"` + Limit int `json:"limit"` + Type string `json:"type"` + SupplierID string `json:"supplierId"` +} + +type DetailRoleRequest struct { + ID string `json:"_id"` +} + type CreateRoleRequest struct { Name string `json:"name"` Code string `json:"code"` diff --git a/model/supplier_role_response.go b/model/supplier_role_response.go index d7b68fc..24fc4be 100644 --- a/model/supplier_role_response.go +++ b/model/supplier_role_response.go @@ -1,5 +1,19 @@ package model +type GetListRoleResponse struct { + Roles []RoleBrief `json:"roles"` + Total int64 `json:"total"` +} + +type RoleBrief struct { + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Type string `json:"type"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` +} + type CreateRoleResponse struct { ID string `json:"_id"` } diff --git a/subject/config.go b/subject/config.go index 71f275d..c838f87 100644 --- a/subject/config.go +++ b/subject/config.go @@ -1,29 +1,31 @@ package subject var prefixes = struct { - Communication string - Order string - News string - Warehouse string - Location string - Bank string - Supplier string - Seller string - AuthSMS string - Selly string - SupplierUser string - SupplierRole string + Communication string + Order string + News string + Warehouse string + Location string + Bank string + Supplier string + Seller string + AuthSMS string + Selly string + SupplierUser string + SupplierRole string + SupplierPermission string }{ - Communication: "communication", - Order: "order", - News: "news", - Warehouse: "warehouse", - Location: "location", - Supplier: "supplier", - Bank: "bank", - Seller: "seller", - AuthSMS: "auth_sms", - Selly: "selly", - SupplierUser: "supplier_user", - SupplierRole: "supplier_role", + Communication: "communication", + Order: "order", + News: "news", + Warehouse: "warehouse", + Location: "location", + Supplier: "supplier", + Bank: "bank", + Seller: "seller", + AuthSMS: "auth_sms", + Selly: "selly", + SupplierUser: "supplier_user", + SupplierRole: "supplier_role", + SupplierPermission: "supplier_permission", } diff --git a/subject/supplier_permission.go b/subject/supplier_permission.go new file mode 100644 index 0000000..f759a0c --- /dev/null +++ b/subject/supplier_permission.go @@ -0,0 +1,17 @@ +package subject + +import "fmt" + +func getPermissionValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.SupplierPermission, val) +} + +var SupplierPermission = struct { + GetList string + Create string + Update string +}{ + GetList: getPermissionValue("get_list"), + Create: getPermissionValue("create"), + Update: getPermissionValue("update"), +} diff --git a/subject/supplier_role.go b/subject/supplier_role.go index 8915759..83389da 100644 --- a/subject/supplier_role.go +++ b/subject/supplier_role.go @@ -7,9 +7,15 @@ func getRoleValue(val string) string { } var SupplierRole = struct { - Create string - Update string + GetList string + Detail string + Create string + Update string + GetListBySupplierID string }{ - Create: getRoleValue("create"), - Update: getRoleValue("update"), + GetList: getRoleValue("get_list"), + Detail: getRoleValue("detail"), + Create: getRoleValue("create"), + Update: getRoleValue("update"), + GetListBySupplierID: getRoleValue("get_list_by_supplierId"), } From f6a2b34a7f98ac975dff996da42c3f989ff16ade Mon Sep 17 00:00:00 2001 From: Tue Date: Mon, 31 Oct 2022 10:04:13 +0700 Subject: [PATCH 036/103] build authsms --- client/supplier_permission.go | 79 +++++++++++++++++++++++++++ client/supplier_role.go | 44 ++++++++++++++- model/supplier_permission_request.go | 24 ++++++++ model/supplier_permission_response.go | 19 +++++++ model/supplier_role_request.go | 11 ++++ model/supplier_role_response.go | 14 +++++ subject/config.go | 2 + subject/supplier_permission.go | 17 ++++++ subject/supplier_role.go | 14 +++-- 9 files changed, 219 insertions(+), 5 deletions(-) create mode 100644 client/supplier_permission.go create mode 100644 model/supplier_permission_request.go create mode 100644 model/supplier_permission_response.go create mode 100644 subject/supplier_permission.go diff --git a/client/supplier_permission.go b/client/supplier_permission.go new file mode 100644 index 0000000..86ac1ba --- /dev/null +++ b/client/supplier_permission.go @@ -0,0 +1,79 @@ +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" +) + +// SupplierPermission ... +type SupplierPermission struct{} + +// GetSupplierPermission ... +func GetSupplierPermission() SupplierPermission { + return SupplierPermission{} +} + +func (s SupplierPermission) GetListPermission(p model.GetListPermissionRequest) (*model.GetListPermissionResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierPermission.GetList, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.GetListPermissionResponse `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 SupplierPermission) CreatePermission(p model.CreatePermissionRequest) (*model.CreatePermissionResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierPermission.Create, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.CreatePermissionResponse `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 SupplierPermission) UpdatePermission(p model.UpdatePermissionRequest) error { + msg, err := natsio.GetServer().Request(subject.SupplierPermission.Update, 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/supplier_role.go b/client/supplier_role.go index 3bf068d..1fe6d9d 100644 --- a/client/supplier_role.go +++ b/client/supplier_role.go @@ -16,8 +16,29 @@ func GetSupplierRole() SupplierRole { return SupplierRole{} } +func (s SupplierRole) GetListRole(p model.GetListRoleRequest) (*model.GetListRoleResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierRole.GetList, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.GetListRoleResponse `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 SupplierRole) CreateRole(p model.CreateRoleRequest) (*model.CreateRoleResponse, error) { - msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.SupplierRole.Create, toBytes(p)) if err != nil { return nil, err } @@ -56,3 +77,24 @@ func (s SupplierRole) UpdateRole(p model.UpdateRoleRequest) error { return nil } + +func (s SupplierRole) DetailRole(p model.DetailRoleRequest) (*model.RoleBrief, error) { + msg, err := natsio.GetServer().Request(subject.SupplierRole.Detail, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.RoleBrief `json:"data"` + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + + return r.Data, nil +} diff --git a/model/supplier_permission_request.go b/model/supplier_permission_request.go new file mode 100644 index 0000000..e3d63c7 --- /dev/null +++ b/model/supplier_permission_request.go @@ -0,0 +1,24 @@ +package model + +type GetListPermissionRequest struct { + Page int `json:"page"` + Limit int `json:"limit"` + Group string `json:"group"` +} + +type DetailPermissionRequest struct { + ID string `json:"_id"` +} + +type CreatePermissionRequest struct { + Name string `json:"name"` + Code string `json:"code"` + Group string `json:"group"` +} + +type UpdatePermissionRequest struct { + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Group string `json:"group"` +} diff --git a/model/supplier_permission_response.go b/model/supplier_permission_response.go new file mode 100644 index 0000000..cbbb019 --- /dev/null +++ b/model/supplier_permission_response.go @@ -0,0 +1,19 @@ +package model + +type GetListPermissionResponse struct { + Permissions []PermissionBrief `json:"permissions"` + Total int64 `json:"total"` +} + +type PermissionBrief struct { + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Group string `json:"group"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` +} + +type CreatePermissionResponse struct { + ID string `json:"_id"` +} diff --git a/model/supplier_role_request.go b/model/supplier_role_request.go index 6402622..dce6112 100644 --- a/model/supplier_role_request.go +++ b/model/supplier_role_request.go @@ -1,5 +1,16 @@ package model +type GetListRoleRequest struct { + Page int `json:"page"` + Limit int `json:"limit"` + Type string `json:"type"` + SupplierID string `json:"supplierId"` +} + +type DetailRoleRequest struct { + ID string `json:"_id"` +} + type CreateRoleRequest struct { Name string `json:"name"` Code string `json:"code"` diff --git a/model/supplier_role_response.go b/model/supplier_role_response.go index d7b68fc..24fc4be 100644 --- a/model/supplier_role_response.go +++ b/model/supplier_role_response.go @@ -1,5 +1,19 @@ package model +type GetListRoleResponse struct { + Roles []RoleBrief `json:"roles"` + Total int64 `json:"total"` +} + +type RoleBrief struct { + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Type string `json:"type"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` +} + type CreateRoleResponse struct { ID string `json:"_id"` } diff --git a/subject/config.go b/subject/config.go index 90a014f..37e3055 100644 --- a/subject/config.go +++ b/subject/config.go @@ -11,6 +11,7 @@ var prefixes = struct { Seller string SupplierUser string SupplierRole string + SupplierPermission string }{ Communication: "communication", Order: "order", @@ -22,4 +23,5 @@ var prefixes = struct { Seller: "seller", SupplierUser: "supplier_user", SupplierRole: "supplier_role", + SupplierPermission: "supplier_permission", } diff --git a/subject/supplier_permission.go b/subject/supplier_permission.go new file mode 100644 index 0000000..f759a0c --- /dev/null +++ b/subject/supplier_permission.go @@ -0,0 +1,17 @@ +package subject + +import "fmt" + +func getPermissionValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.SupplierPermission, val) +} + +var SupplierPermission = struct { + GetList string + Create string + Update string +}{ + GetList: getPermissionValue("get_list"), + Create: getPermissionValue("create"), + Update: getPermissionValue("update"), +} diff --git a/subject/supplier_role.go b/subject/supplier_role.go index 8915759..83389da 100644 --- a/subject/supplier_role.go +++ b/subject/supplier_role.go @@ -7,9 +7,15 @@ func getRoleValue(val string) string { } var SupplierRole = struct { - Create string - Update string + GetList string + Detail string + Create string + Update string + GetListBySupplierID string }{ - Create: getRoleValue("create"), - Update: getRoleValue("update"), + GetList: getRoleValue("get_list"), + Detail: getRoleValue("detail"), + Create: getRoleValue("create"), + Update: getRoleValue("update"), + GetListBySupplierID: getRoleValue("get_list_by_supplierId"), } From 0d8e3969dbeee65d40b016638a440e720008d78a Mon Sep 17 00:00:00 2001 From: Tue Date: Mon, 31 Oct 2022 16:59:38 +0700 Subject: [PATCH 037/103] build auth sms --- model/supplier_role_request.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/model/supplier_role_request.go b/model/supplier_role_request.go index dce6112..3629643 100644 --- a/model/supplier_role_request.go +++ b/model/supplier_role_request.go @@ -12,14 +12,16 @@ type DetailRoleRequest struct { } type CreateRoleRequest struct { - Name string `json:"name"` - Code string `json:"code"` - Type string `json:"type"` + Name string `json:"name"` + Code string `json:"code"` + Type string `json:"type"` + Permissions []string `json:"permissions"` } type UpdateRoleRequest struct { - ID string `json:"_id"` - Name string `json:"name"` - Code string `json:"code"` - Type string `json:"type"` + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Type string `json:"type"` + Permissions []string `json:"permissions"` } From 645effaa04988b56b8bde1ead8de93857941dc0a Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 1 Nov 2022 10:43:20 +0700 Subject: [PATCH 038/103] build authsms --- client/supplier_user.go | 21 +++++++++++++++++++++ model/supplier_response.go | 6 ++++++ model/supplier_user_request.go | 7 +++++++ model/supplier_user_response.go | 19 +++++++++++++++++++ subject/supplier_user.go | 2 ++ 5 files changed, 55 insertions(+) diff --git a/client/supplier_user.go b/client/supplier_user.go index fb6a2db..16eb55a 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -16,6 +16,27 @@ func GetSupplierUser() SupplierUser { return SupplierUser{} } +func (s SupplierUser) GetListOwner(p model.GetListOwnerRequest) (*model.GetListOwnerResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.GetListOwner, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.GetListOwnerResponse `json:"data"` + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + + return r.Data, nil +} + func (s SupplierUser) CreateSupplierOwnerUsers(p model.CreateOwnerRequest) (*model.CreateOwnerResponse, error) { msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p)) if err != nil { diff --git a/model/supplier_response.go b/model/supplier_response.go index 7584160..dc10c0f 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -49,3 +49,9 @@ type SupplierFreeShipInfoResponse struct { SupplierID string `json:"supplierId"` FreeShips []FreeShip `json:"freeShips"` } + +type SupplierShort struct { + ID string `json:"_id"` + Name string `json:"name"` + Logo interface{} `json:"logo"` +} diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 66ccb17..9c6aca1 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -1,5 +1,12 @@ package model +type GetListOwnerRequest struct { + Page int `json:"page"` + Limit int `json:"limit"` + Status string `json:"status"` + SupplierID string `json:"supplierId"` +} + type CreateOwnerRequest struct { Name string `json:"name"` Phone string `json:"phone"` diff --git a/model/supplier_user_response.go b/model/supplier_user_response.go index 38a1d0c..a70957a 100644 --- a/model/supplier_user_response.go +++ b/model/supplier_user_response.go @@ -1,5 +1,24 @@ package model +type GetListOwnerResponse struct { + SupplierUsers []SupplierUserBrief `json:"supplierUsers"` + Total int64 `json:"total"` +} + +type SupplierUserBrief struct { + ID string `json:"_id"` + Role RoleBrief `json:"role"` + Supplier SupplierShort `json:"supplier"` + Name string `json:"name"` + Phone string `json:"phone"` + Email string `json:"email"` + Status string `json:"status"` + Avatar interface{} `json:"avatar"` + Type string `json:"type"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` +} + type CreateOwnerResponse struct { ID string `json:"_id"` } diff --git a/subject/supplier_user.go b/subject/supplier_user.go index adc2f1f..2f0e166 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -8,6 +8,7 @@ func getSupplierUserValue(val string) string { var SupplierUser = struct { // Users + GetListOwner string CreateOwner string UpdateOwner string CreateStaff string @@ -16,6 +17,7 @@ var SupplierUser = struct { ResetPassword string }{ // Users + GetListOwner: getSupplierUserValue("get_list_owner"), CreateOwner: getSupplierUserValue("create_owner"), UpdateOwner: getSupplierUserValue("update_owner"), CreateStaff: getSupplierUserValue("create_staff"), From 56d210bf2d2fffc0e3d5a34bc1f8b042e818d194 Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 1 Nov 2022 10:43:20 +0700 Subject: [PATCH 039/103] build auth sms --- client/supplier_user.go | 21 +++++++++++++++++++++ model/supplier_response.go | 6 ++++++ model/supplier_user_request.go | 7 +++++++ model/supplier_user_response.go | 19 +++++++++++++++++++ subject/supplier_user.go | 2 ++ 5 files changed, 55 insertions(+) diff --git a/client/supplier_user.go b/client/supplier_user.go index fb6a2db..16eb55a 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -16,6 +16,27 @@ func GetSupplierUser() SupplierUser { return SupplierUser{} } +func (s SupplierUser) GetListOwner(p model.GetListOwnerRequest) (*model.GetListOwnerResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.GetListOwner, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.GetListOwnerResponse `json:"data"` + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + + return r.Data, nil +} + func (s SupplierUser) CreateSupplierOwnerUsers(p model.CreateOwnerRequest) (*model.CreateOwnerResponse, error) { msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p)) if err != nil { diff --git a/model/supplier_response.go b/model/supplier_response.go index 975a8de..4df67b7 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -29,3 +29,9 @@ type SupplierAll struct { Suppliers []SupplierBrief `json:"suppliers"` Total int64 `json:"total"` } + +type SupplierShort struct { + ID string `json:"_id"` + Name string `json:"name"` + Logo interface{} `json:"logo"` +} \ No newline at end of file diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 66ccb17..9c6aca1 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -1,5 +1,12 @@ package model +type GetListOwnerRequest struct { + Page int `json:"page"` + Limit int `json:"limit"` + Status string `json:"status"` + SupplierID string `json:"supplierId"` +} + type CreateOwnerRequest struct { Name string `json:"name"` Phone string `json:"phone"` diff --git a/model/supplier_user_response.go b/model/supplier_user_response.go index 38a1d0c..a70957a 100644 --- a/model/supplier_user_response.go +++ b/model/supplier_user_response.go @@ -1,5 +1,24 @@ package model +type GetListOwnerResponse struct { + SupplierUsers []SupplierUserBrief `json:"supplierUsers"` + Total int64 `json:"total"` +} + +type SupplierUserBrief struct { + ID string `json:"_id"` + Role RoleBrief `json:"role"` + Supplier SupplierShort `json:"supplier"` + Name string `json:"name"` + Phone string `json:"phone"` + Email string `json:"email"` + Status string `json:"status"` + Avatar interface{} `json:"avatar"` + Type string `json:"type"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` +} + type CreateOwnerResponse struct { ID string `json:"_id"` } diff --git a/subject/supplier_user.go b/subject/supplier_user.go index adc2f1f..2f0e166 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -8,6 +8,7 @@ func getSupplierUserValue(val string) string { var SupplierUser = struct { // Users + GetListOwner string CreateOwner string UpdateOwner string CreateStaff string @@ -16,6 +17,7 @@ var SupplierUser = struct { ResetPassword string }{ // Users + GetListOwner: getSupplierUserValue("get_list_owner"), CreateOwner: getSupplierUserValue("create_owner"), UpdateOwner: getSupplierUserValue("update_owner"), CreateStaff: getSupplierUserValue("create_staff"), From 285ddb75e7958c72debff933d2549ebf27b8da98 Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 1 Nov 2022 11:40:37 +0700 Subject: [PATCH 040/103] build auth sms --- model/supplier_role_response.go | 7 +++++++ model/supplier_user_response.go | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/model/supplier_role_response.go b/model/supplier_role_response.go index 24fc4be..cebc081 100644 --- a/model/supplier_role_response.go +++ b/model/supplier_role_response.go @@ -17,3 +17,10 @@ type RoleBrief struct { type CreateRoleResponse struct { ID string `json:"_id"` } + +type RoleShort struct { + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Type string `json:"type"` +} diff --git a/model/supplier_user_response.go b/model/supplier_user_response.go index a70957a..40549bc 100644 --- a/model/supplier_user_response.go +++ b/model/supplier_user_response.go @@ -6,17 +6,17 @@ type GetListOwnerResponse struct { } type SupplierUserBrief struct { - ID string `json:"_id"` - Role RoleBrief `json:"role"` - Supplier SupplierShort `json:"supplier"` - Name string `json:"name"` - Phone string `json:"phone"` - Email string `json:"email"` - Status string `json:"status"` - Avatar interface{} `json:"avatar"` - Type string `json:"type"` - CreatedAt string `json:"createdAt"` - UpdatedAt string `json:"updatedAt"` + ID string `json:"_id"` + Role RoleShort `json:"role"` + SupplierID string `json:"supplierId"` + Name string `json:"name"` + Phone string `json:"phone"` + Email string `json:"email"` + Status string `json:"status"` + Avatar interface{} `json:"avatar"` + Type string `json:"type"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` } type CreateOwnerResponse struct { From cdbbf9fc738d771c77dd8305145c00aff1f07e22 Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 2 Nov 2022 14:56:58 +0700 Subject: [PATCH 041/103] build auth sms --- client/supplier_role.go | 1 - model/supplier_permission_response.go | 7 +++++++ model/supplier_role_request.go | 2 ++ model/supplier_role_response.go | 23 +++++++++++++---------- model/supplier_user_request.go | 1 + 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/client/supplier_role.go b/client/supplier_role.go index 1fe6d9d..095f3e9 100644 --- a/client/supplier_role.go +++ b/client/supplier_role.go @@ -26,7 +26,6 @@ func (s SupplierRole) GetListRole(p model.GetListRoleRequest) (*model.GetListRol Data *model.GetListRoleResponse `json:"data"` Error string `json:"error"` } - if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err } diff --git a/model/supplier_permission_response.go b/model/supplier_permission_response.go index cbbb019..8134201 100644 --- a/model/supplier_permission_response.go +++ b/model/supplier_permission_response.go @@ -17,3 +17,10 @@ type PermissionBrief struct { type CreatePermissionResponse struct { ID string `json:"_id"` } + +type PermissionShort struct { + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Group string `json:"group"` +} diff --git a/model/supplier_role_request.go b/model/supplier_role_request.go index 3629643..ee12d59 100644 --- a/model/supplier_role_request.go +++ b/model/supplier_role_request.go @@ -15,6 +15,7 @@ type CreateRoleRequest struct { Name string `json:"name"` Code string `json:"code"` Type string `json:"type"` + SupplierID string `json:"supplierId"` Permissions []string `json:"permissions"` } @@ -23,5 +24,6 @@ type UpdateRoleRequest struct { Name string `json:"name"` Code string `json:"code"` Type string `json:"type"` + SupplierID string `json:"supplierId"` Permissions []string `json:"permissions"` } diff --git a/model/supplier_role_response.go b/model/supplier_role_response.go index cebc081..b67a0c6 100644 --- a/model/supplier_role_response.go +++ b/model/supplier_role_response.go @@ -6,12 +6,14 @@ type GetListRoleResponse struct { } type RoleBrief struct { - ID string `json:"_id"` - Name string `json:"name"` - Code string `json:"code"` - Type string `json:"type"` - CreatedAt string `json:"createdAt"` - UpdatedAt string `json:"updatedAt"` + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Type string `json:"type"` + Permissions []PermissionShort `json:"permissions"` + SupplierId string `json:"supplierId"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` } type CreateRoleResponse struct { @@ -19,8 +21,9 @@ type CreateRoleResponse struct { } type RoleShort struct { - ID string `json:"_id"` - Name string `json:"name"` - Code string `json:"code"` - Type string `json:"type"` + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Type string `json:"type"` + SupplierId string `json:"supplierId"` } diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 9c6aca1..6bb81a0 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -4,6 +4,7 @@ type GetListOwnerRequest struct { Page int `json:"page"` Limit int `json:"limit"` Status string `json:"status"` + Type string `json:"type"` SupplierID string `json:"supplierId"` } From 19349b9813208d90ccc861129c778d290e08a695 Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 2 Nov 2022 14:56:58 +0700 Subject: [PATCH 042/103] build auth sms --- client/supplier_role.go | 1 - model/supplier_permission_response.go | 7 +++++++ model/supplier_role_request.go | 2 ++ model/supplier_role_response.go | 23 +++++++++++++---------- model/supplier_user_request.go | 1 + 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/client/supplier_role.go b/client/supplier_role.go index 1fe6d9d..095f3e9 100644 --- a/client/supplier_role.go +++ b/client/supplier_role.go @@ -26,7 +26,6 @@ func (s SupplierRole) GetListRole(p model.GetListRoleRequest) (*model.GetListRol Data *model.GetListRoleResponse `json:"data"` Error string `json:"error"` } - if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err } diff --git a/model/supplier_permission_response.go b/model/supplier_permission_response.go index cbbb019..8134201 100644 --- a/model/supplier_permission_response.go +++ b/model/supplier_permission_response.go @@ -17,3 +17,10 @@ type PermissionBrief struct { type CreatePermissionResponse struct { ID string `json:"_id"` } + +type PermissionShort struct { + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Group string `json:"group"` +} diff --git a/model/supplier_role_request.go b/model/supplier_role_request.go index 3629643..ee12d59 100644 --- a/model/supplier_role_request.go +++ b/model/supplier_role_request.go @@ -15,6 +15,7 @@ type CreateRoleRequest struct { Name string `json:"name"` Code string `json:"code"` Type string `json:"type"` + SupplierID string `json:"supplierId"` Permissions []string `json:"permissions"` } @@ -23,5 +24,6 @@ type UpdateRoleRequest struct { Name string `json:"name"` Code string `json:"code"` Type string `json:"type"` + SupplierID string `json:"supplierId"` Permissions []string `json:"permissions"` } diff --git a/model/supplier_role_response.go b/model/supplier_role_response.go index cebc081..b67a0c6 100644 --- a/model/supplier_role_response.go +++ b/model/supplier_role_response.go @@ -6,12 +6,14 @@ type GetListRoleResponse struct { } type RoleBrief struct { - ID string `json:"_id"` - Name string `json:"name"` - Code string `json:"code"` - Type string `json:"type"` - CreatedAt string `json:"createdAt"` - UpdatedAt string `json:"updatedAt"` + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Type string `json:"type"` + Permissions []PermissionShort `json:"permissions"` + SupplierId string `json:"supplierId"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` } type CreateRoleResponse struct { @@ -19,8 +21,9 @@ type CreateRoleResponse struct { } type RoleShort struct { - ID string `json:"_id"` - Name string `json:"name"` - Code string `json:"code"` - Type string `json:"type"` + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Type string `json:"type"` + SupplierId string `json:"supplierId"` } diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 9c6aca1..6bb81a0 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -4,6 +4,7 @@ type GetListOwnerRequest struct { Page int `json:"page"` Limit int `json:"limit"` Status string `json:"status"` + Type string `json:"type"` SupplierID string `json:"supplierId"` } From 55e3c07cf6e8a3da9a9c944dc49018ba6bb0b959 Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 2 Nov 2022 16:49:12 +0700 Subject: [PATCH 043/103] build auth sms --- client/supplier_user.go | 21 +++++++++++++++++++++ model/supplier_user_request.go | 17 +++++++++++++++++ model/supplier_user_response.go | 8 ++++++++ subject/supplier_user.go | 2 ++ 4 files changed, 48 insertions(+) diff --git a/client/supplier_user.go b/client/supplier_user.go index 16eb55a..d2cf98d 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -16,6 +16,27 @@ func GetSupplierUser() SupplierUser { return SupplierUser{} } +func (s SupplierUser) LoginUser(p model.LoginUserRequest) (*model.LoginUserResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.LoginUser, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.LoginUserResponse `json:"data"` + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + + return r.Data, nil +} + func (s SupplierUser) GetListOwner(p model.GetListOwnerRequest) (*model.GetListOwnerResponse, error) { msg, err := natsio.GetServer().Request(subject.SupplierUser.GetListOwner, toBytes(p)) if err != nil { diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 6bb81a0..0c5f69a 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -1,5 +1,22 @@ package model +type LoginUserRequest struct { + Email string `json:"email"` + Password string `json:"password"` + DeviceID string `json:"deviceId"` + AppVersion string `json:"appVersion"` + UserAgent string `json:"userAgent"` + Model string `json:"model"` + Manufacturer string `json:"manufacturer"` + IP string `json:"ip"` + Language string `json:"language"` + FCMToken string `json:"FCMToken"` + AuthToken string `json:"authToken"` + OsName string `json:"osName"` + OsVersion string `json:"osVersion"` + IsMobile bool `json:"isMobile"` +} + type GetListOwnerRequest struct { Page int `json:"page"` Limit int `json:"limit"` diff --git a/model/supplier_user_response.go b/model/supplier_user_response.go index 40549bc..5ccd787 100644 --- a/model/supplier_user_response.go +++ b/model/supplier_user_response.go @@ -1,5 +1,13 @@ package model +// LoginUserResponse ... +type LoginUserResponse struct { + ID string `json:"_id"` + Token string `json:"token"` + RequireToChangePassword bool `json:"requireToChangePassword"` + SupplierID string `json:"supplierId"` +} + type GetListOwnerResponse struct { SupplierUsers []SupplierUserBrief `json:"supplierUsers"` Total int64 `json:"total"` diff --git a/subject/supplier_user.go b/subject/supplier_user.go index 2f0e166..d7b21fa 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -8,6 +8,7 @@ func getSupplierUserValue(val string) string { var SupplierUser = struct { // Users + LoginUser string GetListOwner string CreateOwner string UpdateOwner string @@ -17,6 +18,7 @@ var SupplierUser = struct { ResetPassword string }{ // Users + LoginUser: getSupplierUserValue("login_user"), GetListOwner: getSupplierUserValue("get_list_owner"), CreateOwner: getSupplierUserValue("create_owner"), UpdateOwner: getSupplierUserValue("update_owner"), From 816316b558a502d2a8295ac92f15e7577ad573a4 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 2 Nov 2022 17:18:11 +0700 Subject: [PATCH 044/103] define nats func - get supplier order cash and supplier withdraw cash --- model/order_request.go | 4 ++++ model/order_response.go | 6 ++++++ model/withdraw_request.go | 5 +++++ model/withdraw_response.go | 7 +++++++ subject/config.go | 2 ++ subject/order.go | 2 ++ subject/withdraw.go | 13 +++++++++++++ 7 files changed, 39 insertions(+) create mode 100644 model/withdraw_request.go create mode 100644 model/withdraw_response.go create mode 100644 subject/withdraw.go diff --git a/model/order_request.go b/model/order_request.go index bd1fa73..a0ff6ee 100644 --- a/model/order_request.go +++ b/model/order_request.go @@ -49,3 +49,7 @@ type OrderSupplierQuery struct { SupplierID string `json:"supplierId"` WarehouseIDs []string `json:"warehouseIDs"` } + +type OrderSupplierCashReq struct { + SupplierID string `json:"supplierId"` +} diff --git a/model/order_response.go b/model/order_response.go index c08f87a..59b80d3 100644 --- a/model/order_response.go +++ b/model/order_response.go @@ -33,3 +33,9 @@ type SupplierOrderDelivery struct { 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"` } + +type OrderSupplierCashRes struct { + PendingCash float64 `json:"pendingCash"` + WaitingForReconcileCash float64 `json:"waitingForReconcileCash"` + ReconciledCash float64 `json:"reconciledCash"` +} diff --git a/model/withdraw_request.go b/model/withdraw_request.go new file mode 100644 index 0000000..7eb4a3f --- /dev/null +++ b/model/withdraw_request.go @@ -0,0 +1,5 @@ +package model + +type WithdrawSupplierCashReq struct { + SupplierID string `json:"supplierId"` +} diff --git a/model/withdraw_response.go b/model/withdraw_response.go new file mode 100644 index 0000000..9c5adc5 --- /dev/null +++ b/model/withdraw_response.go @@ -0,0 +1,7 @@ +package model + +type WithdrawSupplierCashRes struct { + PendingCash float64 `json:"pendingCash"` + SuccessCash float64 `json:"successCash"` + RejectCash float64 `json:"rejectCash"` +} diff --git a/subject/config.go b/subject/config.go index 90a014f..d428e4f 100644 --- a/subject/config.go +++ b/subject/config.go @@ -11,6 +11,7 @@ var prefixes = struct { Seller string SupplierUser string SupplierRole string + Withdraw string }{ Communication: "communication", Order: "order", @@ -22,4 +23,5 @@ var prefixes = struct { Seller: "seller", SupplierUser: "supplier_user", SupplierRole: "supplier_role", + Withdraw: "withdraw", } diff --git a/subject/order.go b/subject/order.go index 017f2be..e24e193 100644 --- a/subject/order.go +++ b/subject/order.go @@ -13,6 +13,7 @@ var Order = struct { UpdateLogisticInfoFailed string ORNotUpdateStatus string GetSupplierOrders string + GetSupplierCash string }{ UpdateORStatus: getOrderValue("update_outbound_request_status"), CancelDelivery: getOrderValue("cancel_delivery"), @@ -20,4 +21,5 @@ var Order = struct { UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"), ORNotUpdateStatus: getOrderValue("outbound_request_not_update_status"), GetSupplierOrders: getOrderValue("get_supplier_orders"), + GetSupplierCash: getOrderValue("get_supplier_cash"), } diff --git a/subject/withdraw.go b/subject/withdraw.go new file mode 100644 index 0000000..08f9a87 --- /dev/null +++ b/subject/withdraw.go @@ -0,0 +1,13 @@ +package subject + +import "fmt" + +func getWithdrawValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Withdraw, val) +} + +var Withdraw = struct { + GetSupplierCash string +}{ + GetSupplierCash: getWithdrawValue("get_supplier_cash"), +} From ac1ec030dbe32db81f8ef8dba2e7fdf398e008e0 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 2 Nov 2022 17:27:10 +0700 Subject: [PATCH 045/103] define nats func - get supplier order cash and supplier withdraw cash --- client/order.go | 21 +++++++++++++++++++++ client/withdraw.go | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 client/withdraw.go diff --git a/client/order.go b/client/order.go index a6ab736..a49c68b 100644 --- a/client/order.go +++ b/client/order.go @@ -119,3 +119,24 @@ func (o Order) GetSupplierOrders(p model.OrderSupplierQuery) (*model.SupplierOrd } return &r.Data, nil } + +// GetSupplierCash ... +func (o Order) GetSupplierCash(p model.OrderSupplierCashReq) (*model.OrderSupplierCashRes, error) { + msg, err := natsio.GetServer().Request(subject.Order.GetSupplierCash, toBytes(p)) + if err != nil { + return nil, err + } + var ( + r struct { + Data model.OrderSupplierCashRes `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/withdraw.go b/client/withdraw.go new file mode 100644 index 0000000..006d7a7 --- /dev/null +++ b/client/withdraw.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" +) + +// Withdraw ... +type Withdraw struct{} + +// GetWithdraw ... +func GetWithdraw() Withdraw { + return Withdraw{} +} + +// GetSupplierCash ... +func (o Withdraw) GetSupplierCash(p model.WithdrawSupplierCashReq) (*model.WithdrawSupplierCashRes, error) { + msg, err := natsio.GetServer().Request(subject.Withdraw.GetSupplierCash, toBytes(p)) + if err != nil { + return nil, err + } + var ( + r struct { + Data model.WithdrawSupplierCashRes `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 +} From 49426e322ceab645a6167aaab6fb46ce68feeac0 Mon Sep 17 00:00:00 2001 From: Tue Date: Thu, 3 Nov 2022 00:17:49 +0700 Subject: [PATCH 046/103] build auth sms --- model/supplier_device_request.go | 1 + model/supplier_device_response.go | 1 + model/supplier_user_response.go | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 model/supplier_device_request.go create mode 100644 model/supplier_device_response.go diff --git a/model/supplier_device_request.go b/model/supplier_device_request.go new file mode 100644 index 0000000..8b53790 --- /dev/null +++ b/model/supplier_device_request.go @@ -0,0 +1 @@ +package model diff --git a/model/supplier_device_response.go b/model/supplier_device_response.go new file mode 100644 index 0000000..8b53790 --- /dev/null +++ b/model/supplier_device_response.go @@ -0,0 +1 @@ +package model diff --git a/model/supplier_user_response.go b/model/supplier_user_response.go index 5ccd787..5f59100 100644 --- a/model/supplier_user_response.go +++ b/model/supplier_user_response.go @@ -3,7 +3,6 @@ package model // LoginUserResponse ... type LoginUserResponse struct { ID string `json:"_id"` - Token string `json:"token"` RequireToChangePassword bool `json:"requireToChangePassword"` SupplierID string `json:"supplierId"` } From 6cade7d1336d54bfef374df0fb50ff2a4267e969 Mon Sep 17 00:00:00 2001 From: Tue Date: Thu, 3 Nov 2022 10:46:56 +0700 Subject: [PATCH 047/103] build auth sms --- client/supplier_user.go | 10 +++++----- model/supplier_user_request.go | 5 ++--- model/supplier_user_response.go | 2 +- subject/supplier_user.go | 4 ++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/client/supplier_user.go b/client/supplier_user.go index d2cf98d..2a1939a 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -37,15 +37,15 @@ func (s SupplierUser) LoginUser(p model.LoginUserRequest) (*model.LoginUserRespo return r.Data, nil } -func (s SupplierUser) GetListOwner(p model.GetListOwnerRequest) (*model.GetListOwnerResponse, error) { - msg, err := natsio.GetServer().Request(subject.SupplierUser.GetListOwner, toBytes(p)) +func (s SupplierUser) GetListUser(p model.GetListUserRequest) (*model.GetListUserResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.GetListUser, toBytes(p)) if err != nil { return nil, err } var r struct { - Data *model.GetListOwnerResponse `json:"data"` - Error string `json:"error"` + Data *model.GetListUserResponse `json:"data"` + Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil { @@ -141,7 +141,7 @@ func (s SupplierUser) UpdateSupplierStaffUsers(p model.UpdateStaffRequest) error } func (s SupplierUser) UpdateStatus(p model.UpdateStatusRequest) error { - msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateStaff, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateStatus, toBytes(p)) if err != nil { return err } diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 0c5f69a..32c148f 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -17,7 +17,7 @@ type LoginUserRequest struct { IsMobile bool `json:"isMobile"` } -type GetListOwnerRequest struct { +type GetListUserRequest struct { Page int `json:"page"` Limit int `json:"limit"` Status string `json:"status"` @@ -71,6 +71,5 @@ type UpdateStatusRequest struct { } type ResetPasswordRequest struct { - ID string `json:"_id"` - Password string `json:"password"` + ID string `json:"_id"` } diff --git a/model/supplier_user_response.go b/model/supplier_user_response.go index 5f59100..01826ce 100644 --- a/model/supplier_user_response.go +++ b/model/supplier_user_response.go @@ -7,7 +7,7 @@ type LoginUserResponse struct { SupplierID string `json:"supplierId"` } -type GetListOwnerResponse struct { +type GetListUserResponse struct { SupplierUsers []SupplierUserBrief `json:"supplierUsers"` Total int64 `json:"total"` } diff --git a/subject/supplier_user.go b/subject/supplier_user.go index d7b21fa..2ad5b4d 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -9,7 +9,7 @@ func getSupplierUserValue(val string) string { var SupplierUser = struct { // Users LoginUser string - GetListOwner string + GetListUser string CreateOwner string UpdateOwner string CreateStaff string @@ -19,7 +19,7 @@ var SupplierUser = struct { }{ // Users LoginUser: getSupplierUserValue("login_user"), - GetListOwner: getSupplierUserValue("get_list_owner"), + GetListUser: getSupplierUserValue("get_list_user"), CreateOwner: getSupplierUserValue("create_owner"), UpdateOwner: getSupplierUserValue("update_owner"), CreateStaff: getSupplierUserValue("create_staff"), From 9407b2df6bf257cb9317340080b77e566d02e6b8 Mon Sep 17 00:00:00 2001 From: Tue Date: Thu, 3 Nov 2022 10:46:56 +0700 Subject: [PATCH 048/103] build auth sms --- client/supplier_user.go | 10 +++++----- model/supplier_user_request.go | 5 ++--- model/supplier_user_response.go | 2 +- subject/supplier_user.go | 4 ++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/client/supplier_user.go b/client/supplier_user.go index d2cf98d..2a1939a 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -37,15 +37,15 @@ func (s SupplierUser) LoginUser(p model.LoginUserRequest) (*model.LoginUserRespo return r.Data, nil } -func (s SupplierUser) GetListOwner(p model.GetListOwnerRequest) (*model.GetListOwnerResponse, error) { - msg, err := natsio.GetServer().Request(subject.SupplierUser.GetListOwner, toBytes(p)) +func (s SupplierUser) GetListUser(p model.GetListUserRequest) (*model.GetListUserResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.GetListUser, toBytes(p)) if err != nil { return nil, err } var r struct { - Data *model.GetListOwnerResponse `json:"data"` - Error string `json:"error"` + Data *model.GetListUserResponse `json:"data"` + Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil { @@ -141,7 +141,7 @@ func (s SupplierUser) UpdateSupplierStaffUsers(p model.UpdateStaffRequest) error } func (s SupplierUser) UpdateStatus(p model.UpdateStatusRequest) error { - msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateStaff, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateStatus, toBytes(p)) if err != nil { return err } diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 0c5f69a..32c148f 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -17,7 +17,7 @@ type LoginUserRequest struct { IsMobile bool `json:"isMobile"` } -type GetListOwnerRequest struct { +type GetListUserRequest struct { Page int `json:"page"` Limit int `json:"limit"` Status string `json:"status"` @@ -71,6 +71,5 @@ type UpdateStatusRequest struct { } type ResetPasswordRequest struct { - ID string `json:"_id"` - Password string `json:"password"` + ID string `json:"_id"` } diff --git a/model/supplier_user_response.go b/model/supplier_user_response.go index 5f59100..01826ce 100644 --- a/model/supplier_user_response.go +++ b/model/supplier_user_response.go @@ -7,7 +7,7 @@ type LoginUserResponse struct { SupplierID string `json:"supplierId"` } -type GetListOwnerResponse struct { +type GetListUserResponse struct { SupplierUsers []SupplierUserBrief `json:"supplierUsers"` Total int64 `json:"total"` } diff --git a/subject/supplier_user.go b/subject/supplier_user.go index d7b21fa..2ad5b4d 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -9,7 +9,7 @@ func getSupplierUserValue(val string) string { var SupplierUser = struct { // Users LoginUser string - GetListOwner string + GetListUser string CreateOwner string UpdateOwner string CreateStaff string @@ -19,7 +19,7 @@ var SupplierUser = struct { }{ // Users LoginUser: getSupplierUserValue("login_user"), - GetListOwner: getSupplierUserValue("get_list_owner"), + GetListUser: getSupplierUserValue("get_list_user"), CreateOwner: getSupplierUserValue("create_owner"), UpdateOwner: getSupplierUserValue("update_owner"), CreateStaff: getSupplierUserValue("create_staff"), From 634239a9f1e99a24fb488f99d9803878f7752406 Mon Sep 17 00:00:00 2001 From: Tue Date: Thu, 3 Nov 2022 11:35:23 +0700 Subject: [PATCH 049/103] build auth sms --- model/supplier_user_request.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 32c148f..84afd1d 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -31,7 +31,6 @@ type CreateOwnerRequest struct { Email string `json:"email"` SupplierID string `json:"supplierId"` RoleID string `json:"roleId"` - Password string `json:"password"` } type UpdateOwnerRequest struct { @@ -49,7 +48,6 @@ type CreateStaffRequest struct { Email string `json:"email"` SupplierID string `json:"supplierId"` RoleID string `json:"roleId"` - Password string `json:"password"` Warehouses []string `json:"warehouses"` } From b4811f091e78472afe8158bcc913fbacfd63adf6 Mon Sep 17 00:00:00 2001 From: Tue Date: Thu, 3 Nov 2022 11:35:23 +0700 Subject: [PATCH 050/103] build auth sms --- model/supplier_user_request.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 32c148f..84afd1d 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -31,7 +31,6 @@ type CreateOwnerRequest struct { Email string `json:"email"` SupplierID string `json:"supplierId"` RoleID string `json:"roleId"` - Password string `json:"password"` } type UpdateOwnerRequest struct { @@ -49,7 +48,6 @@ type CreateStaffRequest struct { Email string `json:"email"` SupplierID string `json:"supplierId"` RoleID string `json:"roleId"` - Password string `json:"password"` Warehouses []string `json:"warehouses"` } From 32e93323b7891774757ababf58974ae571a143b0 Mon Sep 17 00:00:00 2001 From: Tue Date: Thu, 3 Nov 2022 14:14:25 +0700 Subject: [PATCH 051/103] build auth sms --- model/supplier_user_response.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/supplier_user_response.go b/model/supplier_user_response.go index 01826ce..af13f88 100644 --- a/model/supplier_user_response.go +++ b/model/supplier_user_response.go @@ -5,6 +5,7 @@ type LoginUserResponse struct { ID string `json:"_id"` RequireToChangePassword bool `json:"requireToChangePassword"` SupplierID string `json:"supplierId"` + Name string `json:"name"` } type GetListUserResponse struct { From aeec88129921191e9060e24da116f369d61fb832 Mon Sep 17 00:00:00 2001 From: Sinh Date: Thu, 3 Nov 2022 16:02:43 +0700 Subject: [PATCH 052/103] define nats func - supplier balance --- client/supplier.go | 53 ++++++++++++++++++++++++++++++++++++++ model/supplier_request.go | 12 +++++++++ model/supplier_response.go | 19 +++++++++++++- subject/supplier.go | 6 +++++ 4 files changed, 89 insertions(+), 1 deletion(-) diff --git a/client/supplier.go b/client/supplier.go index f742f94..f861048 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -155,3 +155,56 @@ func (s Supplier) CreateCashflow(p model.SupplierCashflowCreatePayload) (*model. } return r.Data, nil } + +func (s Supplier) UpdateBalance(p model.SupplierUpdateBalanceReq) (*model.SupplierUpdateBalanceRes, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.UpdateBalance, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Error string `json:"error"` + Data *model.SupplierUpdateBalanceRes `json:"data"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + return r.Data, nil +} + +func (s Supplier) GetCurrentBalance(p model.SupplierGetCurrentBalanceReq) (*model.SupplierGetCurrentBalanceRes, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.GetCurrentBalance, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Error string `json:"error"` + Data *model.SupplierGetCurrentBalanceRes `json:"data"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + return r.Data, nil +} + +func (s Supplier) DeleteCashflow(p model.SupplierDeleteCashflowReq) error { + msg, err := natsio.GetServer().Request(subject.Supplier.DeleteCashflow, 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 0a4b6fa..745eafa 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -48,3 +48,15 @@ type SupplierCashflowCreatePayload struct { Value float64 `json:"value"` ClickAction *ClickAction `json:"clickAction"` } + +type SupplierUpdateBalanceReq struct { + SupplierID string `json:"supplierId"` +} + +type SupplierGetCurrentBalanceReq struct { + SupplierID string `json:"supplierId"` +} + +type SupplierDeleteCashflowReq struct { + CashflowID string `json:"cashflowId"` +} diff --git a/model/supplier_response.go b/model/supplier_response.go index ad0c0dd..83fec77 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -38,4 +38,21 @@ type SupplierShort struct { ID string `json:"_id"` Name string `json:"name"` Logo interface{} `json:"logo"` -} \ No newline at end of file +} + +type SupplierUpdateBalanceRes struct { + CurrentCash float64 `json:"currentCash"` + TotalPendingCash float64 `json:"totalPendingCash"` + OrderPendingCash float64 `json:"orderPendingCash"` + OrderWaitingForReconcileCash float64 `json:"orderWaitingForReconcileCash"` + OrderReconciledCash float64 `json:"orderReconciledCash"` + WithdrawPendingCash float64 `json:"withdrawPendingCash"` + WithdrawSuccessCash float64 `json:"withdrawSuccessCash"` + WithdrawRejectCash float64 `json:"withdrawRejectCash"` + ChangeBalanceRequestApproved float64 `json:"changeBalanceRequestApproved"` + UpdatedAt string `json:"updatedAt"` +} + +type SupplierGetCurrentBalanceRes struct { + CurrentCash float64 `json:"currentCash"` +} diff --git a/subject/supplier.go b/subject/supplier.go index 1b86c12..52ef076 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -11,9 +11,15 @@ var Supplier = struct { GetSupplierContractBySupplierID string FindAll string CreateCashflow string + DeleteCashflow string + UpdateBalance string + GetCurrentBalance string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), CreateCashflow: getSupplierValue("create_cashflow"), + DeleteCashflow: getSupplierValue("delete_cashflow"), + UpdateBalance: getSupplierValue("update_balance"), + GetCurrentBalance: getSupplierValue("get_current_balance"), } From 0d3c931c8772f6933ca1c6e785f03c056fc69b5e Mon Sep 17 00:00:00 2001 From: Sinh Date: Fri, 4 Nov 2022 10:28:09 +0700 Subject: [PATCH 053/103] define nats func - supplier balance --- client/notification.go | 31 +++++++++++++++++++++++++++++++ model/notification_request.go | 7 +++++++ model/notification_response.go | 1 + subject/config.go | 2 ++ subject/notification.go | 13 +++++++++++++ 5 files changed, 54 insertions(+) create mode 100644 client/notification.go create mode 100644 model/notification_request.go create mode 100644 model/notification_response.go create mode 100644 subject/notification.go diff --git a/client/notification.go b/client/notification.go new file mode 100644 index 0000000..66c4b52 --- /dev/null +++ b/client/notification.go @@ -0,0 +1,31 @@ +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" +) + +func GetNotification() Notification { + return Notification{} +} + +type Notification struct{} + +func (n Notification) SupplierChangeBalanceRequestApproved(p model.NotificationSupplierChangeBalanceRequestApprovedReq) error { + msg, err := natsio.GetServer().Request(subject.Notification.SupplierChangeBalanceRequestApproved, toBytes(p)) + if err != nil { + return err + } + var r model.CommonResponseData + 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/notification_request.go b/model/notification_request.go new file mode 100644 index 0000000..bbef9c4 --- /dev/null +++ b/model/notification_request.go @@ -0,0 +1,7 @@ +package model + +type NotificationSupplierChangeBalanceRequestApprovedReq struct { + SupplierID string `json:"supplierId"` + Cash float64 `json:"cash"` + Reason string `json:"reason"` +} diff --git a/model/notification_response.go b/model/notification_response.go new file mode 100644 index 0000000..8b53790 --- /dev/null +++ b/model/notification_response.go @@ -0,0 +1 @@ +package model diff --git a/subject/config.go b/subject/config.go index 4bd7454..cbb0f1d 100644 --- a/subject/config.go +++ b/subject/config.go @@ -8,6 +8,7 @@ var prefixes = struct { Location string Bank string Supplier string + Notification string Seller string SupplierUser string SupplierRole string @@ -20,6 +21,7 @@ var prefixes = struct { Warehouse: "warehouse", Location: "location", Supplier: "supplier", + Notification: "notification", Bank: "bank", Seller: "seller", SupplierUser: "supplier_user", diff --git a/subject/notification.go b/subject/notification.go new file mode 100644 index 0000000..317655f --- /dev/null +++ b/subject/notification.go @@ -0,0 +1,13 @@ +package subject + +import "fmt" + +func getNotificationValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Notification, val) +} + +var Notification = struct { + SupplierChangeBalanceRequestApproved string +}{ + SupplierChangeBalanceRequestApproved: getNotificationValue("supplier_change_balance_request_approved"), +} From 88931f9c53b56282990de9206721ba39925b7edc Mon Sep 17 00:00:00 2001 From: Tue Date: Fri, 4 Nov 2022 15:20:31 +0700 Subject: [PATCH 054/103] build auth sms --- model/supplier_user_response.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/supplier_user_response.go b/model/supplier_user_response.go index af13f88..3df1ea0 100644 --- a/model/supplier_user_response.go +++ b/model/supplier_user_response.go @@ -23,6 +23,7 @@ type SupplierUserBrief struct { Status string `json:"status"` Avatar interface{} `json:"avatar"` Type string `json:"type"` + Warehouses []string `json:"warehouses"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` } From b6f390064be7a0a402eb95be80bfa8ef0611a05f Mon Sep 17 00:00:00 2001 From: Tue Date: Fri, 4 Nov 2022 15:20:31 +0700 Subject: [PATCH 055/103] build auth sms --- model/supplier_user_response.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/supplier_user_response.go b/model/supplier_user_response.go index af13f88..3df1ea0 100644 --- a/model/supplier_user_response.go +++ b/model/supplier_user_response.go @@ -23,6 +23,7 @@ type SupplierUserBrief struct { Status string `json:"status"` Avatar interface{} `json:"avatar"` Type string `json:"type"` + Warehouses []string `json:"warehouses"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` } From 283974d869d76a8ae4ad9ee57e6b6dca10b992de Mon Sep 17 00:00:00 2001 From: Tue Date: Fri, 4 Nov 2022 17:28:33 +0700 Subject: [PATCH 056/103] build auth sms --- client/supplier_user.go | 21 +++++++++++++++++++++ model/supplier_user_request.go | 4 ++++ subject/supplier_user.go | 2 ++ 3 files changed, 27 insertions(+) diff --git a/client/supplier_user.go b/client/supplier_user.go index 2a1939a..8f0762b 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -58,6 +58,27 @@ func (s SupplierUser) GetListUser(p model.GetListUserRequest) (*model.GetListUse return r.Data, nil } +func (s SupplierUser) DetailUser(p model.DetailUserRequest) (*model.SupplierUserBrief, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.DetailUser, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.SupplierUserBrief `json:"data"` + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + + return r.Data, nil +} + func (s SupplierUser) CreateSupplierOwnerUsers(p model.CreateOwnerRequest) (*model.CreateOwnerResponse, error) { msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p)) if err != nil { diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 84afd1d..fe359bb 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -25,6 +25,10 @@ type GetListUserRequest struct { SupplierID string `json:"supplierId"` } +type DetailUserRequest struct { + ID string `json:"_id"` +} + type CreateOwnerRequest struct { Name string `json:"name"` Phone string `json:"phone"` diff --git a/subject/supplier_user.go b/subject/supplier_user.go index 2ad5b4d..e70c032 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -10,6 +10,7 @@ var SupplierUser = struct { // Users LoginUser string GetListUser string + DetailUser string CreateOwner string UpdateOwner string CreateStaff string @@ -20,6 +21,7 @@ var SupplierUser = struct { // Users LoginUser: getSupplierUserValue("login_user"), GetListUser: getSupplierUserValue("get_list_user"), + DetailUser: getSupplierUserValue("detail_user"), CreateOwner: getSupplierUserValue("create_owner"), UpdateOwner: getSupplierUserValue("update_owner"), CreateStaff: getSupplierUserValue("create_staff"), From 382a2b7dfa726128eb011443465ca2d18a53f3e5 Mon Sep 17 00:00:00 2001 From: Tue Date: Fri, 4 Nov 2022 17:28:33 +0700 Subject: [PATCH 057/103] build auth sms --- client/supplier_user.go | 21 +++++++++++++++++++++ model/supplier_user_request.go | 4 ++++ subject/supplier_user.go | 2 ++ 3 files changed, 27 insertions(+) diff --git a/client/supplier_user.go b/client/supplier_user.go index 2a1939a..8f0762b 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -58,6 +58,27 @@ func (s SupplierUser) GetListUser(p model.GetListUserRequest) (*model.GetListUse return r.Data, nil } +func (s SupplierUser) DetailUser(p model.DetailUserRequest) (*model.SupplierUserBrief, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.DetailUser, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.SupplierUserBrief `json:"data"` + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + + return r.Data, nil +} + func (s SupplierUser) CreateSupplierOwnerUsers(p model.CreateOwnerRequest) (*model.CreateOwnerResponse, error) { msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p)) if err != nil { diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 84afd1d..fe359bb 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -25,6 +25,10 @@ type GetListUserRequest struct { SupplierID string `json:"supplierId"` } +type DetailUserRequest struct { + ID string `json:"_id"` +} + type CreateOwnerRequest struct { Name string `json:"name"` Phone string `json:"phone"` diff --git a/subject/supplier_user.go b/subject/supplier_user.go index 2ad5b4d..e70c032 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -10,6 +10,7 @@ var SupplierUser = struct { // Users LoginUser string GetListUser string + DetailUser string CreateOwner string UpdateOwner string CreateStaff string @@ -20,6 +21,7 @@ var SupplierUser = struct { // Users LoginUser: getSupplierUserValue("login_user"), GetListUser: getSupplierUserValue("get_list_user"), + DetailUser: getSupplierUserValue("detail_user"), CreateOwner: getSupplierUserValue("create_owner"), UpdateOwner: getSupplierUserValue("update_owner"), CreateStaff: getSupplierUserValue("create_staff"), From 70b38d05cf72e163595986572deca1328e2599e2 Mon Sep 17 00:00:00 2001 From: Tue Date: Mon, 7 Nov 2022 11:21:27 +0700 Subject: [PATCH 058/103] build auth sms --- client/auth_sms.go | 37 +++++++++++++++++++++++++++++++++++++ model/auth_sms_request.go | 7 +++++++ model/auth_sms_response.go | 1 + subject/auth_sms.go | 15 +++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 client/auth_sms.go create mode 100644 model/auth_sms_request.go create mode 100644 model/auth_sms_response.go create mode 100644 subject/auth_sms.go diff --git a/client/auth_sms.go b/client/auth_sms.go new file mode 100644 index 0000000..c86ad50 --- /dev/null +++ b/client/auth_sms.go @@ -0,0 +1,37 @@ +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" +) + +// AuthSMS ... +type AuthSMS struct{} + +// GetAuthSMS ... +func GetAuthSMS() AuthSMS { + return AuthSMS{} +} + +func (s AuthSMS) CheckPermission(p model.CheckPermissionRequest) error { + msg, err := natsio.GetServer().Request(subject.AuthSMS.CheckPermission, 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/auth_sms_request.go b/model/auth_sms_request.go new file mode 100644 index 0000000..7ee616a --- /dev/null +++ b/model/auth_sms_request.go @@ -0,0 +1,7 @@ +package model + +type CheckPermissionRequest struct { + Value []string `json:"value"` + ID string `json:"_id"` + DeviceID string `json:"deviceId"` +} diff --git a/model/auth_sms_response.go b/model/auth_sms_response.go new file mode 100644 index 0000000..8b53790 --- /dev/null +++ b/model/auth_sms_response.go @@ -0,0 +1 @@ +package model diff --git a/subject/auth_sms.go b/subject/auth_sms.go new file mode 100644 index 0000000..92fea0c --- /dev/null +++ b/subject/auth_sms.go @@ -0,0 +1,15 @@ +package subject + +import "fmt" + +func getAuthSMSValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.AuthSMS, val) +} + +var AuthSMS = struct { + // AuthSMS + CheckPermission string +}{ + // Users + CheckPermission: getAuthSMSValue("check_permission"), +} From d946b993ee4863a256a8212ebd3830cab8d6670e Mon Sep 17 00:00:00 2001 From: Tue Date: Mon, 7 Nov 2022 11:21:27 +0700 Subject: [PATCH 059/103] build auth sms --- client/auth_sms.go | 37 +++++++++++++++++++++++++++++++++++++ model/auth_sms_request.go | 7 +++++++ model/auth_sms_response.go | 1 + subject/auth_sms.go | 15 +++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 client/auth_sms.go create mode 100644 model/auth_sms_request.go create mode 100644 model/auth_sms_response.go create mode 100644 subject/auth_sms.go diff --git a/client/auth_sms.go b/client/auth_sms.go new file mode 100644 index 0000000..c86ad50 --- /dev/null +++ b/client/auth_sms.go @@ -0,0 +1,37 @@ +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" +) + +// AuthSMS ... +type AuthSMS struct{} + +// GetAuthSMS ... +func GetAuthSMS() AuthSMS { + return AuthSMS{} +} + +func (s AuthSMS) CheckPermission(p model.CheckPermissionRequest) error { + msg, err := natsio.GetServer().Request(subject.AuthSMS.CheckPermission, 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/auth_sms_request.go b/model/auth_sms_request.go new file mode 100644 index 0000000..7ee616a --- /dev/null +++ b/model/auth_sms_request.go @@ -0,0 +1,7 @@ +package model + +type CheckPermissionRequest struct { + Value []string `json:"value"` + ID string `json:"_id"` + DeviceID string `json:"deviceId"` +} diff --git a/model/auth_sms_response.go b/model/auth_sms_response.go new file mode 100644 index 0000000..8b53790 --- /dev/null +++ b/model/auth_sms_response.go @@ -0,0 +1 @@ +package model diff --git a/subject/auth_sms.go b/subject/auth_sms.go new file mode 100644 index 0000000..92fea0c --- /dev/null +++ b/subject/auth_sms.go @@ -0,0 +1,15 @@ +package subject + +import "fmt" + +func getAuthSMSValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.AuthSMS, val) +} + +var AuthSMS = struct { + // AuthSMS + CheckPermission string +}{ + // Users + CheckPermission: getAuthSMSValue("check_permission"), +} From 34b1de6d4241dae7a57c6cb5d780a27910eb905e Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Mon, 7 Nov 2022 15:48:28 +0700 Subject: [PATCH 060/103] [location] update request model add page & limit --- model/common_request.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/model/common_request.go b/model/common_request.go index 4ffd6e1..8442864 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -35,4 +35,7 @@ type RequestCondition struct { Keyword string `json:"keyword"` Region string `json:"region"` + + Page int `json:"page"` + Limit int `json:"limit"` } From d80b305b1adca5d67270d893c0453f1b1b84eca6 Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Mon, 7 Nov 2022 16:04:12 +0700 Subject: [PATCH 061/103] [location] update request model page & limit --- model/common_request.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/common_request.go b/model/common_request.go index 8442864..ca13b4c 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -36,6 +36,6 @@ type RequestCondition struct { Keyword string `json:"keyword"` Region string `json:"region"` - Page int `json:"page"` - Limit int `json:"limit"` + Page int64 `json:"page"` + Limit int64 `json:"limit"` } From ae1642878343cf31d728e99b491a4dfffa7f8779 Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Tue, 8 Nov 2022 11:05:34 +0700 Subject: [PATCH 062/103] sync data warehouse into service supplier --- client/supplier.go | 24 ++------------ model/supplier_request.go | 10 +----- subject/warehouse.go | 66 +++++++++++++++++++-------------------- 3 files changed, 36 insertions(+), 64 deletions(-) diff --git a/client/supplier.go b/client/supplier.go index f742f94..8287ae7 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -101,27 +101,9 @@ func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*mod return r.Data, nil } -// CreateWarehouseIntoServiceSupplier ... -func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) 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 -} - -// UpdateWarehouseIntoServiceSupplier ... -func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWarehousePayload) error { - msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateWarehouseIntoServiceSupplier, toBytes(p)) +// SyncWarehouseIntoServiceSupplier ... +func (s Supplier) SyncWarehouseIntoServiceSupplier(p model.SyncSupplierWarehousePayload) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.SyncWarehouseIntoServiceSupplier, toBytes(p)) if err != nil { return err } diff --git a/model/supplier_request.go b/model/supplier_request.go index 0a4b6fa..f9bb5c6 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -23,15 +23,7 @@ type SupplierRequestPayload struct { 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"` -} - -type UpdateSupplierWarehousePayload struct { +type SyncSupplierWarehousePayload struct { Supplier string `json:"supplier"` Warehouse string `json:"warehouse"` ProvinceCode int `json:"provinceCode"` diff --git a/subject/warehouse.go b/subject/warehouse.go index 3722edd..f7f232a 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -7,39 +7,37 @@ func getWarehouseValue(val string) string { } var Warehouse = struct { - CreateWarehouseIntoServiceSupplier string - UpdateWarehouseIntoServiceSupplier 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 - UpdateIsClosedSupplier string - GetWarehouses string + SyncWarehouseIntoServiceSupplier 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 + UpdateIsClosedSupplier string + GetWarehouses string }{ - CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), - UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), - 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"), - UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), - GetWarehouses: getWarehouseValue("get_warehouses"), + SyncWarehouseIntoServiceSupplier: getWarehouseValue("sync_warehouse_into_service_supplier"), + 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"), + UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), + GetWarehouses: getWarehouseValue("get_warehouses"), } From 040c867c15159b02e0a6c58f8fb0d10ce2a35e7c Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Tue, 8 Nov 2022 11:12:37 +0700 Subject: [PATCH 063/103] sync data warehouse into service supplier --- subject/warehouse.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/subject/warehouse.go b/subject/warehouse.go index e200804..6bb0d6e 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -15,7 +15,7 @@ var Warehouse = struct { SyncORStatus string WebhookTNC string WebhookGlobalCare string - WebhookOnPoint string + WebhookOnPoint string FindOne string FindByCondition string Distinct string @@ -24,7 +24,7 @@ var Warehouse = struct { AfterCreateWarehouse string UpdateIsClosedSupplier string GetWarehouses string - UpdateORDeliveryStatus string + UpdateORDeliveryStatus string }{ SyncWarehouseIntoServiceSupplier: getWarehouseValue("sync_warehouse_into_service_supplier"), AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), @@ -36,12 +36,12 @@ var Warehouse = struct { SyncORStatus: getWarehouseValue("sync_or_status"), WebhookTNC: getWarehouseValue("webhook_tnc"), WebhookGlobalCare: getWarehouseValue("webhook_global_care"), - WebhookOnPoint: getWarehouseValue("webhook_on_point") + WebhookOnPoint: getWarehouseValue("webhook_on_point"), FindOne: getWarehouseValue("find_one"), FindByCondition: getWarehouseValue("find_all_by_condition"), Distinct: getWarehouseValue("distinct"), Count: getWarehouseValue("count"), UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), GetWarehouses: getWarehouseValue("get_warehouses"), - UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"), + UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"), } From ffff325e788abd46c2f98e5c259d1805fc336c18 Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 8 Nov 2022 13:53:52 +0700 Subject: [PATCH 064/103] build authsms --- client/bank.go | 11 ++-- client/bank_branch.go | 39 ------------- client/supplier.go | 108 +++++++++++++++++++++++++++++++++-- model/bank_branch_reponse.go | 11 ---- model/bank_branch_request.go | 6 -- model/bank_response.go | 39 +++++++++---- model/supplier_request.go | 32 ++++++++--- model/supplier_response.go | 39 ++++++++++++- subject/bank.go | 8 +-- subject/config.go | 44 +++++++------- subject/supplier.go | 12 ++++ subject/warehouse.go | 74 ++++++++++++------------ 12 files changed, 275 insertions(+), 148 deletions(-) delete mode 100644 client/bank_branch.go delete mode 100644 model/bank_branch_reponse.go delete mode 100644 model/bank_branch_request.go diff --git a/client/bank.go b/client/bank.go index 3391911..27eac4e 100644 --- a/client/bank.go +++ b/client/bank.go @@ -17,15 +17,16 @@ func GetBank() Bank { return Bank{} } -func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) { - msg, err := natsio.GetServer().Request(subject.Bank.GetBankById, toBytes(bankID)) +// GetBankInfo ... +func (s Bank) GetBankInfo(p []model.GetBankInfoRequest) ([]*model.ResponseBankInfo, error) { + msg, err := natsio.GetServer().Request(subject.Bank.GetBankInfo, toBytes(p)) if err != nil { return nil, err } var r struct { - Data *model.BankBrief `json:"data"` - Error string `json:"error"` + Data []*model.ResponseBankInfo `json:"data"` + Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil { @@ -38,7 +39,7 @@ func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) { return r.Data, nil } -func (s Bank) CheckBankAndBranchByID(p model.BankBranchRequest) bool { +func (s Bank) CheckBankAndBranchByID(p model.CheckBankAndBranchByIDRequest) bool { msg, err := natsio.GetServer().Request(subject.Bank.CheckBankAndBranchByID, toBytes(p)) if err != nil { return false diff --git a/client/bank_branch.go b/client/bank_branch.go deleted file mode 100644 index 5890e75..0000000 --- a/client/bank_branch.go +++ /dev/null @@ -1,39 +0,0 @@ -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/client/supplier.go b/client/supplier.go index 1ed20d0..fa96d66 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "errors" + "go.mongodb.org/mongo-driver/bson" "git.selly.red/Selly-Modules/natsio" "git.selly.red/Selly-Modules/natsio/model" @@ -101,9 +102,9 @@ func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*mod return r.Data, nil } -// CreateWarehouseIntoServiceSupplier ... -func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) error { - msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, toBytes(p)) +// SyncWarehouseIntoServiceSupplier ... +func (s Supplier) SyncWarehouseIntoServiceSupplier(p model.SyncSupplierWarehousePayload) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.SyncWarehouseIntoServiceSupplier, toBytes(p)) if err != nil { return err } @@ -119,9 +120,104 @@ 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)) +// GetListWarehouseFreeShip ... +func (s Supplier) GetListWarehouseFreeShip() (*model.SupplierListWarehouseFreeShipResponse, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.GetListWarehouseFreeShip, toBytes(bson.M{})) + if err != nil { + return nil, err + } + + var r struct { + Data *model.SupplierListWarehouseFreeShipResponse `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 +} + +// GetFreeShipInfo ... +func (s Supplier) GetFreeShipInfo(p model.SupplierFreeShipInfoRequestPayload) ([]*model.SupplierFreeShipInfoResponse, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.GetFreeShipInfo, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data []*model.SupplierFreeShipInfoResponse `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 +} + +// CreateCashflow ... +func (s Supplier) CreateCashflow(p model.SupplierCashflowCreatePayload) (*model.SupplierCashflowCreateResponse, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.CreateCashflow, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Error string `json:"error"` + Data *model.SupplierCashflowCreateResponse `json:"data"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + return r.Data, nil +} + +func (s Supplier) UpdateBalance(p model.SupplierUpdateBalanceReq) (*model.SupplierUpdateBalanceRes, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.UpdateBalance, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Error string `json:"error"` + Data *model.SupplierUpdateBalanceRes `json:"data"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + return r.Data, nil +} + +func (s Supplier) GetCurrentBalance(p model.SupplierGetCurrentBalanceReq) (*model.SupplierGetCurrentBalanceRes, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.GetCurrentBalance, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Error string `json:"error"` + Data *model.SupplierGetCurrentBalanceRes `json:"data"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + return r.Data, nil +} + +func (s Supplier) DeleteCashflow(p model.SupplierDeleteCashflowReq) error { + msg, err := natsio.GetServer().Request(subject.Supplier.DeleteCashflow, toBytes(p)) if err != nil { return err } diff --git a/model/bank_branch_reponse.go b/model/bank_branch_reponse.go deleted file mode 100644 index 1fa1432..0000000 --- a/model/bank_branch_reponse.go +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index 6de1216..0000000 --- a/model/bank_branch_request.go +++ /dev/null @@ -1,6 +0,0 @@ -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 index 74fc10e..4880d03 100644 --- a/model/bank_response.go +++ b/model/bank_response.go @@ -1,21 +1,40 @@ package model +import "time" + // MultiLang ... type MultiLang struct { En string `json:"en"` Vi string `json:"vi"` } +// BankBranchBrief ... +type BranchBrief struct { + ID string `json:"_id"` + City string `json:"city"` + BankCode string `json:"bankCode"` + BankID string `json:"bankId"` + Active bool `json:"active"` + Name string `json:"name"` +} + // 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"` + 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"` + BeneficiaryForVietinbank string `json:"beneficiaryForVietinbank"` + CreatedBy string `json:"createdBy,omitempty"` + CreatedAt time.Time `json:"createdAt"` + BranchTotal int64 `json:"branchTotal"` + Logo interface{} `json:"logo"` +} + +type ResponseBankInfo struct { + Bank BankBrief `json:"bank"` + Branch BranchBrief `json:"branch"` } diff --git a/model/supplier_request.go b/model/supplier_request.go index 5a19924..2f20416 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -23,7 +23,7 @@ type SupplierRequestPayload struct { ContractStatus string } -type CreateSupplierWarehousePayload struct { +type SyncSupplierWarehousePayload struct { Supplier string `json:"supplier"` Warehouse string `json:"warehouse"` ProvinceCode int `json:"provinceCode"` @@ -31,10 +31,28 @@ type CreateSupplierWarehousePayload struct { 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"` +// SupplierCashflowCreatePayload ... +type SupplierCashflowCreatePayload struct { + Supplier string `json:"supplier"` + Action string `json:"action"` + Name string `json:"name"` + TargetID string `json:"targetId"` + Value float64 `json:"value"` + ClickAction *ClickAction `json:"clickAction"` +} + +type SupplierFreeShipInfoRequestPayload struct { + SupplierIDs []string `json:"supplierIds"` +} + +type SupplierUpdateBalanceReq struct { + SupplierID string `json:"supplierId"` +} + +type SupplierGetCurrentBalanceReq struct { + SupplierID string `json:"supplierId"` +} + +type SupplierDeleteCashflowReq struct { + CashflowID string `json:"cashflowId"` } diff --git a/model/supplier_response.go b/model/supplier_response.go index 4df67b7..655e85b 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -30,8 +30,45 @@ type SupplierAll struct { Total int64 `json:"total"` } +type SupplierListWarehouseFreeShipResponse struct { + Warehouses []string `json:"warehouses"` +} + +type SupplierCashflowCreateResponse struct { + ID string `json:"id"` +} + +type FreeShip struct { + ID string `json:"_id"` + ShortName string `json:"shortName"` + ListMilestoneText []string `json:"milestoneText"` + Order int `json:"-"` +} + +type SupplierFreeShipInfoResponse struct { + SupplierID string `json:"supplierId"` + FreeShips []FreeShip `json:"freeShips"` +} + type SupplierShort struct { ID string `json:"_id"` Name string `json:"name"` Logo interface{} `json:"logo"` -} \ No newline at end of file +} + +type SupplierUpdateBalanceRes struct { + CurrentCash float64 `json:"currentCash"` + TotalPendingCash float64 `json:"totalPendingCash"` + OrderPendingCash float64 `json:"orderPendingCash"` + OrderWaitingForReconcileCash float64 `json:"orderWaitingForReconcileCash"` + OrderReconciledCash float64 `json:"orderReconciledCash"` + WithdrawPendingCash float64 `json:"withdrawPendingCash"` + WithdrawSuccessCash float64 `json:"withdrawSuccessCash"` + WithdrawRejectCash float64 `json:"withdrawRejectCash"` + ChangeBalanceRequestApproved float64 `json:"changeBalanceRequestApproved"` + UpdatedAt string `json:"updatedAt"` +} + +type SupplierGetCurrentBalanceRes struct { + CurrentCash float64 `json:"currentCash"` +} diff --git a/subject/bank.go b/subject/bank.go index 9f7f8bb..601ecb4 100644 --- a/subject/bank.go +++ b/subject/bank.go @@ -7,11 +7,9 @@ func getBankValue(val string) string { } var Bank = struct { - GetBankById string - GetBankBranchById string + GetBankInfo string CheckBankAndBranchByID string }{ - GetBankById: getBankValue("get_bank_by_id"), - GetBankBranchById: getBankValue("get_bank_branch_by_id"), - CheckBankAndBranchByID: getBankValue("check_bank_and_brach_by_id"), + GetBankInfo: getBankValue("get_bank_info"), + CheckBankAndBranchByID: getBankValue("check_bank_and_branch_by_id"), } diff --git a/subject/config.go b/subject/config.go index 37e3055..c838f87 100644 --- a/subject/config.go +++ b/subject/config.go @@ -1,27 +1,31 @@ package subject var prefixes = struct { - Communication string - Order string - News string - Warehouse string - Location string - Bank string - Supplier string - Seller string - SupplierUser string - SupplierRole string + Communication string + Order string + News string + Warehouse string + Location string + Bank string + Supplier string + Seller string + AuthSMS string + Selly string + SupplierUser string + SupplierRole string SupplierPermission string }{ - Communication: "communication", - Order: "order", - News: "news", - Warehouse: "warehouse", - Location: "location", - Supplier: "supplier", - Bank: "bank", - Seller: "seller", - SupplierUser: "supplier_user", - SupplierRole: "supplier_role", + Communication: "communication", + Order: "order", + News: "news", + Warehouse: "warehouse", + Location: "location", + Supplier: "supplier", + Bank: "bank", + Seller: "seller", + AuthSMS: "auth_sms", + Selly: "selly", + SupplierUser: "supplier_user", + SupplierRole: "supplier_role", SupplierPermission: "supplier_permission", } diff --git a/subject/supplier.go b/subject/supplier.go index 17ca8d0..441118f 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -10,8 +10,20 @@ var Supplier = struct { GetListSupplierInfo string GetSupplierContractBySupplierID string FindAll string + GetListWarehouseFreeShip string + CreateCashflow string + DeleteCashflow string + UpdateBalance string + GetCurrentBalance string + GetFreeShipInfo string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), + GetListWarehouseFreeShip: getSupplierValue("get_list_warehouse_free_ship"), + CreateCashflow: getSupplierValue("create_cashflow"), + DeleteCashflow: getSupplierValue("delete_cashflow"), + UpdateBalance: getSupplierValue("update_balance"), + GetCurrentBalance: getSupplierValue("get_current_balance"), + GetFreeShipInfo: getSupplierValue("get_free_ship_info"), } diff --git a/subject/warehouse.go b/subject/warehouse.go index bb184b5..6bb0d6e 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -7,43 +7,41 @@ func getWarehouseValue(val string) string { } var Warehouse = struct { - CreateWarehouseIntoServiceSupplier string - UpdateWarehouseIntoServiceSupplier string - CreateOutboundRequest string - UpdateOutboundRequestLogistic string - CancelOutboundRequest string - GetConfiguration string - SyncORStatus string - WebhookTNC string - WebhookGlobalCare string - WebhookOnPoint string - FindOne string - FindByCondition string - Distinct string - Count string - AfterUpdateWarehouse string - AfterCreateWarehouse string - UpdateIsClosedSupplier string - GetWarehouses string - UpdateORDeliveryStatus string + SyncWarehouseIntoServiceSupplier string + CreateOutboundRequest string + UpdateOutboundRequestLogistic string + CancelOutboundRequest string + GetConfiguration string + SyncORStatus string + WebhookTNC string + WebhookGlobalCare string + WebhookOnPoint string + FindOne string + FindByCondition string + Distinct string + Count string + AfterUpdateWarehouse string + AfterCreateWarehouse string + UpdateIsClosedSupplier string + GetWarehouses string + UpdateORDeliveryStatus string }{ - CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), - UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), - 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"), - WebhookOnPoint: getWarehouseValue("webhook_on_point"), - FindOne: getWarehouseValue("find_one"), - FindByCondition: getWarehouseValue("find_all_by_condition"), - Distinct: getWarehouseValue("distinct"), - Count: getWarehouseValue("count"), - UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), - GetWarehouses: getWarehouseValue("get_warehouses"), - UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"), + SyncWarehouseIntoServiceSupplier: getWarehouseValue("sync_warehouse_into_service_supplier"), + 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"), + WebhookOnPoint: getWarehouseValue("webhook_on_point"), + FindOne: getWarehouseValue("find_one"), + FindByCondition: getWarehouseValue("find_all_by_condition"), + Distinct: getWarehouseValue("distinct"), + Count: getWarehouseValue("count"), + UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), + GetWarehouses: getWarehouseValue("get_warehouses"), + UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"), } From 4d501a437c7d4b65d8f766cb38c28821364f6371 Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 8 Nov 2022 13:57:22 +0700 Subject: [PATCH 065/103] build authsms --- client/withdraw.go | 39 +++++++++++++++++++++++++++++++++++++++ model/bank_request.go | 11 +++++++++++ 2 files changed, 50 insertions(+) create mode 100644 client/withdraw.go create mode 100644 model/bank_request.go diff --git a/client/withdraw.go b/client/withdraw.go new file mode 100644 index 0000000..006d7a7 --- /dev/null +++ b/client/withdraw.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" +) + +// Withdraw ... +type Withdraw struct{} + +// GetWithdraw ... +func GetWithdraw() Withdraw { + return Withdraw{} +} + +// GetSupplierCash ... +func (o Withdraw) GetSupplierCash(p model.WithdrawSupplierCashReq) (*model.WithdrawSupplierCashRes, error) { + msg, err := natsio.GetServer().Request(subject.Withdraw.GetSupplierCash, toBytes(p)) + if err != nil { + return nil, err + } + var ( + r struct { + Data model.WithdrawSupplierCashRes `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..3b76615 --- /dev/null +++ b/model/bank_request.go @@ -0,0 +1,11 @@ +package model + +type CheckBankAndBranchByIDRequest struct { + BankID string `json:"bankId"` + BranchID string `json:"branchId"` +} + +type GetBankInfoRequest struct { + BankID string `json:"bankId"` + BranchID string `json:"branchId"` +} From 1cacdae5475dd8ed418981e6a6e26b23a2229d9c Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 8 Nov 2022 13:58:30 +0700 Subject: [PATCH 066/103] build authsms --- model/common_request.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/model/common_request.go b/model/common_request.go index 0ce5163..e83fa2c 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -20,3 +20,25 @@ type ActionBy struct { ID string `json:"id"` Name string `json:"name"` } + +// ClickAction ... +type ClickAction struct { + Type string `json:"type"` + Value string `json:"value"` +} + +// RequestCondition ... +type RequestCondition struct { + Code int `json:"code"` + Codes []int `json:"codes"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` + + Slug string `json:"slug"` + Slugs []string `json:"slugs"` + DistrictSlug string `json:"districtSlug"` + ProvinceSlug string `json:"provinceSlug"` + + Keyword string `json:"keyword"` + Region string `json:"region"` +} From 7e433426cbf4c60151034a58a14dc2f5f121f42d Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 8 Nov 2022 14:02:07 +0700 Subject: [PATCH 067/103] build auth sms --- model/withdraw_request.go | 5 +++++ model/withdraw_response.go | 7 +++++++ subject/withdraw.go | 13 +++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 model/withdraw_request.go create mode 100644 model/withdraw_response.go create mode 100644 subject/withdraw.go diff --git a/model/withdraw_request.go b/model/withdraw_request.go new file mode 100644 index 0000000..7eb4a3f --- /dev/null +++ b/model/withdraw_request.go @@ -0,0 +1,5 @@ +package model + +type WithdrawSupplierCashReq struct { + SupplierID string `json:"supplierId"` +} diff --git a/model/withdraw_response.go b/model/withdraw_response.go new file mode 100644 index 0000000..9c5adc5 --- /dev/null +++ b/model/withdraw_response.go @@ -0,0 +1,7 @@ +package model + +type WithdrawSupplierCashRes struct { + PendingCash float64 `json:"pendingCash"` + SuccessCash float64 `json:"successCash"` + RejectCash float64 `json:"rejectCash"` +} diff --git a/subject/withdraw.go b/subject/withdraw.go new file mode 100644 index 0000000..08f9a87 --- /dev/null +++ b/subject/withdraw.go @@ -0,0 +1,13 @@ +package subject + +import "fmt" + +func getWithdrawValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Withdraw, val) +} + +var Withdraw = struct { + GetSupplierCash string +}{ + GetSupplierCash: getWithdrawValue("get_supplier_cash"), +} From c004406728898b35ad5eb569db372b02daef8140 Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 8 Nov 2022 14:05:17 +0700 Subject: [PATCH 068/103] build auth sms --- subject/config.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subject/config.go b/subject/config.go index c838f87..97ce6be 100644 --- a/subject/config.go +++ b/subject/config.go @@ -14,6 +14,7 @@ var prefixes = struct { SupplierUser string SupplierRole string SupplierPermission string + Withdraw string }{ Communication: "communication", Order: "order", @@ -28,4 +29,5 @@ var prefixes = struct { SupplierUser: "supplier_user", SupplierRole: "supplier_role", SupplierPermission: "supplier_permission", + Withdraw: "withdraw", } From ca99cdad86e74e3925032a1c054b4dba54873d8f Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 8 Nov 2022 14:05:17 +0700 Subject: [PATCH 069/103] build auth sms --- subject/config.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subject/config.go b/subject/config.go index c838f87..97ce6be 100644 --- a/subject/config.go +++ b/subject/config.go @@ -14,6 +14,7 @@ var prefixes = struct { SupplierUser string SupplierRole string SupplierPermission string + Withdraw string }{ Communication: "communication", Order: "order", @@ -28,4 +29,5 @@ var prefixes = struct { SupplierUser: "supplier_user", SupplierRole: "supplier_role", SupplierPermission: "supplier_permission", + Withdraw: "withdraw", } From 2872e4f75b7358c7690bed687fb506438bac6a90 Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 8 Nov 2022 14:15:47 +0700 Subject: [PATCH 070/103] build auth sms --- client/order.go | 21 +++++++++++++++++++++ model/order_request.go | 4 ++++ model/order_response.go | 6 ++++++ subject/order.go | 2 ++ 4 files changed, 33 insertions(+) diff --git a/client/order.go b/client/order.go index a6ab736..a49c68b 100644 --- a/client/order.go +++ b/client/order.go @@ -119,3 +119,24 @@ func (o Order) GetSupplierOrders(p model.OrderSupplierQuery) (*model.SupplierOrd } return &r.Data, nil } + +// GetSupplierCash ... +func (o Order) GetSupplierCash(p model.OrderSupplierCashReq) (*model.OrderSupplierCashRes, error) { + msg, err := natsio.GetServer().Request(subject.Order.GetSupplierCash, toBytes(p)) + if err != nil { + return nil, err + } + var ( + r struct { + Data model.OrderSupplierCashRes `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 bd1fa73..a0ff6ee 100644 --- a/model/order_request.go +++ b/model/order_request.go @@ -49,3 +49,7 @@ type OrderSupplierQuery struct { SupplierID string `json:"supplierId"` WarehouseIDs []string `json:"warehouseIDs"` } + +type OrderSupplierCashReq struct { + SupplierID string `json:"supplierId"` +} diff --git a/model/order_response.go b/model/order_response.go index c08f87a..59b80d3 100644 --- a/model/order_response.go +++ b/model/order_response.go @@ -33,3 +33,9 @@ type SupplierOrderDelivery struct { 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"` } + +type OrderSupplierCashRes struct { + PendingCash float64 `json:"pendingCash"` + WaitingForReconcileCash float64 `json:"waitingForReconcileCash"` + ReconciledCash float64 `json:"reconciledCash"` +} diff --git a/subject/order.go b/subject/order.go index 017f2be..e24e193 100644 --- a/subject/order.go +++ b/subject/order.go @@ -13,6 +13,7 @@ var Order = struct { UpdateLogisticInfoFailed string ORNotUpdateStatus string GetSupplierOrders string + GetSupplierCash string }{ UpdateORStatus: getOrderValue("update_outbound_request_status"), CancelDelivery: getOrderValue("cancel_delivery"), @@ -20,4 +21,5 @@ var Order = struct { UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"), ORNotUpdateStatus: getOrderValue("outbound_request_not_update_status"), GetSupplierOrders: getOrderValue("get_supplier_orders"), + GetSupplierCash: getOrderValue("get_supplier_cash"), } From b45fb1d19ac5a8ff3b4cf7e2dc43e0ec20346865 Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Tue, 8 Nov 2022 14:20:05 +0700 Subject: [PATCH 071/103] sync data warehouse into service supplier --- model/supplier_request.go | 8 -------- model/supplier_response.go | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/model/supplier_request.go b/model/supplier_request.go index d2c9ae1..e4ddab5 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -23,14 +23,6 @@ type SupplierRequestPayload struct { ContractStatus string } -type SyncSupplierWarehousePayload struct { - Supplier string `json:"supplier"` - Warehouse string `json:"warehouse"` - ProvinceCode int `json:"provinceCode"` - DistrictCode int `json:"districtCode"` - WardCode int `json:"wardCode"` -} - // SupplierCashflowCreatePayload ... type SupplierCashflowCreatePayload struct { Supplier string `json:"supplier"` diff --git a/model/supplier_response.go b/model/supplier_response.go index 83fec77..ec46dc5 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -56,3 +56,11 @@ type SupplierUpdateBalanceRes struct { type SupplierGetCurrentBalanceRes struct { CurrentCash float64 `json:"currentCash"` } + +type SyncSupplierWarehousePayload struct { + Supplier string `json:"supplier"` + Warehouse string `json:"warehouse"` + ProvinceCode int `json:"provinceCode"` + DistrictCode int `json:"districtCode"` + WardCode int `json:"wardCode"` +} From 61498e15942f088709c350419d5da66fea7561de Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Tue, 8 Nov 2022 15:22:53 +0700 Subject: [PATCH 072/103] update --- subject/config.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subject/config.go b/subject/config.go index 97ce6be..867d934 100644 --- a/subject/config.go +++ b/subject/config.go @@ -15,6 +15,7 @@ var prefixes = struct { SupplierRole string SupplierPermission string Withdraw string + Notification string }{ Communication: "communication", Order: "order", @@ -30,4 +31,5 @@ var prefixes = struct { SupplierRole: "supplier_role", SupplierPermission: "supplier_permission", Withdraw: "withdraw", + Notification: "notification", } From 0580606373958bc1a0b1c42d28a77f49bc649849 Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Tue, 8 Nov 2022 18:00:24 +0700 Subject: [PATCH 073/103] get-bank-info --- client/bank.go | 11 +++++----- model/bank_branch_reponse.go | 11 ---------- model/bank_branch_request.go | 6 ------ model/bank_request.go | 11 ++++++++++ model/bank_response.go | 39 +++++++++++++++++++++++++++--------- subject/bank.go | 8 +++----- 6 files changed, 49 insertions(+), 37 deletions(-) delete mode 100644 model/bank_branch_reponse.go delete mode 100644 model/bank_branch_request.go create mode 100644 model/bank_request.go diff --git a/client/bank.go b/client/bank.go index 3391911..27eac4e 100644 --- a/client/bank.go +++ b/client/bank.go @@ -17,15 +17,16 @@ func GetBank() Bank { return Bank{} } -func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) { - msg, err := natsio.GetServer().Request(subject.Bank.GetBankById, toBytes(bankID)) +// GetBankInfo ... +func (s Bank) GetBankInfo(p []model.GetBankInfoRequest) ([]*model.ResponseBankInfo, error) { + msg, err := natsio.GetServer().Request(subject.Bank.GetBankInfo, toBytes(p)) if err != nil { return nil, err } var r struct { - Data *model.BankBrief `json:"data"` - Error string `json:"error"` + Data []*model.ResponseBankInfo `json:"data"` + Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil { @@ -38,7 +39,7 @@ func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) { return r.Data, nil } -func (s Bank) CheckBankAndBranchByID(p model.BankBranchRequest) bool { +func (s Bank) CheckBankAndBranchByID(p model.CheckBankAndBranchByIDRequest) bool { msg, err := natsio.GetServer().Request(subject.Bank.CheckBankAndBranchByID, toBytes(p)) if err != nil { return false diff --git a/model/bank_branch_reponse.go b/model/bank_branch_reponse.go deleted file mode 100644 index 1fa1432..0000000 --- a/model/bank_branch_reponse.go +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index 6de1216..0000000 --- a/model/bank_branch_request.go +++ /dev/null @@ -1,6 +0,0 @@ -package model - -type BankBranchRequest struct { - BankID string `json:"bankId"` - BranchID string `json:"branchId"` -} diff --git a/model/bank_request.go b/model/bank_request.go new file mode 100644 index 0000000..3b76615 --- /dev/null +++ b/model/bank_request.go @@ -0,0 +1,11 @@ +package model + +type CheckBankAndBranchByIDRequest struct { + BankID string `json:"bankId"` + BranchID string `json:"branchId"` +} + +type GetBankInfoRequest struct { + BankID string `json:"bankId"` + BranchID string `json:"branchId"` +} diff --git a/model/bank_response.go b/model/bank_response.go index 74fc10e..4880d03 100644 --- a/model/bank_response.go +++ b/model/bank_response.go @@ -1,21 +1,40 @@ package model +import "time" + // MultiLang ... type MultiLang struct { En string `json:"en"` Vi string `json:"vi"` } +// BankBranchBrief ... +type BranchBrief struct { + ID string `json:"_id"` + City string `json:"city"` + BankCode string `json:"bankCode"` + BankID string `json:"bankId"` + Active bool `json:"active"` + Name string `json:"name"` +} + // 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"` + 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"` + BeneficiaryForVietinbank string `json:"beneficiaryForVietinbank"` + CreatedBy string `json:"createdBy,omitempty"` + CreatedAt time.Time `json:"createdAt"` + BranchTotal int64 `json:"branchTotal"` + Logo interface{} `json:"logo"` +} + +type ResponseBankInfo struct { + Bank BankBrief `json:"bank"` + Branch BranchBrief `json:"branch"` } diff --git a/subject/bank.go b/subject/bank.go index 9f7f8bb..601ecb4 100644 --- a/subject/bank.go +++ b/subject/bank.go @@ -7,11 +7,9 @@ func getBankValue(val string) string { } var Bank = struct { - GetBankById string - GetBankBranchById string + GetBankInfo string CheckBankAndBranchByID string }{ - GetBankById: getBankValue("get_bank_by_id"), - GetBankBranchById: getBankValue("get_bank_branch_by_id"), - CheckBankAndBranchByID: getBankValue("check_bank_and_brach_by_id"), + GetBankInfo: getBankValue("get_bank_info"), + CheckBankAndBranchByID: getBankValue("check_bank_and_branch_by_id"), } From 3507d1702961928305c667de7b4cb6538e6663d6 Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 8 Nov 2022 18:02:42 +0700 Subject: [PATCH 074/103] build auth sms --- client/supplier_user.go | 40 ++++++++++++++++++++++++++++++++++ model/supplier_user_request.go | 9 ++++++++ subject/supplier_user.go | 40 +++++++++++++++++++--------------- 3 files changed, 71 insertions(+), 18 deletions(-) diff --git a/client/supplier_user.go b/client/supplier_user.go index 8f0762b..f7b52ad 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -37,6 +37,26 @@ func (s SupplierUser) LoginUser(p model.LoginUserRequest) (*model.LoginUserRespo return r.Data, nil } +func (s SupplierUser) Logout(p model.LogoutRequest) error { + msg, err := natsio.GetServer().Request(subject.SupplierUser.Logout, 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 +} + func (s SupplierUser) GetListUser(p model.GetListUserRequest) (*model.GetListUserResponse, error) { msg, err := natsio.GetServer().Request(subject.SupplierUser.GetListUser, toBytes(p)) if err != nil { @@ -201,3 +221,23 @@ func (s SupplierUser) ResetPassword(p model.ResetPasswordRequest) (*model.ResetP return r.Data, nil } + +func (s SupplierUser) ChangePassword(p model.ChangePasswordRequest) error { + msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateStatus, 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_user_request.go b/model/supplier_user_request.go index fe359bb..401a1d1 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -17,6 +17,10 @@ type LoginUserRequest struct { IsMobile bool `json:"isMobile"` } +type LogoutRequest struct { + ID string `json:"_id"` +} + type GetListUserRequest struct { Page int `json:"page"` Limit int `json:"limit"` @@ -75,3 +79,8 @@ type UpdateStatusRequest struct { type ResetPasswordRequest struct { ID string `json:"_id"` } + +type ChangePasswordRequest struct { + ID string `json:"_id"` + Password string `json:"password"` +} diff --git a/subject/supplier_user.go b/subject/supplier_user.go index e70c032..49d186c 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -8,24 +8,28 @@ func getSupplierUserValue(val string) string { var SupplierUser = struct { // Users - LoginUser string - GetListUser string - DetailUser string - CreateOwner string - UpdateOwner string - CreateStaff string - UpdateStaff string - UpdateStatus string - ResetPassword string + LoginUser string + Logout string + GetListUser string + DetailUser string + CreateOwner string + UpdateOwner string + CreateStaff string + UpdateStaff string + UpdateStatus string + ResetPassword string + ChangePassword string }{ // Users - LoginUser: getSupplierUserValue("login_user"), - GetListUser: getSupplierUserValue("get_list_user"), - DetailUser: getSupplierUserValue("detail_user"), - CreateOwner: getSupplierUserValue("create_owner"), - UpdateOwner: getSupplierUserValue("update_owner"), - CreateStaff: getSupplierUserValue("create_staff"), - UpdateStaff: getSupplierUserValue("update_staff"), - UpdateStatus: getSupplierUserValue("update_status"), - ResetPassword: getSupplierUserValue("reset_password"), + LoginUser: getSupplierUserValue("login_user"), + Logout: getSupplierUserValue("logout"), + GetListUser: getSupplierUserValue("get_list_user"), + DetailUser: getSupplierUserValue("detail_user"), + CreateOwner: getSupplierUserValue("create_owner"), + UpdateOwner: getSupplierUserValue("update_owner"), + CreateStaff: getSupplierUserValue("create_staff"), + UpdateStaff: getSupplierUserValue("update_staff"), + UpdateStatus: getSupplierUserValue("update_status"), + ResetPassword: getSupplierUserValue("reset_password"), + ChangePassword: getSupplierUserValue("change_password"), } From a3206ebdd46d890cdf87a6753f532fe0e0eff0da Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 9 Nov 2022 14:28:10 +0700 Subject: [PATCH 075/103] build auth sms --- client/bank.go | 26 ++++++++++++++++++++++++-- model/bank_response.go | 2 +- subject/bank.go | 2 ++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/client/bank.go b/client/bank.go index 27eac4e..ba3e9fb 100644 --- a/client/bank.go +++ b/client/bank.go @@ -46,11 +46,33 @@ func (s Bank) CheckBankAndBranchByID(p model.CheckBankAndBranchByIDRequest) bool } var r struct { - Error string `json:"error"` + Data bool `json:"data"` } if err = json.Unmarshal(msg.Data, &r); err != nil { return false } - return r.Error == "" + return r.Data +} + +// GetBankAndBranchDetail ... +func (s Bank) GetBankAndBranchDetail(p model.GetBankInfoRequest) (*model.ResponseBankInfo, error) { + msg, err := natsio.GetServer().Request(subject.Bank.GetBankInfoDetail, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseBankInfo `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_response.go b/model/bank_response.go index 4880d03..e422915 100644 --- a/model/bank_response.go +++ b/model/bank_response.go @@ -8,7 +8,7 @@ type MultiLang struct { Vi string `json:"vi"` } -// BankBranchBrief ... +// BranchBrief ... type BranchBrief struct { ID string `json:"_id"` City string `json:"city"` diff --git a/subject/bank.go b/subject/bank.go index 601ecb4..a500900 100644 --- a/subject/bank.go +++ b/subject/bank.go @@ -8,8 +8,10 @@ func getBankValue(val string) string { var Bank = struct { GetBankInfo string + GetBankInfoDetail string CheckBankAndBranchByID string }{ GetBankInfo: getBankValue("get_bank_info"), + GetBankInfoDetail: getBankValue("get_bank_info_detail"), CheckBankAndBranchByID: getBankValue("check_bank_and_branch_by_id"), } From 035fb59f64829bbf99edf93af0d937793393d0e3 Mon Sep 17 00:00:00 2001 From: Tue Date: Thu, 17 Nov 2022 13:55:44 +0700 Subject: [PATCH 076/103] build email --- client/email.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 client/email.go diff --git a/client/email.go b/client/email.go new file mode 100644 index 0000000..0de10e1 --- /dev/null +++ b/client/email.go @@ -0,0 +1,38 @@ +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" +) + +// Email ... +type Email struct{} + +// GetEmail ... +func GetEmail() Email { + return Email{} +} + +func (s Email) Send(p model.GetEmailRequest) ([]*model.ResponseEmailInfo, error) { + msg, err := natsio.GetServer().Request(subject.Email.GetListEmailInfo, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data []*model.ResponseEmailInfo `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 +} From f602e17ef28525ca7fa0ec83abf0461896c70329 Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Thu, 17 Nov 2022 16:49:02 +0700 Subject: [PATCH 077/103] [location] add oldSlug to RequestCondition --- model/common_request.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/model/common_request.go b/model/common_request.go index ca13b4c..3568338 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -28,7 +28,9 @@ type RequestCondition struct { DistrictCode int `json:"districtCode"` ProvinceCode int `json:"provinceCode"` - Slug string `json:"slug"` + Slug string `json:"slug"` + OldSlug string `json:"oldSlug"` + Slugs []string `json:"slugs"` DistrictSlug string `json:"districtSlug"` ProvinceSlug string `json:"provinceSlug"` From b9885a2a0288acb99eaf2892a6bd2ce7fdb048fd Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Thu, 17 Nov 2022 17:19:04 +0700 Subject: [PATCH 078/103] [location] RequestCondition oldSlugs --- model/common_request.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/model/common_request.go b/model/common_request.go index 3568338..447ae57 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -31,9 +31,11 @@ type RequestCondition struct { Slug string `json:"slug"` OldSlug string `json:"oldSlug"` - Slugs []string `json:"slugs"` - DistrictSlug string `json:"districtSlug"` - ProvinceSlug string `json:"provinceSlug"` + Slugs []string `json:"slugs"` + OldSlugs []string `json:"oldSlugs"` + + DistrictSlug string `json:"districtSlug"` + ProvinceSlug string `json:"provinceSlug"` Keyword string `json:"keyword"` Region string `json:"region"` From 17dace7edf59daa90bca74a3f310fe20daef25ff Mon Sep 17 00:00:00 2001 From: Sinh Date: Fri, 18 Nov 2022 10:24:06 +0700 Subject: [PATCH 079/103] remove err method email --- client/email.go | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/client/email.go b/client/email.go index 0de10e1..7725884 100644 --- a/client/email.go +++ b/client/email.go @@ -1,13 +1,5 @@ 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" -) - // Email ... type Email struct{} @@ -16,23 +8,23 @@ func GetEmail() Email { return Email{} } -func (s Email) Send(p model.GetEmailRequest) ([]*model.ResponseEmailInfo, error) { - msg, err := natsio.GetServer().Request(subject.Email.GetListEmailInfo, toBytes(p)) - if err != nil { - return nil, err - } - - var r struct { - Data []*model.ResponseEmailInfo `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 Email) Send(p model.GetEmailRequest) ([]*model.ResponseEmailInfo, error) { +// msg, err := natsio.GetServer().Request(subject.Email.GetListEmailInfo, toBytes(p)) +// if err != nil { +// return nil, err +// } +// +// var r struct { +// Data []*model.ResponseEmailInfo `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 +// } From 8cceae74ef96afc69b7ac7361376e383f2ccf5ea Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Fri, 18 Nov 2022 16:22:17 +0700 Subject: [PATCH 080/103] get staff by notification action --- client/staff.go | 41 +++++++++++++++++++++++++++++++++++++++++ model/staff_request.go | 8 ++++++++ model/staff_response.go | 14 ++++++++++++++ subject/config.go | 2 ++ subject/staff.go | 13 +++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 client/staff.go create mode 100644 model/staff_request.go create mode 100644 model/staff_response.go create mode 100644 subject/staff.go diff --git a/client/staff.go b/client/staff.go new file mode 100644 index 0000000..7bcd91d --- /dev/null +++ b/client/staff.go @@ -0,0 +1,41 @@ +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" +) + +// Staff ... +type Staff struct{} + +func GetStaff() Staff { + return Staff{} +} + +// GetListStaffInfoByNotificationAction ... +func (s Staff) GetListStaffInfoByNotificationAction(p model.GetListStaffByNotificationActionRequest) (*model.ResponseListStaffInfoByNotificationAction, error) { + msg, err := natsio.GetServer().Request(subject.Staff.GetListStaffInfoByNotificationAction, toBytes(p)) + + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseListStaffInfoByNotificationAction `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/staff_request.go b/model/staff_request.go new file mode 100644 index 0000000..904f617 --- /dev/null +++ b/model/staff_request.go @@ -0,0 +1,8 @@ +package model + +// GetListStaffByNotificationActionRequest ... +type GetListStaffByNotificationActionRequest struct { + CreatedBys []string `json:"createdBys"` + ApprovedBys []string `json:"approvedBys"` + CancelledBys []string `json:"cancelledBys"` +} diff --git a/model/staff_response.go b/model/staff_response.go new file mode 100644 index 0000000..cd471a2 --- /dev/null +++ b/model/staff_response.go @@ -0,0 +1,14 @@ +package model + +// ResponseListStaffInfoByNotificationAction ... +type ResponseListStaffInfoByNotificationAction struct { + CreatedBys []ResponseStaffInfo `json:"CreatedBys"` + ApprovedBys []ResponseStaffInfo `json:"ApprovedBys"` + CancelledBys []ResponseStaffInfo `json:"CancelledBys"` +} + +// ResponseStaffInfo ... +type ResponseStaffInfo struct { + ID string `json:"_id"` + Name string `json:"name"` +} diff --git a/subject/config.go b/subject/config.go index 8837975..6988929 100644 --- a/subject/config.go +++ b/subject/config.go @@ -17,6 +17,7 @@ var prefixes = struct { Withdraw string Notification string SocialPost string + Staff string }{ Communication: "communication", Order: "order", @@ -34,4 +35,5 @@ var prefixes = struct { Withdraw: "withdraw", Notification: "notification", SocialPost: "social_post", + Staff: "staff", } diff --git a/subject/staff.go b/subject/staff.go new file mode 100644 index 0000000..0cdbcf0 --- /dev/null +++ b/subject/staff.go @@ -0,0 +1,13 @@ +package subject + +import "fmt" + +func getStaffValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Staff, val) +} + +var Staff = struct { + GetListStaffInfoByNotificationAction string +}{ + GetListStaffInfoByNotificationAction: getStaffValue("get_list_staff_info_by_notification_info"), +} From 0a9381065fc0acb946ea7ca91ee0193d89d1378a Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Fri, 18 Nov 2022 17:47:26 +0700 Subject: [PATCH 081/103] edit get staff-info --- client/staff.go | 8 ++++---- model/staff_request.go | 8 +++----- model/staff_response.go | 8 +++----- subject/staff.go | 4 ++-- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/client/staff.go b/client/staff.go index 7bcd91d..e2eac0c 100644 --- a/client/staff.go +++ b/client/staff.go @@ -16,16 +16,16 @@ func GetStaff() Staff { } // GetListStaffInfoByNotificationAction ... -func (s Staff) GetListStaffInfoByNotificationAction(p model.GetListStaffByNotificationActionRequest) (*model.ResponseListStaffInfoByNotificationAction, error) { - msg, err := natsio.GetServer().Request(subject.Staff.GetListStaffInfoByNotificationAction, toBytes(p)) +func (s Staff) GetListStaffInfoByNotificationAction(p model.GetListStaffRequest) (*model.ResponseListStaffInfo, error) { + msg, err := natsio.GetServer().Request(subject.Staff.GetListStaffInfo, toBytes(p)) if err != nil { return nil, err } var r struct { - Data *model.ResponseListStaffInfoByNotificationAction `json:"data"` - Error string `json:"error"` + Data *model.ResponseListStaffInfo `json:"data"` + Error string `json:"error"` } if err := json.Unmarshal(msg.Data, &r); err != nil { diff --git a/model/staff_request.go b/model/staff_request.go index 904f617..8ee7b67 100644 --- a/model/staff_request.go +++ b/model/staff_request.go @@ -1,8 +1,6 @@ package model -// GetListStaffByNotificationActionRequest ... -type GetListStaffByNotificationActionRequest struct { - CreatedBys []string `json:"createdBys"` - ApprovedBys []string `json:"approvedBys"` - CancelledBys []string `json:"cancelledBys"` +// GetListStaffRequest ... +type GetListStaffRequest struct { + Staffs []string `json:"Staffs"` } diff --git a/model/staff_response.go b/model/staff_response.go index cd471a2..5076d0c 100644 --- a/model/staff_response.go +++ b/model/staff_response.go @@ -1,10 +1,8 @@ package model -// ResponseListStaffInfoByNotificationAction ... -type ResponseListStaffInfoByNotificationAction struct { - CreatedBys []ResponseStaffInfo `json:"CreatedBys"` - ApprovedBys []ResponseStaffInfo `json:"ApprovedBys"` - CancelledBys []ResponseStaffInfo `json:"CancelledBys"` +// ResponseListStaffInfo ... +type ResponseListStaffInfo struct { + Staffs []ResponseStaffInfo `json:"staffs"` } // ResponseStaffInfo ... diff --git a/subject/staff.go b/subject/staff.go index 0cdbcf0..86e72e9 100644 --- a/subject/staff.go +++ b/subject/staff.go @@ -7,7 +7,7 @@ func getStaffValue(val string) string { } var Staff = struct { - GetListStaffInfoByNotificationAction string + GetListStaffInfo string }{ - GetListStaffInfoByNotificationAction: getStaffValue("get_list_staff_info_by_notification_info"), + GetListStaffInfo: getStaffValue("get_list_staff_info_by_notification_info"), } From 2199bb4eef096c1c34a7336427f35efa2da769df Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Fri, 18 Nov 2022 21:49:42 +0700 Subject: [PATCH 082/103] fix get list staff --- client/staff.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/staff.go b/client/staff.go index e2eac0c..b175f53 100644 --- a/client/staff.go +++ b/client/staff.go @@ -15,8 +15,8 @@ func GetStaff() Staff { return Staff{} } -// GetListStaffInfoByNotificationAction ... -func (s Staff) GetListStaffInfoByNotificationAction(p model.GetListStaffRequest) (*model.ResponseListStaffInfo, error) { +// GetListStaffInfoByIds ... +func (s Staff) GetListStaffInfoByIds(p model.GetListStaffRequest) (*model.ResponseListStaffInfo, error) { msg, err := natsio.GetServer().Request(subject.Staff.GetListStaffInfo, toBytes(p)) if err != nil { From be18b81589383d04850c6f34937ad857ab5150fa Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Mon, 21 Nov 2022 00:08:21 +0700 Subject: [PATCH 083/103] [location] update location resp model --- model/location_response.go | 54 +++++++++++++++----------------------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/model/location_response.go b/model/location_response.go index f0b4116..3352a8f 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -1,7 +1,5 @@ package model -import "time" - type ( // ResponseLocationAddress ... ResponseLocationAddress struct { @@ -53,44 +51,34 @@ type ( // LocationProvinceDetailResponse ... LocationProvinceDetailResponse struct { - ID string `json:"_id"` - Name string `json:"name"` - SearchString string `json:"searchString"` - OldSlug string `json:"oldSlug"` - 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"` + Name string `json:"name"` + 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"` } // LocationDistrictDetailResponse ... LocationDistrictDetailResponse struct { - ID string `json:"_id"` - Name string `json:"name"` - SearchString string `json:"searchString"` - OldSlug string `json:"oldSlug"` - 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"` + Name string `json:"name"` + OldSlugs []string `json:"oldSlugs"` + Slug string `json:"slug"` + Code int `json:"code"` + ProvinceCode int `json:"provinceCode"` + Area int `json:"area"` + TotalWards int `json:"totalWards"` } // LocationWardDetailResponse ... LocationWardDetailResponse struct { - ID string `json:"_id"` - Name string `json:"name"` - SearchString string `json:"searchString"` - OldSlugs []string `json:"oldSlugs"` - Code int `json:"code"` - DistrictCode int `json:"districtCode"` - ProvinceCode int `json:"provinceCode"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` + Name string `json:"name"` + OldSlugs []string `json:"oldSlugs"` + Slug string `json:"slug"` + Code int `json:"code"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` } ) From 1a77ac3d8e2093dbfb6761ba3a024f520d86c2b1 Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Mon, 21 Nov 2022 00:29:18 +0700 Subject: [PATCH 084/103] [location] update location resp model --- model/location_response.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/model/location_response.go b/model/location_response.go index 3352a8f..e48bdce 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -51,6 +51,7 @@ type ( // LocationProvinceDetailResponse ... LocationProvinceDetailResponse struct { + ID string `json:"_id"` Name string `json:"name"` Slug string `json:"slug"` Code int `json:"code"` @@ -63,6 +64,7 @@ type ( // LocationDistrictDetailResponse ... LocationDistrictDetailResponse struct { + ID string `json:"_id"` Name string `json:"name"` OldSlugs []string `json:"oldSlugs"` Slug string `json:"slug"` @@ -74,6 +76,7 @@ type ( // LocationWardDetailResponse ... LocationWardDetailResponse struct { + ID string `json:"_id"` Name string `json:"name"` OldSlugs []string `json:"oldSlugs"` Slug string `json:"slug"` From f9c269ce2dc41e9a147307a07f19f0dfd70848d6 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Mon, 21 Nov 2022 08:33:39 +0700 Subject: [PATCH 085/103] change mgs get staff-info --- subject/staff.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subject/staff.go b/subject/staff.go index 86e72e9..f9d6711 100644 --- a/subject/staff.go +++ b/subject/staff.go @@ -9,5 +9,5 @@ func getStaffValue(val string) string { var Staff = struct { GetListStaffInfo string }{ - GetListStaffInfo: getStaffValue("get_list_staff_info_by_notification_info"), + GetListStaffInfo: getStaffValue("get_list_staff_info"), } From 74b88b9a2f92022f7ec5d36801da1bfb1921f3b5 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Mon, 21 Nov 2022 08:55:30 +0700 Subject: [PATCH 086/103] fix --- subject/staff.go | 1 + 1 file changed, 1 insertion(+) diff --git a/subject/staff.go b/subject/staff.go index f9d6711..4777f06 100644 --- a/subject/staff.go +++ b/subject/staff.go @@ -6,6 +6,7 @@ func getStaffValue(val string) string { return fmt.Sprintf("%s.%s", prefixes.Staff, val) } +// Staff ... var Staff = struct { GetListStaffInfo string }{ From f8658523a2d3ac559c8dbf87dc4f197f7cca65d4 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Mon, 21 Nov 2022 10:37:53 +0700 Subject: [PATCH 087/103] change request get staff --- model/staff_request.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/staff_request.go b/model/staff_request.go index 8ee7b67..176b34e 100644 --- a/model/staff_request.go +++ b/model/staff_request.go @@ -2,5 +2,5 @@ package model // GetListStaffRequest ... type GetListStaffRequest struct { - Staffs []string `json:"Staffs"` + StaffIds []string `json:"staffIds"` } From 8b907cec0d42722027128a0b196762bb2eccf490 Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Mon, 21 Nov 2022 15:59:56 +0700 Subject: [PATCH 088/103] new location subject --- subject/location.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/subject/location.go b/subject/location.go index c625ca4..3ee9baf 100644 --- a/subject/location.go +++ b/subject/location.go @@ -8,9 +8,13 @@ func getLocationValue(val string) string { var Location = struct { GetLocationByCode string + GetLocationByCodeNew string GetProvincesByCodes string + GetProvincesByCodesNew string GetDistrictsByCodes string + GetDistrictsByCodesNew string GetWardsByCodes string + GetWardsByCodesNew string GetProvinceByCondition string GetProvincesByCondition string GetDistrictByCondition string @@ -23,9 +27,13 @@ var Location = struct { ProvinceDistinctWithField string }{ GetLocationByCode: getLocationValue("get_location_warehouse"), + GetLocationByCodeNew: getLocationValue("get_location_warehouse_new"), GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), + GetProvincesByCodesNew: getLocationValue("get_provinces_by_codes_new"), GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), + GetDistrictsByCodesNew: getLocationValue("get_districts_by_codes_new"), GetWardsByCodes: getLocationValue("get_wards_by_codes"), + GetWardsByCodesNew: getLocationValue("get_wards_by_codes_new"), GetProvinceByCondition: getLocationValue("get_province_by_condition"), GetProvincesByCondition: getLocationValue("get_provinces_by_condition"), GetDistrictByCondition: getLocationValue("get_district_by_condition"), From e3599d1903f0f94885cda7b14d5ef485ee50d381 Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Mon, 21 Nov 2022 16:20:06 +0700 Subject: [PATCH 089/103] [location] update location subject --- client/location.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/location.go b/client/location.go index db19312..803e33d 100644 --- a/client/location.go +++ b/client/location.go @@ -19,7 +19,7 @@ func GetLocation() Location { // GetLocationByCode ... func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*model.ResponseLocationAddress, error) { - msg, err := natsio.GetServer().Request(subject.Location.GetLocationByCode, toBytes(payload)) + msg, err := natsio.GetServer().Request(subject.Location.GetLocationByCodeNew, toBytes(payload)) if err != nil { return nil, err } @@ -40,7 +40,7 @@ func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*mode // GetProvincesByCodes ... ... func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.LocationProvinceResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCodes, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCodesNew, toBytes(p)) if err != nil { return nil, err } @@ -62,7 +62,7 @@ func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.Lo // GetDistrictsByCodes ... func (l Location) GetDistrictsByCodes(p model.DistrictRequestPayload) (*model.LocationDistrictResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCodes, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCodesNew, toBytes(p)) if err != nil { return nil, err } @@ -84,7 +84,7 @@ func (l Location) GetDistrictsByCodes(p model.DistrictRequestPayload) (*model.Lo // GetWardsByCodes ... func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWardResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCodes, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCodesNew, toBytes(p)) if err != nil { return nil, err } From 0a1c76bb88ad7375cfdbdf40419dd5c4e1e5abe0 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Tue, 22 Nov 2022 05:43:02 +0700 Subject: [PATCH 090/103] add get segment info --- client/segment.go | 40 +++++++++++++++++++++++++++++++++++++++ model/segment_request.go | 6 ++++++ model/segment_response.go | 12 ++++++++++++ subject/config.go | 1 + subject/segment.go | 14 ++++++++++++++ 5 files changed, 73 insertions(+) create mode 100644 client/segment.go create mode 100644 model/segment_request.go create mode 100644 model/segment_response.go create mode 100644 subject/segment.go diff --git a/client/segment.go b/client/segment.go new file mode 100644 index 0000000..ec937c8 --- /dev/null +++ b/client/segment.go @@ -0,0 +1,40 @@ +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" +) + +// Segment ... +type Segment struct{} + +// GetSegment ... +func GetSegment() Segment { + return Segment{} +} + +func (s Segment) GetListSegmentInfoByIds(p model.GetListSegmentRequest) (*model.ResponseListSegmentInfo, error) { + msg, err := natsio.GetServer().Request(subject.Segment.GetListSegmentInfo, toBytes(p)) + + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseListSegmentInfo `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/segment_request.go b/model/segment_request.go new file mode 100644 index 0000000..138f347 --- /dev/null +++ b/model/segment_request.go @@ -0,0 +1,6 @@ +package model + +// GetListSegmentRequest ... +type GetListSegmentRequest struct { + SegmentIds []string `json:"segmentIds"` +} diff --git a/model/segment_response.go b/model/segment_response.go new file mode 100644 index 0000000..84a1571 --- /dev/null +++ b/model/segment_response.go @@ -0,0 +1,12 @@ +package model + +// ResponseSegmentInfo ... +type ResponseSegmentInfo struct { + ID string `json:"_id"` + Name string `json:"name"` +} + +// ResponseListSegmentInfo ... +type ResponseListSegmentInfo struct { + Segments []ResponseSegmentInfo `json:"segments"` +} diff --git a/subject/config.go b/subject/config.go index 6988929..0df1b9e 100644 --- a/subject/config.go +++ b/subject/config.go @@ -18,6 +18,7 @@ var prefixes = struct { Notification string SocialPost string Staff string + Segment string }{ Communication: "communication", Order: "order", diff --git a/subject/segment.go b/subject/segment.go new file mode 100644 index 0000000..54d5b7e --- /dev/null +++ b/subject/segment.go @@ -0,0 +1,14 @@ +package subject + +import "fmt" + +func getSegmentValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Segment, val) +} + +// Segment ... +var Segment = struct { + GetListSegmentInfo string +}{ + GetListSegmentInfo: getSegmentValue("get_list_segment_info"), +} From 2719017b61798a38ebff3d137aa4a21f6e4c2ffd Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Tue, 22 Nov 2022 05:44:36 +0700 Subject: [PATCH 091/103] add cmt --- client/segment.go | 1 + subject/segment.go | 1 + 2 files changed, 2 insertions(+) diff --git a/client/segment.go b/client/segment.go index ec937c8..bcc7bab 100644 --- a/client/segment.go +++ b/client/segment.go @@ -16,6 +16,7 @@ func GetSegment() Segment { return Segment{} } +// GetListSegmentInfoByIds ... func (s Segment) GetListSegmentInfoByIds(p model.GetListSegmentRequest) (*model.ResponseListSegmentInfo, error) { msg, err := natsio.GetServer().Request(subject.Segment.GetListSegmentInfo, toBytes(p)) diff --git a/subject/segment.go b/subject/segment.go index 54d5b7e..f6021ca 100644 --- a/subject/segment.go +++ b/subject/segment.go @@ -2,6 +2,7 @@ package subject import "fmt" +// getSegmentValue ... func getSegmentValue(val string) string { return fmt.Sprintf("%s.%s", prefixes.Segment, val) } From ede51d03d01a73414222bf10ea750c9e5454cd1b Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Tue, 22 Nov 2022 11:52:16 +0700 Subject: [PATCH 092/103] add value config get segment --- subject/config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/subject/config.go b/subject/config.go index 0df1b9e..1042aa2 100644 --- a/subject/config.go +++ b/subject/config.go @@ -37,4 +37,5 @@ var prefixes = struct { Notification: "notification", SocialPost: "social_post", Staff: "staff", + Segment: "segment", } From fa693cc60b82d8c9936b00af32568a7c9a2990eb Mon Sep 17 00:00:00 2001 From: Sinh Date: Thu, 24 Nov 2022 09:45:53 +0700 Subject: [PATCH 093/103] fix nats --- client/segmnet.go | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 client/segmnet.go diff --git a/client/segmnet.go b/client/segmnet.go deleted file mode 100644 index bcc7bab..0000000 --- a/client/segmnet.go +++ /dev/null @@ -1,41 +0,0 @@ -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" -) - -// Segment ... -type Segment struct{} - -// GetSegment ... -func GetSegment() Segment { - return Segment{} -} - -// GetListSegmentInfoByIds ... -func (s Segment) GetListSegmentInfoByIds(p model.GetListSegmentRequest) (*model.ResponseListSegmentInfo, error) { - msg, err := natsio.GetServer().Request(subject.Segment.GetListSegmentInfo, toBytes(p)) - - if err != nil { - return nil, err - } - - var r struct { - Data *model.ResponseListSegmentInfo `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 -} From 437a67e4b4e41e863004e5bfd318fb85110242a6 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 30 Nov 2022 17:39:41 +0700 Subject: [PATCH 094/103] add warehouse subject --- subject/warehouse.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subject/warehouse.go b/subject/warehouse.go index bb184b5..689f004 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -15,6 +15,7 @@ var Warehouse = struct { GetConfiguration string SyncORStatus string WebhookTNC string + WebhookShiip string WebhookGlobalCare string WebhookOnPoint string FindOne string @@ -37,6 +38,7 @@ var Warehouse = struct { GetConfiguration: getWarehouseValue("get_configuration"), SyncORStatus: getWarehouseValue("sync_or_status"), WebhookTNC: getWarehouseValue("webhook_tnc"), + WebhookShiip: getWarehouseValue("webhook_shiip"), WebhookGlobalCare: getWarehouseValue("webhook_global_care"), WebhookOnPoint: getWarehouseValue("webhook_on_point"), FindOne: getWarehouseValue("find_one"), From 46539db23609d8cf226fc77f0d36c2645f008613 Mon Sep 17 00:00:00 2001 From: Sinh Date: Fri, 9 Dec 2022 10:05:41 +0700 Subject: [PATCH 095/103] update get warehouse condition --- model/warehouse_request.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index b6cecb1..56adb1b 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -97,10 +97,11 @@ type SupplierIsClosed struct { // GetWarehousesRequest ... type GetWarehousesRequest struct { - Keyword string `json:"keyword"` - Status string `json:"status"` - Supplier string `json:"supplier"` - BusinessType string `json:"businessType"` + Keyword string `json:"keyword"` + Status string `json:"status"` + Supplier string `json:"supplier"` + BusinessType string `json:"businessType"` + IDs []string `json:"ids"` Page int64 `json:"page"` Limit int64 `json:"limit"` From b19fea04c8b9d76c66f1b3028d32af1ab3fceb1c Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 26 Dec 2022 14:08:14 +0700 Subject: [PATCH 096/103] define nats product --- client/product.go | 35 +++++++++++++++++++++++++++++++++++ model/product_request.go | 5 +++++ subject/config.go | 2 ++ subject/product.go | 14 ++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 client/product.go create mode 100644 model/product_request.go create mode 100644 subject/product.go diff --git a/client/product.go b/client/product.go new file mode 100644 index 0000000..340ba21 --- /dev/null +++ b/client/product.go @@ -0,0 +1,35 @@ +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" +) + +// Product ... +type Product struct{} + +// GetProduct ... +func GetProduct() Product { + return Product{} +} + +func (c Product) ApplyRequest(p model.ProductApplyRequestPayload) error { + msg, err := natsio.GetServer().Request(subject.Product.ApplyRequest, 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/product_request.go b/model/product_request.go new file mode 100644 index 0000000..1adbec5 --- /dev/null +++ b/model/product_request.go @@ -0,0 +1,5 @@ +package model + +type ProductApplyRequestPayload struct { + RequestID string `json:"requestId"` +} diff --git a/subject/config.go b/subject/config.go index 1954121..483f963 100644 --- a/subject/config.go +++ b/subject/config.go @@ -14,6 +14,7 @@ var prefixes = struct { SocialPost string Staff string Segment string + Product string Campaign string Affiliate string }{ @@ -30,6 +31,7 @@ var prefixes = struct { SocialPost: "social_post", Staff: "staff", Segment: "segment", + Product: "product", Campaign: "campaign", Affiliate: "affiliate", } diff --git a/subject/product.go b/subject/product.go new file mode 100644 index 0000000..3911ecb --- /dev/null +++ b/subject/product.go @@ -0,0 +1,14 @@ +package subject + +import "fmt" + +// getSegmentValue ... +func getProductValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Product, val) +} + +var Product = struct { + ApplyRequest string +}{ + ApplyRequest: getProductValue("apply_request"), +} From e66596baf6b9270ec7df4502ccfd43a6c25116eb Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 26 Dec 2022 15:12:48 +0700 Subject: [PATCH 097/103] define nats queue --- model/queue_request.go | 8 ++++++++ subject/config.go | 2 ++ subject/queue.go | 13 +++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 model/queue_request.go create mode 100644 subject/queue.go diff --git a/model/queue_request.go b/model/queue_request.go new file mode 100644 index 0000000..87b7410 --- /dev/null +++ b/model/queue_request.go @@ -0,0 +1,8 @@ +package model + +type QueueScheduleTaskRequest struct { + ID string `json:"id"` + NatsSubject string `json:"natsSubject"` + Data string `json:"data"` + StartAt int64 `json:"startAt"` // unix +} diff --git a/subject/config.go b/subject/config.go index 483f963..0ba5952 100644 --- a/subject/config.go +++ b/subject/config.go @@ -15,6 +15,7 @@ var prefixes = struct { Staff string Segment string Product string + Queue string Campaign string Affiliate string }{ @@ -32,6 +33,7 @@ var prefixes = struct { Staff: "staff", Segment: "segment", Product: "product", + Queue: "queue", Campaign: "campaign", Affiliate: "affiliate", } diff --git a/subject/queue.go b/subject/queue.go new file mode 100644 index 0000000..87a84ef --- /dev/null +++ b/subject/queue.go @@ -0,0 +1,13 @@ +package subject + +import "fmt" + +func getQueueValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Queue, val) +} + +var Queue = struct { + ScheduleTask string +}{ + ScheduleTask: getQueueValue("schedule_task"), +} From 252c82f1e46dffbfbeceab75b049759e2c2b35c2 Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 26 Dec 2022 15:16:46 +0700 Subject: [PATCH 098/103] add client queue --- client/queue.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 client/queue.go diff --git a/client/queue.go b/client/queue.go new file mode 100644 index 0000000..8cb048d --- /dev/null +++ b/client/queue.go @@ -0,0 +1,35 @@ +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" +) + +// Queue ... +type Queue struct{} + +// GetQueue ... +func GetQueue() Queue { + return Queue{} +} + +func (c Queue) ScheduleTask(p model.QueueScheduleTaskRequest) error { + msg, err := natsio.GetServer().Request(subject.Queue.ScheduleTask, 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 cdccf315712d2b49b9afd0bde5311050edc5b240 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Tue, 3 Jan 2023 09:11:55 +0700 Subject: [PATCH 099/103] add response --- model/supplier_response.go | 54 +++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/model/supplier_response.go b/model/supplier_response.go index 2b9dd10..c0e193d 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -2,9 +2,57 @@ package model // ResponseSupplierInfo ... type ResponseSupplierInfo struct { - ID string `json:"id"` - Name string `json:"name"` - BusinessType string `json:"businessType"` + ID string `json:"id"` + Name string `json:"name"` + BusinessType string `json:"businessType"` + Statistic *SupplierStatistic `json:"statistic"` + Rating float64 `json:"rating"` + Inventories *SKUCommonInfo `json:"inventories"` + Active bool `json:"active"` +} + +// SupplierStatistic ... +type SupplierStatistic struct { + TotalInventory int64 `json:"totalInventory"` + TotalQuantitySale int64 `json:"totalQuantitySale"` + TotalProduct int64 `json:"totalProduct"` + TotalHasOrderSeller int64 `json:"totalHasOrderSeller"` + TotalFollower int64 `json:"totalFollower"` + SalesTotal float64 `json:"salesTotal"` + SalesWeekTotal float64 `json:"salesWeekTotal"` + SalesMonthTotal float64 `json:"salesMonthTotal"` + SalesTwoMonthTotal float64 `json:"salesTwoMonthTotal"` + SalesYearTotal float64 `json:"salesYearTotal"` + SalesSuccess float64 `json:"salesSuccess"` + SalesPending float64 `json:"salesPending"` + SalesCancelled float64 `json:"salesCancelled"` +} + +// SKUCommonInfo ... +type SKUCommonInfo struct { + Code int `json:"id,omitempty" bson:"id,omitempty"` + ID string `json:"_id" bson:"_id"` + Name string `json:"name" bson:"name"` + SearchString string `json:"-" bson:"searchString,omitempty"` + Location *LocationInventory `json:"location,omitempty" bson:"location,omitempty"` + MinimumValue float64 `json:"minimumValue,omitempty" bson:"-"` +} + +// LocationInventory ... +type LocationInventory struct { + Address string `bson:"address" json:"address"` + Province string `bson:"province" json:"province"` + ProvinceName string `bson:"provinceName,omitempty" json:"provinceName,omitempty"` + District string `bson:"district" json:"district"` + Ward string `bson:"ward" json:"ward"` + FullAddress string `bson:"fullAddress,omitempty" json:"fullAddress,omitempty"` + Location *MongoLocation `bson:"location" json:"location"` +} + +// MongoLocation ... +type MongoLocation struct { + Type string `bson:"type"` + Coordinates []float64 `bson:"coordinates"` } // ResponseSupplierContract ... From 6ed64beecbef3b4cdbb80e12790d94925c03a725 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Tue, 3 Jan 2023 09:21:06 +0700 Subject: [PATCH 100/103] update --- model/supplier_response.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/model/supplier_response.go b/model/supplier_response.go index c0e193d..9c47a05 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -2,13 +2,13 @@ package model // ResponseSupplierInfo ... type ResponseSupplierInfo struct { - ID string `json:"id"` - Name string `json:"name"` - BusinessType string `json:"businessType"` - Statistic *SupplierStatistic `json:"statistic"` - Rating float64 `json:"rating"` - Inventories *SKUCommonInfo `json:"inventories"` - Active bool `json:"active"` + ID string `json:"id"` + Name string `json:"name"` + BusinessType string `json:"businessType"` + Statistic SupplierStatistic `json:"statistic"` + Rating float64 `json:"rating"` + Inventories *[]SKUCommonInfo `json:"inventories"` + Active bool `json:"active"` } // SupplierStatistic ... From e4436002e820adb5ddc0a4210fc1aa36177fdb7a Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Tue, 3 Jan 2023 09:23:34 +0700 Subject: [PATCH 101/103] update --- model/supplier_response.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/supplier_response.go b/model/supplier_response.go index 9c47a05..36f9666 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -7,7 +7,7 @@ type ResponseSupplierInfo struct { BusinessType string `json:"businessType"` Statistic SupplierStatistic `json:"statistic"` Rating float64 `json:"rating"` - Inventories *[]SKUCommonInfo `json:"inventories"` + Inventories []*SKUCommonInfo `json:"inventories"` Active bool `json:"active"` } From 1edc683dd5e5afec7a97139d861d8892ecab458e Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 9 Jan 2023 15:56:46 +0700 Subject: [PATCH 102/103] add subject process product req --- client/product.go | 17 +++++++++++++++++ subject/product.go | 6 ++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/client/product.go b/client/product.go index 340ba21..a581b9d 100644 --- a/client/product.go +++ b/client/product.go @@ -33,3 +33,20 @@ func (c Product) ApplyRequest(p model.ProductApplyRequestPayload) error { } return nil } + +func (c Product) ProcessApplyRequest(p model.ProductApplyRequestPayload) error { + msg, err := natsio.GetServer().Request(subject.Product.ProcessApplyRequest, 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/subject/product.go b/subject/product.go index 3911ecb..348aca9 100644 --- a/subject/product.go +++ b/subject/product.go @@ -8,7 +8,9 @@ func getProductValue(val string) string { } var Product = struct { - ApplyRequest string + ApplyRequest string + ProcessApplyRequest string }{ - ApplyRequest: getProductValue("apply_request"), + ApplyRequest: getProductValue("apply_request"), + ProcessApplyRequest: getProductValue("process_apply_request"), } From f69ac3ba0cd7379baf428cc085ecb5bf80415819 Mon Sep 17 00:00:00 2001 From: quang Date: Mon, 16 Jan 2023 14:03:09 +0700 Subject: [PATCH 103/103] test --- model/location_request.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/location_request.go b/model/location_request.go index e4312ce..47ddd01 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -2,6 +2,7 @@ package model // LocationRequestPayload ... type ( + // LocationRequestPayload ... LocationRequestPayload struct { Province int `json:"province"` District int `json:"district"`