count supplier
This commit is contained in:
parent
d45da3e74c
commit
8248069bb8
|
@ -122,6 +122,27 @@ func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*mod
|
|||
return r.Data, nil
|
||||
}
|
||||
|
||||
func (s Supplier) Count(req model.SupplierCountReq) (*model.SupplierCountRes, error) {
|
||||
msg, err := natsio.GetServer().Request(subject.Supplier.Count, toBytes(req))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var r struct {
|
||||
Data *model.SupplierCountRes `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))
|
||||
|
|
|
@ -45,3 +45,8 @@ type SupplierFindAllReq struct {
|
|||
Segment string `json:"segment"`
|
||||
IDs []string `json:"ids"`
|
||||
}
|
||||
|
||||
type SupplierCountReq struct {
|
||||
Segment string `json:"segment"`
|
||||
IDs []string `json:"ids"`
|
||||
}
|
||||
|
|
|
@ -29,3 +29,7 @@ type SupplierAll struct {
|
|||
Suppliers []SupplierBrief `json:"suppliers"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
type SupplierCountRes struct {
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
|
|
@ -11,9 +11,11 @@ var Supplier = struct {
|
|||
GetSupplierContractBySupplierID string
|
||||
FindAll string
|
||||
FindAllOld string
|
||||
Count 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"),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue