Intergrate model for supplier #15
			
				
			
		
		
		
	|  | @ -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 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -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 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -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"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -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"), | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue