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 25 additions and 16 deletions
Showing only changes of commit 30b0238c0f - Show all commits

View File

@ -17,18 +17,18 @@ func GetSupplier() Supplier {
return Supplier{} return Supplier{}
} }
func (s Supplier) GetSupplierInfo(supplierID model.GetSupplierRequest) (*model.ResponseSupplierInfo, error) { func (s Supplier) FindAll(supplierID model.GetSupplierRequest) (*model.SupplierAll, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.GetSupplierInfo, toBytes(supplierID)) msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID))
if err != nil { if err != nil {
return nil, err return nil, err
} }
var r struct { var r struct {
Data *model.ResponseSupplierInfo `json:"data"` Data *model.SupplierAll `json:"data"`
Error string `json:"error"` 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 return nil, err
} }
if r.Error != "" { if r.Error != "" {

View File

@ -1,10 +1,11 @@
package model package model
import (
"go.mongodb.org/mongo-driver/bson/primitive"
)
// GetSupplierRequest ... // GetSupplierRequest ...
type GetSupplierRequest struct { type GetSupplierRequest struct {
ID primitive.ObjectID `json:"_id"` Limit int
Page int
Keyword string
Status string
PIC string
ContractStatus string
} }

View File

@ -1,7 +1,15 @@
package model package model
// ResponseSupplierInfo ... // SupplierBrief ...
type ResponseSupplierInfo struct { type SupplierBrief struct {
ID string `json:"id"` ID string `json:"_id"`
Name string `json:"name"` 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

@ -7,7 +7,7 @@ func getSupplierValue(val string) string {
} }
var Supplier = struct { var Supplier = struct {
GetSupplierInfo string FindAll string
}{ }{
GetSupplierInfo: getSupplierValue("get_supplier_info"), FindAll: getSupplierValue("find_all"),
} }