Intergrate model for supplier #15

Merged
nguyenphamquangtue merged 5 commits from intergrateModelForSupplier into develop 2022-08-31 07:48:24 +00:00
4 changed files with 47 additions and 0 deletions

View File

@ -58,3 +58,24 @@ func (s Supplier) GetSupplierContractBySupplierID(p model.GetSupplierContractReq
return r.Data, nil return r.Data, nil
} }
func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.SupplierAll, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID))
if err != nil {
return nil, err
}
var r struct {
Data *model.SupplierAll `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

@ -12,3 +12,13 @@ type GetSupplierRequest struct {
type GetSupplierContractRequest struct { type GetSupplierContractRequest struct {
SupplierID primitive.ObjectID `json:"supplierID"` SupplierID primitive.ObjectID `json:"supplierID"`
} }
// SupplierRequestPayload ...
type SupplierRequestPayload struct {
Limit int
Page int
Keyword string
Status string
PIC string
ContractStatus string
}

View File

@ -13,3 +13,17 @@ type ResponseSupplierContract struct {
Name string `json:"name"` Name string `json:"name"`
Status string `json:"status"` Status string `json:"status"`
} }
// 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"`
}

View File

@ -9,7 +9,9 @@ func getSupplierValue(val string) string {
var Supplier = struct { var Supplier = struct {
GetListSupplierInfo string GetListSupplierInfo string
GetSupplierContractBySupplierID string GetSupplierContractBySupplierID string
FindAll 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"),
} }