diff --git a/client/location.go b/client/location.go index 2e8d30e..7fc3474 100644 --- a/client/location.go +++ b/client/location.go @@ -17,7 +17,6 @@ func GetLocation() Location { return Location{} } -// GetLocationByCode ... func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*model.ResponseLocationAddress, error) { msg, err := natsio.GetServer().Request(subject.Location.GetLocationByCode, toBytes(payload)) if err != nil { @@ -37,70 +36,3 @@ func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*mode } return r.Data, nil } - -// GetProvincesByCodes ... ... -func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.LocationProvinceResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCodes, toBytes(p)) - if err != nil { - return nil, err - } - - var r struct { - Data *model.LocationProvinceResponse `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 -} - -// GetDistrictsByCodes ... -func (l Location) GetDistrictsByCodes(p model.DistrictRequestPayload) (*model.LocationDistrictResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCodes, toBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data *model.LocationDistrictResponse `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 -} - -// GetWardsByCodes ... -func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWardResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCodes, toBytes(p)) - if err != nil { - return nil, err - } - - var r struct { - Data *model.LocationWardResponse `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/order.go b/client/order.go index 8834495..4379747 100644 --- a/client/order.go +++ b/client/order.go @@ -50,35 +50,3 @@ func (o Order) CancelDelivery(p model.OrderCancelDelivery) error { } return nil } - -// ChangeDeliveryStatus ... -func (o Order) ChangeDeliveryStatus(p model.OrderChangeDeliveryStatus) error { - msg, err := natsio.GetServer().Request(subject.Order.ChangeDeliveryStatus, 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 -} - -// UpdateLogisticInfoFailed ... -func (o Order) UpdateLogisticInfoFailed(p model.OrderUpdateLogisticInfoFailed) error { - msg, err := natsio.GetServer().Request(subject.Order.UpdateLogisticInfoFailed, 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/client/supplier.go b/client/supplier.go index 700d714..5b4881a 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -58,24 +58,3 @@ func (s Supplier) GetSupplierContractBySupplierID(p model.GetSupplierContractReq return r.Data, nil } - -func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.SupplierAll, error) { - msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID)) - if err != nil { - return nil, err - } - - var r struct { - Data *model.SupplierAll `json:"data"` - Error string `json:"error"` - } - - if err = json.Unmarshal(msg.Data, &r); err != nil { - return nil, err - } - if r.Error != "" { - return nil, errors.New(r.Error) - } - - return r.Data, nil -} diff --git a/model/common_request.go b/model/common_request.go index 0ce5163..4d6a719 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -15,8 +15,3 @@ type DistinctWithField struct { Conditions interface{} `json:"conditions"` Filed string `json:"filed"` } - -type ActionBy struct { - ID string `json:"id"` - Name string `json:"name"` -} diff --git a/model/location_request.go b/model/location_request.go index 4533db7..e6781ca 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -6,18 +6,3 @@ type LocationRequestPayload struct { District int `json:"district"` Ward int `json:"ward"` } - -// ProvinceRequestPayload ... -type ProvinceRequestPayload struct { - Codes []int `json:"codes"` -} - -// DistrictRequestPayload ... -type DistrictRequestPayload struct { - Codes []int `json:"codes"` -} - -// WardRequestPayload ... -type WardRequestPayload struct { - Codes []int `json:"codes"` -} diff --git a/model/location_response.go b/model/location_response.go index 484d89e..436d1f7 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -26,18 +26,3 @@ type LocationWard struct { Name string `json:"name"` Code int `json:"code"` } - -// LocationProvinceResponse ... -type LocationProvinceResponse struct { - Provinces []LocationProvince `json:"provinces"` -} - -// LocationDistrictResponse ... -type LocationDistrictResponse struct { - Districts []LocationDistrict `json:"districts"` -} - -// LocationWardResponse ... -type LocationWardResponse struct { - Wards []LocationWard `json:"wards"` -} diff --git a/model/order_request.go b/model/order_request.go index 48bbb79..da9d4fe 100644 --- a/model/order_request.go +++ b/model/order_request.go @@ -2,34 +2,13 @@ package model // OrderUpdateORStatus ... type OrderUpdateORStatus struct { - OrderCode string `json:"orderCode"` - ORCode string `json:"orCode"` - Status string `json:"status"` - DeliveryStatus string `json:"deliveryStatus"` - Reason string `json:"reason"` - Data OrderORData `json:"data"` + OrderCode string `json:"orderCode"` + ORCode string `json:"orCode"` + Status string `json:"status"` + Reason string `json:"reason"` } // OrderCancelDelivery ... type OrderCancelDelivery struct { OrderID string `json:"orderId"` } - -// OrderChangeDeliveryStatus ... -type OrderChangeDeliveryStatus struct { - OrderID string `json:"orderId"` - DeliveryStatus string `json:"deliveryStatus"` - ActionBy ActionBy `json:"actionBy"` -} - -// OrderORData ... -type OrderORData struct { - Link string `json:"link"` -} - -// OrderUpdateLogisticInfoFailed ... -type OrderUpdateLogisticInfoFailed struct { - OrderID string `json:"orderId"` - ORCode string `json:"orCode"` - Reason string `json:"reason"` -} diff --git a/model/supplier_request.go b/model/supplier_request.go index 04d15d5..8372569 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -12,13 +12,3 @@ type GetSupplierRequest struct { type GetSupplierContractRequest struct { SupplierID primitive.ObjectID `json:"supplierID"` } - -// SupplierRequestPayload ... -type SupplierRequestPayload struct { - Limit int - Page int - Keyword string - Status string - PIC string - ContractStatus string -} diff --git a/model/supplier_response.go b/model/supplier_response.go index a87a29e..da33a9f 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -13,17 +13,3 @@ type ResponseSupplierContract struct { Name string `json:"name"` Status string `json:"status"` } - -// SupplierBrief ... -type SupplierBrief struct { - ID string `json:"_id"` - Name string `json:"name"` - Status string `json:"status"` - CreatedAt string `json:"createdAt"` - UpdatedAt string `json:"updatedAt"` -} - -type SupplierAll struct { - Suppliers []SupplierBrief `json:"suppliers"` - Total int64 `json:"total"` -} diff --git a/model/warehouse_request.go b/model/warehouse_request.go index f63b135..5612532 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -12,19 +12,6 @@ type OutboundRequestPayload struct { TPLCode string `json:"tplCode"` Customer CustomerInfo `json:"customer"` Items []OutboundRequestItem `json:"items"` - Insurance *InsuranceOpts -} - -// InsuranceOpts ... -type InsuranceOpts struct { - VehicleTypeID string `json:"vehicleTypeId"` - VehicleTypeName string `json:"vehicleTypeName"` - InsuranceTypeID string `json:"insuranceTypeId"` - YearsOfInsurance int `json:"yearsOfInsurance"` - License string `json:"license"` - Chassis string `json:"chassis"` - Engine string `json:"engine"` - BeginDate string `json:"beginDate"` } // OutboundRequestItem ... @@ -38,7 +25,6 @@ type OutboundRequestItem struct { type CustomerInfo struct { Name string `json:"name"` PhoneNumber string `json:"phoneNumber"` - Email string `json:"email"` Address AddressDetail `json:"address"` } @@ -63,9 +49,3 @@ type CancelOutboundRequest struct { ORCode string `json:"orCode"` Note string `json:"note"` } - -// SyncORStatusRequest ... -type SyncORStatusRequest struct { - ORCode string `json:"orCode"` - OrderCode string `json:"orderCode"` -} diff --git a/model/warehouse_response.go b/model/warehouse_response.go index bc0baaf..f394770 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -68,14 +68,6 @@ type WarehousePartner struct { Authentication string `json:"authentication"` } -// SyncORStatusResponse ... -type SyncORStatusResponse struct { - ORCode string `json:"orCode"` - OrderCode string `json:"orderCode"` - Status string `json:"status"` - DeliveryStatus string `json:"deliveryStatus"` -} - // ResponseWarehouseContact ... type ResponseWarehouseContact struct { Name string `json:"name"` @@ -108,6 +100,7 @@ type ResponseLatLng struct { // WarehouseNatsResponse ... type WarehouseNatsResponse struct { ID string `json:"_id"` + Staff string `json:"staff"` Name string `json:"name"` SearchString string `json:"searchString"` Slug string `json:"slug"` diff --git a/server_reqres.go b/server_reqres.go index 8979ab0..841f9ef 100644 --- a/server_reqres.go +++ b/server_reqres.go @@ -18,11 +18,7 @@ func (sv Server) Request(subject string, payload []byte) (*nats.Msg, error) { if sv.Config.RequestTimeout > 0 { timeout = sv.Config.RequestTimeout } - msg, err := sv.instance.Request(subject, payload, timeout) - if errors.Is(err, nats.ErrNoResponders) { - log.Printf("[NATS SERVER]: request - no responders for subject: %s", subject) - } - return msg, err + return sv.instance.Request(subject, payload, timeout) } // Reply ... diff --git a/subject/communication.go b/subject/communication.go index 80926f2..bcbbe31 100644 --- a/subject/communication.go +++ b/subject/communication.go @@ -7,9 +7,13 @@ func getCommunicationValue(val string) string { } var Communication = struct { - RequestHTTP string - ResponseHTTP string + RequestHTTP string + ResponseHTTP string + WebhookTNC string + WebhookGlobalCare string }{ - RequestHTTP: getCommunicationValue("request_http"), - ResponseHTTP: getCommunicationValue("response_http"), + RequestHTTP: getCommunicationValue("request_http"), + ResponseHTTP: getCommunicationValue("response_http"), + WebhookTNC: getCommunicationValue("webhook_tnc"), + WebhookGlobalCare: getCommunicationValue("webhook_global_care"), } diff --git a/subject/location.go b/subject/location.go index b19a59b..1989df3 100644 --- a/subject/location.go +++ b/subject/location.go @@ -7,13 +7,7 @@ func getLocationValue(val string) string { } var Location = struct { - GetLocationByCode string - GetProvincesByCodes string - GetDistrictsByCodes string - GetWardsByCodes string + GetLocationByCode 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"), } diff --git a/subject/order.go b/subject/order.go index 40f190e..846cee5 100644 --- a/subject/order.go +++ b/subject/order.go @@ -7,13 +7,11 @@ func getOrderValue(val string) string { } var Order = struct { - UpdateORStatus string - CancelDelivery string - ChangeDeliveryStatus string - UpdateLogisticInfoFailed string + UpdateORStatus string + CancelDelivery string + WebhookTNC string + WebhookGlobalCare string }{ - UpdateORStatus: getOrderValue("update_outbound_request_status"), - CancelDelivery: getOrderValue("cancel_delivery"), - ChangeDeliveryStatus: getOrderValue("change_delivery_status"), - UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"), + UpdateORStatus: getOrderValue("update_outbound_request_status"), + CancelDelivery: getOrderValue("cancel_delivery"), } diff --git a/subject/supplier.go b/subject/supplier.go index 17ca8d0..b2505cf 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -9,9 +9,7 @@ func getSupplierValue(val string) string { var Supplier = struct { GetListSupplierInfo string GetSupplierContractBySupplierID string - FindAll string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), - FindAll: getSupplierValue("find_all"), } diff --git a/subject/warehouse.go b/subject/warehouse.go index 5d0a81c..73c5334 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -11,9 +11,6 @@ var Warehouse = struct { UpdateOutboundRequestLogistic string CancelOutboundRequest string GetConfiguration string - SyncORStatus string - WebhookTNC string - WebhookGlobalCare string FindOne string FindByCondition string Distinct string @@ -27,9 +24,6 @@ var Warehouse = struct { 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"),