export-data-affiliate-transaction-merge-dev #96
			
				
			
		
		
		
	| 
						 | 
					@ -0,0 +1,41 @@
 | 
				
			||||||
 | 
					package client
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
 | 
						"git.selly.red/Selly-Modules/natsio"
 | 
				
			||||||
 | 
						"git.selly.red/Selly-Modules/natsio/model"
 | 
				
			||||||
 | 
						"git.selly.red/Selly-Modules/natsio/subject"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Segment ...
 | 
				
			||||||
 | 
					type Segment struct{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetSegment ...
 | 
				
			||||||
 | 
					func GetSegment() Segment {
 | 
				
			||||||
 | 
						return Segment{}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetListSegmentInfoByIds ...
 | 
				
			||||||
 | 
					func (s Segment) GetListSegmentInfoByIds(p model.GetListSegmentRequest) (*model.ResponseListSegmentInfo, error) {
 | 
				
			||||||
 | 
						msg, err := natsio.GetServer().Request(subject.Segment.GetListSegmentInfo, toBytes(p))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var r struct {
 | 
				
			||||||
 | 
							Data  *model.ResponseListSegmentInfo `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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -80,6 +80,27 @@ func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.Suppl
 | 
				
			||||||
	return r.Data, nil
 | 
						return r.Data, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s Supplier) FindAllOld(req model.SupplierFindAllReq) (*model.SupplierAll, error) {
 | 
				
			||||||
 | 
						msg, err := natsio.GetServer().Request(subject.Supplier.FindAllOld, toBytes(req))
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var r struct {
 | 
				
			||||||
 | 
							Data  *model.SupplierAll `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) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*model.SupplierAll, error) {
 | 
					func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*model.SupplierAll, error) {
 | 
				
			||||||
	msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID))
 | 
						msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					@ -101,6 +122,27 @@ func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*mod
 | 
				
			||||||
	return r.Data, nil
 | 
						return r.Data, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s Supplier) Count(req model.SupplierCountReq) (*model.SupplierCountRes, error) {
 | 
				
			||||||
 | 
						msg, err := natsio.GetServer().Request(subject.Supplier.Count, toBytes(req))
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var r struct {
 | 
				
			||||||
 | 
							Data  *model.SupplierCountRes `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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// CreateWarehouseIntoServiceSupplier ...
 | 
					// CreateWarehouseIntoServiceSupplier ...
 | 
				
			||||||
func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) error {
 | 
					func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) error {
 | 
				
			||||||
	msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, toBytes(p))
 | 
						msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, toBytes(p))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,6 @@
 | 
				
			||||||
 | 
					package model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetListSegmentRequest ...
 | 
				
			||||||
 | 
					type GetListSegmentRequest struct {
 | 
				
			||||||
 | 
						SegmentIds []string `json:"segmentIds"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					package model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ResponseSegmentInfo ...
 | 
				
			||||||
 | 
					type ResponseSegmentInfo struct {
 | 
				
			||||||
 | 
						ID   string `json:"_id"`
 | 
				
			||||||
 | 
						Name string `json:"name"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ResponseListSegmentInfo ...
 | 
				
			||||||
 | 
					type ResponseListSegmentInfo struct {
 | 
				
			||||||
 | 
						Segments []ResponseSegmentInfo `json:"segments"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -38,3 +38,17 @@ type UpdateSupplierWarehousePayload struct {
 | 
				
			||||||
	DistrictCode int    `json:"districtCode"`
 | 
						DistrictCode int    `json:"districtCode"`
 | 
				
			||||||
	WardCode     int    `json:"wardCode"`
 | 
						WardCode     int    `json:"wardCode"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type SupplierFindAllReq struct {
 | 
				
			||||||
 | 
						Page    int64    `json:"page"`
 | 
				
			||||||
 | 
						Limit   int64    `json:"limit"`
 | 
				
			||||||
 | 
						Segment string   `json:"segment"`
 | 
				
			||||||
 | 
						IDs     []string `json:"ids"`
 | 
				
			||||||
 | 
						Status  string   `json:"status"` // active,inactive
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type SupplierCountReq struct {
 | 
				
			||||||
 | 
						Segment string   `json:"segment"`
 | 
				
			||||||
 | 
						IDs     []string `json:"ids"`
 | 
				
			||||||
 | 
						Status  string   `json:"status"` // active,inactive
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,3 +29,7 @@ type SupplierAll struct {
 | 
				
			||||||
	Suppliers []SupplierBrief `json:"suppliers"`
 | 
						Suppliers []SupplierBrief `json:"suppliers"`
 | 
				
			||||||
	Total     int64           `json:"total"`
 | 
						Total     int64           `json:"total"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type SupplierCountRes struct {
 | 
				
			||||||
 | 
						Total int64 `json:"total"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,6 +13,7 @@ var prefixes = struct {
 | 
				
			||||||
	SupplierRole  string
 | 
						SupplierRole  string
 | 
				
			||||||
	SocialPost    string
 | 
						SocialPost    string
 | 
				
			||||||
	Staff         string
 | 
						Staff         string
 | 
				
			||||||
 | 
						Segment       string
 | 
				
			||||||
	Campaign      string
 | 
						Campaign      string
 | 
				
			||||||
}{
 | 
					}{
 | 
				
			||||||
	Communication: "communication",
 | 
						Communication: "communication",
 | 
				
			||||||
| 
						 | 
					@ -27,5 +28,6 @@ var prefixes = struct {
 | 
				
			||||||
	SupplierRole:  "supplier_role",
 | 
						SupplierRole:  "supplier_role",
 | 
				
			||||||
	SocialPost:    "social_post",
 | 
						SocialPost:    "social_post",
 | 
				
			||||||
	Staff:         "staff",
 | 
						Staff:         "staff",
 | 
				
			||||||
 | 
						Segment:       "segment",
 | 
				
			||||||
	Campaign:      "campaign",
 | 
						Campaign:      "campaign",
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,15 @@
 | 
				
			||||||
 | 
					package subject
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// getSegmentValue ...
 | 
				
			||||||
 | 
					func getSegmentValue(val string) string {
 | 
				
			||||||
 | 
						return fmt.Sprintf("%s.%s", prefixes.Segment, val)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Segment ...
 | 
				
			||||||
 | 
					var Segment = struct {
 | 
				
			||||||
 | 
						GetListSegmentInfo string
 | 
				
			||||||
 | 
					}{
 | 
				
			||||||
 | 
						GetListSegmentInfo: getSegmentValue("get_list_segment_info"),
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -10,8 +10,12 @@ var Supplier = struct {
 | 
				
			||||||
	GetListSupplierInfo             string
 | 
						GetListSupplierInfo             string
 | 
				
			||||||
	GetSupplierContractBySupplierID string
 | 
						GetSupplierContractBySupplierID string
 | 
				
			||||||
	FindAll                         string
 | 
						FindAll                         string
 | 
				
			||||||
 | 
						FindAllOld                      string
 | 
				
			||||||
 | 
						Count                           string
 | 
				
			||||||
}{
 | 
					}{
 | 
				
			||||||
	GetListSupplierInfo:             getSupplierValue("get_list_supplier_info"),
 | 
						GetListSupplierInfo:             getSupplierValue("get_list_supplier_info"),
 | 
				
			||||||
	GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
 | 
						GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
 | 
				
			||||||
	FindAll:                         getSupplierValue("find_all"),
 | 
						FindAll:                         getSupplierValue("find_all"),
 | 
				
			||||||
 | 
						FindAllOld:                      getSupplierValue("find_all_old"),
 | 
				
			||||||
 | 
						Count:                           getSupplierValue("count"),
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue