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