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{}
}
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 != "" {

View File

@ -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
}

View File

@ -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"`
}

View File

@ -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"),
}