Compare commits

...

5 Commits

Author SHA1 Message Date
Tue d29ad11fa5 build nats supplier 2022-08-31 14:41:06 +07:00
Tue ed48d80665 build nats supplier 2022-08-31 14:37:56 +07:00
Tue c491945395 build nats supplier 2022-08-31 14:36:04 +07:00
Tue 8c5e7e4798 build nats supplier 2022-08-31 14:29:11 +07:00
Tue 30b0238c0f build nats supplier 2022-08-31 14:18:04 +07: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"),
} }