Merge branch 'supplier-setup-product' into develop

This commit is contained in:
Sinh 2022-12-26 15:13:38 +07:00
commit dcf44fa87b
7 changed files with 86 additions and 6 deletions

35
client/product.go Normal file
View File

@ -0,0 +1,35 @@
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"
)
// Product ...
type Product struct{}
// GetProduct ...
func GetProduct() Product {
return Product{}
}
func (c Product) ApplyRequest(p model.ProductApplyRequestPayload) error {
msg, err := natsio.GetServer().Request(subject.Product.ApplyRequest, 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
}

5
model/product_request.go Normal file
View File

@ -0,0 +1,5 @@
package model
type ProductApplyRequestPayload struct {
RequestID string `json:"requestId"`
}

8
model/queue_request.go Normal file
View File

@ -0,0 +1,8 @@
package model
type QueueScheduleTaskRequest struct {
ID string `json:"id"`
NatsSubject string `json:"natsSubject"`
Data string `json:"data"`
StartAt int64 `json:"startAt"` // unix
}

View File

@ -97,10 +97,11 @@ type SupplierIsClosed struct {
// GetWarehousesRequest ... // GetWarehousesRequest ...
type GetWarehousesRequest struct { type GetWarehousesRequest struct {
Keyword string `json:"keyword"` Keyword string `json:"keyword"`
Status string `json:"status"` Status string `json:"status"`
Supplier string `json:"supplier"` Supplier string `json:"supplier"`
BusinessType string `json:"businessType"` BusinessType string `json:"businessType"`
IDs []string `json:"ids"`
Page int64 `json:"page"` Page int64 `json:"page"`
Limit int64 `json:"limit"` Limit int64 `json:"limit"`

View File

@ -20,7 +20,9 @@ var prefixes = struct {
SupplierUser string SupplierUser string
SupplierRole string SupplierRole string
Campaign string Campaign string
Affiliate string Affiliate string
Product string
Queue string
}{ }{
Communication: "communication", Communication: "communication",
Order: "order", Order: "order",
@ -41,5 +43,7 @@ var prefixes = struct {
Staff: "staff", Staff: "staff",
Segment: "segment", Segment: "segment",
Campaign: "campaign", Campaign: "campaign",
Affiliate: "affiliate", Affiliate: "affiliate",
Product: "product",
Queue: "queue",
} }

14
subject/product.go Normal file
View File

@ -0,0 +1,14 @@
package subject
import "fmt"
// getSegmentValue ...
func getProductValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Product, val)
}
var Product = struct {
ApplyRequest string
}{
ApplyRequest: getProductValue("apply_request"),
}

13
subject/queue.go Normal file
View File

@ -0,0 +1,13 @@
package subject
import "fmt"
func getQueueValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Queue, val)
}
var Queue = struct {
ScheduleTask string
}{
ScheduleTask: getQueueValue("schedule_task"),
}