- up
This commit is contained in:
52
business/partner/partner_printer.go
Normal file
52
business/partner/partner_printer.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package partner
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
type BindPrinterResult struct {
|
||||
PrinterSN string
|
||||
PrinterKey string
|
||||
PrinterKey2 string
|
||||
ExpiresIn int64 `json:"expires_in"`
|
||||
}
|
||||
|
||||
type IPrinterHandler interface {
|
||||
GetVendorID() int
|
||||
PrintMsg(ctx *jxcontext.Context, id1, id2, msgTitle, msgContent string) (printerStatus *PrinterStatus, err error)
|
||||
GetPrinterStatus(ctx *jxcontext.Context, id1, id2 string) (printerStatus *PrinterStatus, err error)
|
||||
|
||||
RegisterPrinter(ctx *jxcontext.Context, id1, id2, printerName string) (newID1, newID2 string, err error)
|
||||
UnregisterPrinter(ctx *jxcontext.Context, id1, id2 string) (err error)
|
||||
|
||||
BindPrinter(ctx *jxcontext.Context, mapData map[string]interface{}) (bindResult *BindPrinterResult, err error)
|
||||
RebindPrinter(ctx *jxcontext.Context, lastBindResult *BindPrinterResult) (bindResult *BindPrinterResult, err error)
|
||||
|
||||
PrintOrder(ctx *jxcontext.Context, store *model.Store, order *model.GoodsOrder) (printerStatus *PrinterStatus, err error)
|
||||
}
|
||||
|
||||
var (
|
||||
PrinterPlatformHandlers map[int]IPrinterHandler
|
||||
)
|
||||
|
||||
func init() {
|
||||
PrinterPlatformHandlers = make(map[int]IPrinterHandler)
|
||||
}
|
||||
|
||||
func RegisterPrinterPlatform(handler IPrinterHandler) {
|
||||
vendorID := handler.GetVendorID()
|
||||
if !(model.IsPrinterVendorExist(vendorID)) {
|
||||
panic(fmt.Sprintf("printer vendor:%d is illegal", vendorID))
|
||||
}
|
||||
if _, ok := PrinterPlatformHandlers[vendorID]; ok {
|
||||
panic(fmt.Sprintf("printer vendor:%d, already exists", vendorID))
|
||||
}
|
||||
PrinterPlatformHandlers[vendorID] = handler
|
||||
}
|
||||
|
||||
func GetPrinterPlatformFromVendorID(vendorID int) IPrinterHandler {
|
||||
return PrinterPlatformHandlers[vendorID]
|
||||
}
|
||||
Reference in New Issue
Block a user