build nats supplier
This commit is contained in:
		
							parent
							
								
									df340fefda
								
							
						
					
					
						commit
						30b0238c0f
					
				| 
						 | 
					@ -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 != "" {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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"),
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue