diff --git a/client/supplier.go b/client/supplier.go index 01da757..4e4d938 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -17,18 +17,18 @@ func GetSupplier() Supplier { return Supplier{} } -func (s Supplier) GetSupplierInfo(supplierID model.GetSupplierRequest) (*model.ResponseSupplierInfo, error) { - msg, err := natsio.GetServer().Request(subject.Supplier.GetSupplierInfo, toBytes(supplierID)) +func (s Supplier) FindAll(supplierID model.GetSupplierRequest) (*model.SupplierAll, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID)) if err != nil { return nil, err } var r struct { - Data *model.ResponseSupplierInfo `json:"data"` - Error string `json:"error"` + Data *model.SupplierAll `json:"data"` + Error string `json:"error"` } - if err := json.Unmarshal(msg.Data, &r); err != nil { + if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err } if r.Error != "" { diff --git a/model/supplier_request.go b/model/supplier_request.go index 2fede05..52806ba 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -1,10 +1,11 @@ package model -import ( - "go.mongodb.org/mongo-driver/bson/primitive" -) - // GetSupplierRequest ... type GetSupplierRequest struct { - ID primitive.ObjectID `json:"_id"` + 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 de2f579..23c0f1b 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -1,7 +1,15 @@ package model -// ResponseSupplierInfo ... -type ResponseSupplierInfo struct { - ID string `json:"id"` - Name string `json:"name"` +// 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/subject/supplier.go b/subject/supplier.go index 4b4cf52..557fc77 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -7,7 +7,7 @@ func getSupplierValue(val string) string { } var Supplier = struct { - GetSupplierInfo string + FindAll string }{ - GetSupplierInfo: getSupplierValue("get_supplier_info"), + FindAll: getSupplierValue("find_all"), }