count supplier

This commit is contained in:
Sinh 2022-11-23 10:08:52 +07:00
parent d45da3e74c
commit 8248069bb8
4 changed files with 32 additions and 0 deletions

View File

@ -122,6 +122,27 @@ func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*mod
return r.Data, nil 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 ... // CreateWarehouseIntoServiceSupplier ...
func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) error { func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) error {
msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, toBytes(p)) msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, toBytes(p))

View File

@ -45,3 +45,8 @@ type SupplierFindAllReq struct {
Segment string `json:"segment"` Segment string `json:"segment"`
IDs []string `json:"ids"` IDs []string `json:"ids"`
} }
type SupplierCountReq struct {
Segment string `json:"segment"`
IDs []string `json:"ids"`
}

View File

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

View File

@ -11,9 +11,11 @@ var Supplier = struct {
GetSupplierContractBySupplierID string GetSupplierContractBySupplierID string
FindAll string FindAll string
FindAllOld string FindAllOld string
Count string
}{ }{
GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetListSupplierInfo: getSupplierValue("get_list_supplier_info"),
GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
FindAll: getSupplierValue("find_all"), FindAll: getSupplierValue("find_all"),
FindAllOld: getSupplierValue("find_all_old"), FindAllOld: getSupplierValue("find_all_old"),
Count: getSupplierValue("count"),
} }