소스 검색

update 新增对货币类型的校验

Alvin 8 달 전
부모
커밋
94ed3cacab
2개의 변경된 파일25개의 추가작업 그리고 8개의 파일을 삭제
  1. 0 8
      game/game_cluster/internal/constant/constant.go
  2. 25 0
      game/game_cluster/internal/constant/currency.go

+ 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
+}