setup-holiday-supplier-tool #123
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -38,6 +38,28 @@ func (s Supplier) GetListSupplierInfo(p model.GetSupplierRequest) ([]*model.Resp
 | 
			
		|||
	return r.Data, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetDetailSupplierInfo ...
 | 
			
		||||
func (s Supplier) GetDetailSupplierInfo(p model.GetDetailSupplierRequest) (*model.ResponseSupplierInfo, error) {
 | 
			
		||||
	msg, err := natsio.GetServer().Request(subject.Supplier.GetDetailSupplierInfo, toBytes(p))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var r struct {
 | 
			
		||||
		Data  *model.ResponseSupplierInfo `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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s Supplier) GetSupplierContractBySupplierID(p model.GetSupplierContractRequest) (*model.ResponseSupplierContract, error) {
 | 
			
		||||
	msg, err := natsio.GetServer().Request(subject.Supplier.GetSupplierContractBySupplierID, toBytes(p))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -138,3 +138,23 @@ func (s SupplierUser) ResetPassword(p model.ResetPasswordRequest) (*model.ResetP
 | 
			
		|||
 | 
			
		||||
	return r.Data, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckTokenSupplierUser ...
 | 
			
		||||
func (s SupplierUser) CheckTokenSupplierUser(p model.CheckTokenSupplierUserPayload) (*model.ResponseCheckTokenSupplierUser, error) {
 | 
			
		||||
	msg, err := natsio.GetServer().Request(subject.SupplierUser.CheckTokenSupplierUser, toBytes(p))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var r struct {
 | 
			
		||||
		Error string                                `json:"error"`
 | 
			
		||||
		Data  *model.ResponseCheckTokenSupplierUser `json:"data"`
 | 
			
		||||
	}
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,6 +9,11 @@ type GetSupplierRequest struct {
 | 
			
		|||
	ListID []primitive.ObjectID `json:"listID"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetDetailSupplierRequest ...
 | 
			
		||||
type GetDetailSupplierRequest struct {
 | 
			
		||||
	Supplier string `json:"supplier"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetSupplierContractRequest struct {
 | 
			
		||||
	SupplierID primitive.ObjectID `json:"supplierID"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,3 +49,9 @@ type ResetPasswordRequest struct {
 | 
			
		|||
	ID       string `json:"_id"`
 | 
			
		||||
	Password string `json:"password"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckTokenSupplierUserPayload ...
 | 
			
		||||
type CheckTokenSupplierUserPayload struct {
 | 
			
		||||
	Token       string   `json:"token"`
 | 
			
		||||
	Permissions []string `json:"permissions"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,3 +11,16 @@ type CreateStaffResponse struct {
 | 
			
		|||
type ResetPasswordResponse struct {
 | 
			
		||||
	Password string `json:"password"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ResponseCheckTokenSupplierUser ...
 | 
			
		||||
type ResponseCheckTokenSupplierUser struct {
 | 
			
		||||
	IsValid bool                     `json:"isValid"`
 | 
			
		||||
	Reason  string                   `json:"reason"`
 | 
			
		||||
	User    ResponseSupplierUserInfo `json:"supplier"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ResponseSupplierUserInfo struct {
 | 
			
		||||
	ID         string `json:"_id"`
 | 
			
		||||
	Name       string `json:"name"`
 | 
			
		||||
	SupplierID string `json:"supplierId"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,12 +8,14 @@ func getSupplierValue(val string) string {
 | 
			
		|||
 | 
			
		||||
var Supplier = struct {
 | 
			
		||||
	GetListSupplierInfo             string
 | 
			
		||||
	GetDetailSupplierInfo           string
 | 
			
		||||
	GetSupplierContractBySupplierID string
 | 
			
		||||
	FindAll                         string
 | 
			
		||||
	FindAllOld                      string
 | 
			
		||||
	Count                           string
 | 
			
		||||
}{
 | 
			
		||||
	GetListSupplierInfo:             getSupplierValue("get_list_supplier_info"),
 | 
			
		||||
	GetDetailSupplierInfo:           getSupplierValue("get_detail_supplier_info"),
 | 
			
		||||
	GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
 | 
			
		||||
	FindAll:                         getSupplierValue("find_all"),
 | 
			
		||||
	FindAllOld:                      getSupplierValue("find_all_old"),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,6 +14,7 @@ var SupplierUser = struct {
 | 
			
		|||
	UpdateStaff            string
 | 
			
		||||
	UpdateStatus           string
 | 
			
		||||
	ResetPassword          string
 | 
			
		||||
	CheckTokenSupplierUser string
 | 
			
		||||
}{
 | 
			
		||||
	// Users
 | 
			
		||||
	CreateOwner:            getSupplierUserValue("create_owner"),
 | 
			
		||||
| 
						 | 
				
			
			@ -22,4 +23,5 @@ var SupplierUser = struct {
 | 
			
		|||
	UpdateStaff:            getSupplierUserValue("update_staff"),
 | 
			
		||||
	UpdateStatus:           getSupplierUserValue("update_status"),
 | 
			
		||||
	ResetPassword:          getSupplierUserValue("reset_password"),
 | 
			
		||||
	CheckTokenSupplierUser: getSupplierUserValue("check_token_supplier_user"),
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue