diff --git a/client/bank.go b/client/bank.go deleted file mode 100644 index 5650b2f..0000000 --- a/client/bank.go +++ /dev/null @@ -1,39 +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" -) - -// Bank ... -type Bank struct{} - -// GetBank ... -func GetBank() Bank { - return Bank{} -} - -func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) { - msg, err := natsio.GetServer().Request(subject.Bank.GetBankById, toBytes(bankID)) - if err != nil { - return nil, err - } - - var r struct { - Data *model.BankBrief `json:"data"` - Error string `json:"error"` - } - - if err = json.Unmarshal(msg.Data, &r); err != nil { - return nil, err - } - if r.Error != "" { - return nil, errors.New(r.Error) - } - - return r.Data, nil -} diff --git a/client/bank_branch.go b/client/bank_branch.go deleted file mode 100644 index 0ca9460..0000000 --- a/client/bank_branch.go +++ /dev/null @@ -1,39 +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" -) - -// 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/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/client/supplier.go b/client/supplier.go index 41a1849..700d714 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -79,39 +79,3 @@ func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.Suppl 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)) - 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/js/consumer/selly.go b/js/consumer/selly.go new file mode 100644 index 0000000..380927c --- /dev/null +++ b/js/consumer/selly.go @@ -0,0 +1,8 @@ +package jsconsumer + +// Selly ... +var Selly = struct { + PushNotification string +}{ + PushNotification: "PULL_PUSH_NOTIFICATION", +} diff --git a/js/model/selly.go b/js/model/selly.go index 053a3be..ab8d021 100644 --- a/js/model/selly.go +++ b/js/model/selly.go @@ -2,13 +2,16 @@ package jsmodel // PushNotification ... type PushNotification struct { - User string `json:"user"` - Type string `json:"type"` - TargetID string `json:"targetId"` - IsFromAdmin bool `json:"isFromAdmin"` - Category string `json:"category"` - Options struct { - Title string `json:"title"` - Content string `json:"content"` - } `json:"options"` + User string `json:"user"` + Type string `json:"type"` + TargetID string `json:"targetId"` + IsFromAdmin bool `json:"isFromAdmin"` + Category string `json:"category"` + Options NotificationOptions `json:"options"` +} + +// NotificationOptions ... +type NotificationOptions struct { + Title string `json:"title"` + Content string `json:"content"` } 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_response.go b/model/bank_response.go deleted file mode 100644 index 74fc10e..0000000 --- a/model/bank_response.go +++ /dev/null @@ -1,21 +0,0 @@ -package model - -// MultiLang ... -type MultiLang struct { - En string `json:"en"` - Vi string `json:"vi"` -} - -// BankBrief ... -type BankBrief struct { - ID string `json:"_id"` - Name MultiLang `json:"name"` - ShortName string `json:"shortName"` - Active bool `json:"active"` - BenBankName string `json:"benBankName"` - BankCode int `json:"bankCode"` - IsBranchRequired bool `json:"isBranchRequired"` - SearchString string `json:"searchString"` - BeneficiaryForVietinbank string `json:"beneficiaryForVietinbank"` - CreatedBy string `json:"createdBy,omitempty"` -} diff --git a/model/location_response.go b/model/location_response.go index 2674041..484d89e 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -1,93 +1,43 @@ package model -import "time" +type ResponseLocationAddress struct { + Province LocationProvince `json:"province"` + District LocationDistrict `json:"district"` + Ward LocationWard `json:"ward"` +} -type ( - // ResponseLocationAddress ... - ResponseLocationAddress struct { - Province LocationProvince `json:"province"` - District LocationDistrict `json:"district"` - Ward LocationWard `json:"ward"` - } +// LocationProvince ... +type LocationProvince 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"` - } +// LocationDistrict ... +type LocationDistrict 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"` - } +// LocationWard ... +type LocationWard struct { + ID string `json:"id"` + Name string `json:"name"` + Code int `json:"code"` +} - // LocationWard ... - LocationWard struct { - ID string `json:"id"` - Name string `json:"name"` - Code int `json:"code"` - } +// LocationProvinceResponse ... +type LocationProvinceResponse struct { + Provinces []LocationProvince `json:"provinces"` +} - // LocationProvinceResponse ... - LocationProvinceResponse struct { - Provinces []LocationProvince `json:"provinces"` - } +// LocationDistrictResponse ... +type LocationDistrictResponse struct { + Districts []LocationDistrict `json:"districts"` +} - // 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"` - } -) +// LocationWardResponse ... +type LocationWardResponse struct { + Wards []LocationWard `json:"wards"` +} diff --git a/model/supplier_request.go b/model/supplier_request.go index 5a19924..04d15d5 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -22,19 +22,3 @@ type SupplierRequestPayload struct { PIC string ContractStatus string } - -type CreateSupplierWarehousePayload struct { - Supplier string `json:"supplier"` - Warehouse string `json:"warehouse"` - ProvinceCode int `json:"provinceCode"` - DistrictCode int `json:"districtCode"` - WardCode int `json:"wardCode"` -} - -type UpdateSupplierWarehousePayload struct { - Supplier string `json:"supplier"` - Warehouse string `json:"warehouse"` - ProvinceCode int `json:"provinceCode"` - DistrictCode int `json:"districtCode"` - WardCode int `json:"wardCode"` -} diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 663cfaa..b546725 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -29,11 +29,9 @@ type InsuranceOpts struct { // OutboundRequestItem ... type OutboundRequestItem struct { - SupplierSKU string `json:"supplierSKU"` - Quantity int64 `json:"quantity"` - UnitCode string `json:"unitCode"` - Price float64 `json:"price"` - Name string `json:"name"` + SupplierSKU string `json:"supplierSKU"` + Quantity int64 `json:"quantity"` + UnitCode string `json:"unitCode"` } // CustomerInfo ... @@ -58,7 +56,6 @@ type UpdateOutboundRequestLogisticInfoPayload struct { ShippingLabel string `json:"shippingLabel"` TrackingCode string `json:"trackingCode"` ORCode string `json:"orCode"` - TPLCode string `json:"tplCode"` } // CancelOutboundRequest ... diff --git a/subject/bank.go b/subject/bank.go deleted file mode 100644 index a991d5d..0000000 --- a/subject/bank.go +++ /dev/null @@ -1,15 +0,0 @@ -package subject - -import "fmt" - -func getBankValue(val string) string { - return fmt.Sprintf("%s.%s", prefixes.Bank, val) -} - -var Bank = struct { - GetBankById string - GetBankBranchById string -}{ - GetBankById: getBankValue("get_bank_by_id"), - GetBankBranchById: getBankValue("get_bank_branch_by_id"), -} diff --git a/subject/config.go b/subject/config.go index 4a2f9f3..7a69414 100644 --- a/subject/config.go +++ b/subject/config.go @@ -6,7 +6,6 @@ var prefixes = struct { News string Warehouse string Location string - Bank string Supplier string Seller string }{ @@ -16,6 +15,5 @@ var prefixes = struct { Warehouse: "warehouse", Location: "location", Supplier: "supplier", - Bank: "bank", Seller: "seller", } diff --git a/subject/location.go b/subject/location.go index 7525c25..b19a59b 100644 --- a/subject/location.go +++ b/subject/location.go @@ -7,31 +7,13 @@ 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 }{ - 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"), } diff --git a/subject/warehouse.go b/subject/warehouse.go index cbebba0..a0480ae 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -14,7 +14,6 @@ var Warehouse = struct { SyncORStatus string WebhookTNC string WebhookGlobalCare string - WebhookOnPoint string FindOne string FindByCondition string Distinct string @@ -22,8 +21,6 @@ var Warehouse = struct { AfterUpdateWarehouse string AfterCreateWarehouse string UpdateIsClosedSupplier string - CreateWarehouseIntoServiceSupplier string - UpdateWarehouseIntoServiceSupplier string }{ AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), @@ -34,12 +31,9 @@ var Warehouse = struct { SyncORStatus: getWarehouseValue("sync_or_status"), WebhookTNC: getWarehouseValue("webhook_tnc"), WebhookGlobalCare: getWarehouseValue("webhook_global_care"), - WebhookOnPoint: getWarehouseValue("webhook_on_point"), FindOne: getWarehouseValue("find_one"), FindByCondition: getWarehouseValue("find_all_by_condition"), Distinct: getWarehouseValue("distinct"), Count: getWarehouseValue("count"), UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), - CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), - UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), }