判断兑换码名称长度,改为按字符长度计算

This commit is contained in:
Raymond
2025-07-25 22:40:12 +08:00
parent 4d0037a40c
commit df647e7b42

View File

@@ -6,6 +6,7 @@ import (
"one-api/common"
"one-api/model"
"strconv"
"unicode/utf8"
"github.com/gin-gonic/gin"
)
@@ -63,7 +64,7 @@ func AddRedemption(c *gin.Context) {
common.ApiError(c, err)
return
}
if len(redemption.Name) == 0 || len(redemption.Name) > 20 {
if utf8.RuneCountInString(redemption.Name) == 0 || utf8.RuneCountInString(redemption.Name) > 20 {
c.JSON(http.StatusOK, gin.H{
"success": false,
"message": "兑换码名称长度必须在1-20之间",