From daac1da25daf78fb46456924e11fca0b2bb15c60 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Fri, 23 Dec 2022 14:47:09 +0700 Subject: [PATCH] delete suppler-holiday && add checkTokenSupplier --- client/supplier.go | 20 ++++++++++++ client/warehouse.go | 63 ------------------------------------- model/supplier_request.go | 5 +++ model/warehouse_request.go | 27 ---------------- model/warehouse_response.go | 17 ---------- subject/supplier.go | 2 ++ subject/warehouse.go | 6 ---- 7 files changed, 27 insertions(+), 113 deletions(-) diff --git a/client/supplier.go b/client/supplier.go index 9b53826..b10f982 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -178,3 +178,23 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh } return nil } + +// CheckTokenSupplier ... +func (s Supplier) CheckTokenSupplier(p model.CheckTokenSupplierPayload) (*model.ResponseSupplierInfo, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.CheckTokenSupplier, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Error string `json:"error"` + Data *model.ResponseSupplierInfo `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/client/warehouse.go b/client/warehouse.go index 664df43..fb391ca 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -182,66 +182,3 @@ func (w Warehouse) UpdateORDeliveryStatus(p model.WarehouseORUpdateDeliveryStatu } return nil } - -// CreateSupplierHoliday ... -func (w Warehouse) CreateSupplierHoliday(p model.SupplierHolidayCreatePayload) error { - msg, err := natsio.GetServer().Request(subject.Warehouse.CreateSupplierHoliday, toBytes(p)) - if err != nil { - return err - } - - var r struct { - Error string `json:"error"` - } - - if err = json.Unmarshal(msg.Data, &r); err != nil { - return fmt.Errorf("nats: create_supplier_holiday %v", err) - } - if r.Error != "" { - return errors.New(r.Error) - } - return nil -} - -// UpdateSupplierHoliday ... -func (w Warehouse) UpdateSupplierHoliday(p model.SupplierHolidayUpdatePayload) error { - msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateSupplierHoliday, toBytes(p)) - if err != nil { - return err - } - - var r struct { - Error string `json:"error"` - } - - if err = json.Unmarshal(msg.Data, &r); err != nil { - return fmt.Errorf("nats: create_supplier_holiday %v", err) - } - if r.Error != "" { - return errors.New(r.Error) - } - return nil -} - -// GetSupplierHoliday ... -func (w Warehouse) GetSupplierHoliday(p model.GetSupplierHolidayRequest) (*model.ResponseSupplierHoliday, error) { - msg, err := natsio.GetServer().Request(subject.Warehouse.GetSupplierHoliday, toBytes(p)) - if err != nil { - return nil, err - } - - var r struct { - Data *model.ResponseSupplierHoliday `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 18034af..63b5459 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -52,3 +52,8 @@ type SupplierCountReq struct { IDs []string `json:"ids"` Status string `json:"status"` // active,inactive } + +// CheckTokenSupplierPayload ... +type CheckTokenSupplierPayload struct { + Token string `json:"token"` +} diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 550e870..b6cecb1 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -113,30 +113,3 @@ type WarehouseORUpdateDeliveryStatus struct { OrderID string `json:"orderId"` DeliveryStatus string `json:"deliveryStatus"` } - -// SupplierHolidayCreatePayload ... -type SupplierHolidayCreatePayload struct { - Supplier string `json:"supplier"` - Title string `json:"title"` - From string `json:"from"` - To string `json:"to"` - Warehouses []string `json:"warehouses"` - IsApplyAll bool `json:"isApplyAll"` - Source string `json:"source"` -} - -// SupplierHolidayUpdatePayload ... -type SupplierHolidayUpdatePayload struct { - Supplier string `json:"supplier"` - Title string `json:"title"` - From string `json:"from"` - To string `json:"to"` - Warehouses []string `json:"warehouses"` - IsApplyAll bool `json:"isApplyAll"` - Source string `json:"source"` -} - -// GetSupplierHolidayRequest ... -type GetSupplierHolidayRequest struct { - Conditions interface{} `json:"conditions"` -} diff --git a/model/warehouse_response.go b/model/warehouse_response.go index e5d556b..6359ae3 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -172,20 +172,3 @@ type GetWarehousesResponse struct { Limit int64 `json:"limit"` List []WarehouseInfo `json:"list"` } - -// ResponseWarehouseShort ... -type ResponseWarehouseShort struct { - ID string `json:"_id"` - Name string `json:"name"` -} - -// ResponseSupplierHoliday ... -type ResponseSupplierHoliday struct { - Title string `json:"title"` - From string `json:"from"` - To string `json:"to"` - Status string `json:"status"` - Reason string `json:"reason"` - IsApplyAll bool `json:"isApplyAll"` - Warehouses []ResponseWarehouseShort `json:"warehouses"` -} diff --git a/subject/supplier.go b/subject/supplier.go index edc797f..fe041bf 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -12,10 +12,12 @@ var Supplier = struct { FindAll string FindAllOld string Count string + CheckTokenSupplier string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), FindAllOld: getSupplierValue("find_all_old"), Count: getSupplierValue("count"), + CheckTokenSupplier: getSupplierValue("check_token_supplier"), } diff --git a/subject/warehouse.go b/subject/warehouse.go index 51be4c7..bb184b5 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -26,9 +26,6 @@ var Warehouse = struct { UpdateIsClosedSupplier string GetWarehouses string UpdateORDeliveryStatus string - CreateSupplierHoliday string - UpdateSupplierHoliday string - GetSupplierHoliday string }{ CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), @@ -49,7 +46,4 @@ var Warehouse = struct { UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), GetWarehouses: getWarehouseValue("get_warehouses"), UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"), - CreateSupplierHoliday: getWarehouseValue("create_supplier_holiday"), - UpdateSupplierHoliday: getWarehouseValue("update_supplier_holiday"), - GetSupplierHoliday: getWarehouseValue("get_supplier_holiday"), }