get list warehouse freeship

This commit is contained in:
QuanTT0110 2022-10-17 15:09:50 +07:00
parent d71d7f0eb4
commit b7d963cc90
3 changed files with 29 additions and 0 deletions

View File

@ -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
}

View File

@ -29,3 +29,7 @@ type SupplierAll struct {
Suppliers []SupplierBrief `json:"suppliers"`
Total int64 `json:"total"`
}
type ResponseListWarehouseIDByBusinessType struct {
Warehouses []string `json:"warehouses"`
}

View File

@ -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"),
}