- 整理sync.go

This commit is contained in:
gazebo
2019-08-16 14:12:11 +08:00
parent 9a5bde9d09
commit c27d610fbb
4 changed files with 32 additions and 43 deletions

View File

@@ -211,9 +211,32 @@ func RegisterPurchasePlatform(handler IPurchasePlatformHandler) {
if _, ok := PurchasePlatformHandlers[vendorID]; ok {
panic(fmt.Sprintf("purchase vendor:%d, already exists", vendorID))
}
_, isSingleStore := handler.(ISingleStoreHandler)
_, isMultiStore := handler.(IMultipleStoresHandler)
if !isSingleStore && !isMultiStore {
panic(fmt.Sprintf("platform:%d type is wrong!", vendorID))
}
PurchasePlatformHandlers[vendorID] = handler
}
func GetPurchasePlatformFromVendorID(vendorID int) IPurchasePlatformHandler {
return PurchasePlatformHandlers[vendorID]
}
func GetMultiStoreVendorIDs() (vendorIDs []int) {
for k, v := range PurchasePlatformHandlers {
if _, ok := v.(IMultipleStoresHandler); ok {
vendorIDs = append(vendorIDs, k)
}
}
return vendorIDs
}
func GetSingleStoreVendorIDs() (vendorIDs []int) {
for k, v := range PurchasePlatformHandlers {
if _, ok := v.(ISingleStoreHandler); !ok {
vendorIDs = append(vendorIDs, k)
}
}
return vendorIDs
}