Pārlūkot izejas kodu

update 新增对货币类型的校验

Alvin 8 mēneši atpakaļ
vecāks
revīzija
94ed3cacab

+ 0 - 8
game/game_cluster/internal/constant/constant.go

@@ -58,11 +58,3 @@ const (
 	IncreaseOp OperationTypeStr = "increase"
 	DecreaseOp OperationTypeStr = "decrease"
 )
-
-type CurrencyTypeStr string
-
-const (
-	PointsCurrency CurrencyTypeStr = "POINTS" // 积分
-	TonCurrency    CurrencyTypeStr = "TON"
-	UsdtCurrency   CurrencyTypeStr = "USDT"
-)

+ 25 - 0
game/game_cluster/internal/constant/currency.go

@@ -0,0 +1,25 @@
+package constant
+
+type CurrencyTypeStr string
+
+const (
+	PointsCurrency CurrencyTypeStr = "POINTS" // 积分
+	TonCurrency    CurrencyTypeStr = "TON"
+	UsdtCurrency   CurrencyTypeStr = "USDT"
+)
+
+var (
+	currencyMap map[string]CurrencyTypeStr
+)
+
+func init() {
+	currencyMap = make(map[string]CurrencyTypeStr, 8)
+	currencyMap["POINTS"] = PointsCurrency
+	currencyMap["TON"] = TonCurrency
+	currencyMap["USDT"] = UsdtCurrency
+}
+
+func CurrencyValid(currency string) bool {
+	_, exist := currencyMap[currency]
+	return exist
+}