Merge 4546d0e89b into 738089755a
				
					
				
			This commit is contained in:
		
						commit
						3656bfe772
					
				| 
						 | 
				
			
			@ -0,0 +1,39 @@
 | 
			
		|||
package client
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"errors"
 | 
			
		||||
 | 
			
		||||
	"github.com/Selly-Modules/natsio"
 | 
			
		||||
	"github.com/Selly-Modules/natsio/model"
 | 
			
		||||
	"github.com/Selly-Modules/natsio/subject"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Bank ...
 | 
			
		||||
type Bank struct{}
 | 
			
		||||
 | 
			
		||||
// GetBank ...
 | 
			
		||||
func GetBank() Bank {
 | 
			
		||||
	return Bank{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) {
 | 
			
		||||
	msg, err := natsio.GetServer().Request(subject.Bank.GetBankById, toBytes(bankID))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var r struct {
 | 
			
		||||
		Data  *model.BankBrief `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
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,39 @@
 | 
			
		|||
package client
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"errors"
 | 
			
		||||
 | 
			
		||||
	"github.com/Selly-Modules/natsio"
 | 
			
		||||
	"github.com/Selly-Modules/natsio/model"
 | 
			
		||||
	"github.com/Selly-Modules/natsio/subject"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// BankBranch ...
 | 
			
		||||
type BankBranch struct{}
 | 
			
		||||
 | 
			
		||||
// GetBankBranch ...
 | 
			
		||||
func GetBankBranch() Bank {
 | 
			
		||||
	return Bank{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s Bank) GetBankBranchById(bankBranchID string) (*model.BankBranchBrief, error) {
 | 
			
		||||
	msg, err := natsio.GetServer().Request(subject.Bank.GetBankBranchById, toBytes(bankBranchID))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var r struct {
 | 
			
		||||
		Data  *model.BankBranchBrief `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
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -79,3 +79,39 @@ func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.Suppl
 | 
			
		|||
 | 
			
		||||
	return r.Data, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateWarehouseIntoServiceSupplier ...
 | 
			
		||||
func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) error {
 | 
			
		||||
	msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, toBytes(p))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	var r struct {
 | 
			
		||||
		Error string `json:"error"`
 | 
			
		||||
	}
 | 
			
		||||
	if err = json.Unmarshal(msg.Data, &r); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if r.Error != "" {
 | 
			
		||||
		return errors.New(r.Error)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UpdateWarehouseIntoServiceSupplier ...
 | 
			
		||||
func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWarehousePayload) error {
 | 
			
		||||
	msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateWarehouseIntoServiceSupplier, toBytes(p))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	var r struct {
 | 
			
		||||
		Error string `json:"error"`
 | 
			
		||||
	}
 | 
			
		||||
	if err = json.Unmarshal(msg.Data, &r); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if r.Error != "" {
 | 
			
		||||
		return errors.New(r.Error)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
package model
 | 
			
		||||
 | 
			
		||||
// BankBranchBrief ...
 | 
			
		||||
type BankBranchBrief struct {
 | 
			
		||||
	ID       string `json:"_id"`
 | 
			
		||||
	City     string `json:"city"`
 | 
			
		||||
	BankCode string `json:"bankCode"`
 | 
			
		||||
	Bank     string `json:"bank"`
 | 
			
		||||
	Active   bool   `json:"active"`
 | 
			
		||||
	Name     string `json:"name"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
package model
 | 
			
		||||
 | 
			
		||||
// MultiLang ...
 | 
			
		||||
type MultiLang struct {
 | 
			
		||||
	En string `json:"en"`
 | 
			
		||||
	Vi string `json:"vi"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BankBrief ...
 | 
			
		||||
type BankBrief struct {
 | 
			
		||||
	ID                       string    `json:"_id"`
 | 
			
		||||
	Name                     MultiLang `json:"name"`
 | 
			
		||||
	ShortName                string    `json:"shortName"`
 | 
			
		||||
	Active                   bool      `json:"active"`
 | 
			
		||||
	BenBankName              string    `json:"benBankName"`
 | 
			
		||||
	BankCode                 int       `json:"bankCode"`
 | 
			
		||||
	IsBranchRequired         bool      `json:"isBranchRequired"`
 | 
			
		||||
	SearchString             string    `json:"searchString"`
 | 
			
		||||
	BeneficiaryForVietinbank string    `json:"beneficiaryForVietinbank"`
 | 
			
		||||
	CreatedBy                string    `json:"createdBy,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -22,3 +22,19 @@ type SupplierRequestPayload struct {
 | 
			
		|||
	PIC            string
 | 
			
		||||
	ContractStatus string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type CreateSupplierWarehousePayload struct {
 | 
			
		||||
	Supplier     string `json:"supplier"`
 | 
			
		||||
	Warehouse    string `json:"warehouse"`
 | 
			
		||||
	ProvinceCode int    `json:"provinceCode"`
 | 
			
		||||
	DistrictCode int    `json:"districtCode"`
 | 
			
		||||
	WardCode     int    `json:"wardCode"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type UpdateSupplierWarehousePayload struct {
 | 
			
		||||
	Supplier     string `json:"supplier"`
 | 
			
		||||
	Warehouse    string `json:"warehouse"`
 | 
			
		||||
	ProvinceCode int    `json:"provinceCode"`
 | 
			
		||||
	DistrictCode int    `json:"districtCode"`
 | 
			
		||||
	WardCode     int    `json:"wardCode"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
package subject
 | 
			
		||||
 | 
			
		||||
import "fmt"
 | 
			
		||||
 | 
			
		||||
func getBankValue(val string) string {
 | 
			
		||||
	return fmt.Sprintf("%s.%s", prefixes.Bank, val)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var Bank = struct {
 | 
			
		||||
	GetBankById       string
 | 
			
		||||
	GetBankBranchById string
 | 
			
		||||
}{
 | 
			
		||||
	GetBankById:       getBankValue("get_bank_by_id"),
 | 
			
		||||
	GetBankBranchById: getBankValue("get_bank_branch_by_id"),
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -5,6 +5,7 @@ var prefixes = struct {
 | 
			
		|||
	Order         string
 | 
			
		||||
	Warehouse     string
 | 
			
		||||
	Location      string
 | 
			
		||||
	Bank          string
 | 
			
		||||
	Supplier      string
 | 
			
		||||
}{
 | 
			
		||||
	Communication: "communication",
 | 
			
		||||
| 
						 | 
				
			
			@ -12,4 +13,5 @@ var prefixes = struct {
 | 
			
		|||
	Warehouse:     "warehouse",
 | 
			
		||||
	Location:      "location",
 | 
			
		||||
	Supplier:      "supplier",
 | 
			
		||||
	Bank:          "bank",
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,31 +7,35 @@ func getWarehouseValue(val string) string {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
var Warehouse = struct {
 | 
			
		||||
	CreateOutboundRequest         string
 | 
			
		||||
	UpdateOutboundRequestLogistic string
 | 
			
		||||
	CancelOutboundRequest         string
 | 
			
		||||
	GetConfiguration              string
 | 
			
		||||
	SyncORStatus                  string
 | 
			
		||||
	WebhookTNC                    string
 | 
			
		||||
	WebhookGlobalCare             string
 | 
			
		||||
	FindOne                       string
 | 
			
		||||
	FindByCondition               string
 | 
			
		||||
	Distinct                      string
 | 
			
		||||
	Count                         string
 | 
			
		||||
	AfterUpdateWarehouse          string
 | 
			
		||||
	AfterCreateWarehouse          string
 | 
			
		||||
	CreateOutboundRequest              string
 | 
			
		||||
	UpdateOutboundRequestLogistic      string
 | 
			
		||||
	CancelOutboundRequest              string
 | 
			
		||||
	GetConfiguration                   string
 | 
			
		||||
	SyncORStatus                       string
 | 
			
		||||
	WebhookTNC                         string
 | 
			
		||||
	WebhookGlobalCare                  string
 | 
			
		||||
	FindOne                            string
 | 
			
		||||
	FindByCondition                    string
 | 
			
		||||
	Distinct                           string
 | 
			
		||||
	Count                              string
 | 
			
		||||
	AfterUpdateWarehouse               string
 | 
			
		||||
	AfterCreateWarehouse               string
 | 
			
		||||
	CreateWarehouseIntoServiceSupplier string
 | 
			
		||||
	UpdateWarehouseIntoServiceSupplier string
 | 
			
		||||
}{
 | 
			
		||||
	AfterCreateWarehouse:          getWarehouseValue("after_create_warehouse"),
 | 
			
		||||
	AfterUpdateWarehouse:          getWarehouseValue("after_update_warehouse"),
 | 
			
		||||
	CreateOutboundRequest:         getWarehouseValue("create_outbound_request"),
 | 
			
		||||
	UpdateOutboundRequestLogistic: getWarehouseValue("update_outbound_request_logistic_info"),
 | 
			
		||||
	CancelOutboundRequest:         getWarehouseValue("cancel_outbound_request"),
 | 
			
		||||
	GetConfiguration:              getWarehouseValue("get_configuration"),
 | 
			
		||||
	SyncORStatus:                  getWarehouseValue("sync_or_status"),
 | 
			
		||||
	WebhookTNC:                    getWarehouseValue("webhook_tnc"),
 | 
			
		||||
	WebhookGlobalCare:             getWarehouseValue("webhook_global_care"),
 | 
			
		||||
	FindOne:                       getWarehouseValue("find_one"),
 | 
			
		||||
	FindByCondition:               getWarehouseValue("find_all_by_condition"),
 | 
			
		||||
	Distinct:                      getWarehouseValue("distinct"),
 | 
			
		||||
	Count:                         getWarehouseValue("count"),
 | 
			
		||||
	AfterCreateWarehouse:               getWarehouseValue("after_create_warehouse"),
 | 
			
		||||
	AfterUpdateWarehouse:               getWarehouseValue("after_update_warehouse"),
 | 
			
		||||
	CreateOutboundRequest:              getWarehouseValue("create_outbound_request"),
 | 
			
		||||
	UpdateOutboundRequestLogistic:      getWarehouseValue("update_outbound_request_logistic_info"),
 | 
			
		||||
	CancelOutboundRequest:              getWarehouseValue("cancel_outbound_request"),
 | 
			
		||||
	GetConfiguration:                   getWarehouseValue("get_configuration"),
 | 
			
		||||
	SyncORStatus:                       getWarehouseValue("sync_or_status"),
 | 
			
		||||
	WebhookTNC:                         getWarehouseValue("webhook_tnc"),
 | 
			
		||||
	WebhookGlobalCare:                  getWarehouseValue("webhook_global_care"),
 | 
			
		||||
	FindOne:                            getWarehouseValue("find_one"),
 | 
			
		||||
	FindByCondition:                    getWarehouseValue("find_all_by_condition"),
 | 
			
		||||
	Distinct:                           getWarehouseValue("distinct"),
 | 
			
		||||
	Count:                              getWarehouseValue("count"),
 | 
			
		||||
	CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"),
 | 
			
		||||
	UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"),
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue