This commit is contained in:
蒋海成 2025-02-26 15:11:28 +08:00
commit 6bf02405c6
6 changed files with 99 additions and 100 deletions

View File

@ -20,6 +20,7 @@ package main
import (
"fmt"
"fonchain-fiee/cmd/config"
"fonchain-fiee/pkg/cache"
"fonchain-fiee/pkg/router"
)
@ -44,14 +45,14 @@ func bootstrap() (err error) {
fmt.Println(config.AppConfig)
////redis
//redisConfig := cache.RedisConfig{
// RedisDB: configEnv.Redis.RedisDB,
// RedisAddr: configEnv.Redis.RedisAddr,
// RedisPw: configEnv.Redis.RedisPW,
// RedisDbName: configEnv.Redis.RedisDBNAme,
//}
//
//cache.LoadRedis(redisConfig)
redisConfig := cache.RedisConfig{
RedisDB: configEnv.Redis.RedisDB,
RedisAddr: configEnv.Redis.RedisAddr,
RedisPw: configEnv.Redis.RedisPW,
RedisDbName: configEnv.Redis.RedisDBNAme,
}
cache.LoadRedis(redisConfig)
//
//gpt.InitSet(configEnv.Ai.Host, configEnv.Ai.TelNum, configEnv.Ai.Password)
return nil

View File

@ -21,10 +21,11 @@ BucketName = "fontree-test"
BaseDir = "fonchain-main"
CdnHost = "https://cdn-test.szjixun.cn"
[redis]
RedisDB = "1"
RedisDB = "2"
RedisAddr = "127.0.0.1:6379"
RedisPW = ""
RedisDBNAme = "1"
RedisDBNAme = "2"
[ai]
Host = "https://erpapi.fontree.cn"

View File

@ -22,10 +22,10 @@ BaseDir = "fiee"
CdnHost = "https://cdn-test.szjixun.cn"
[redis]
RedisDB = "1"
RedisDB = "2"
RedisAddr = "172.16.100.114:6379"
RedisPW = "kP6tW4tS3qB2dW4aE6uI5cX2"
RedisDBNAme = "1"
RedisDBNAme = "2"
[ai]
Host = "https://erpapi.fontree.cn"

View File

@ -14,10 +14,10 @@ BosBaseDir = "fonchain-main"
BosHttp = "https://"
[redis]
RedisDB = "1"
RedisDB = "2"
RedisAddr = "svc-fontree-redis-service:6379"
RedisPW = "fonchain_opv:kP6tW4tS3qB2dW4aE6uI5cX2"
RedisDBNAme = "1"
RedisDBNAme = "2"
[ai]
Host = "https://erpapi.fontree.cn"

View File

@ -9,53 +9,53 @@ const (
)
var EnMessages = map[string]string{
"获取套餐列表失败": "Failed to get bundle list",
"创建套餐信息失败": "Failed to create bundle information",
"创建套餐信息成功": "Successfully created bundle information",
"更新套餐信息失败": "Failed to update bundle information",
"更新套餐信息成功": "Successfully updated bundle information",
"删除套餐信息失败": "Failed to delete bundle information",
"删除套餐信息成功": "Successfully deleted bundle information",
"获取套餐信息失败": "Failed to get bundle information",
"创建订单信息失败": "Failed to create order information",
"创建订单信息成功": "Successfully created order information",
"更新订单信息失败": "Failed to update order information",
"更新订单信息成功": "Successfully updated order information",
"获取订单信息失败": "Failed to get order information",
"获取订单列表失败": "Failed to get order list",
"缺少套餐UUID": "Missing bundle UUID",
"缺少客户签名信息": "Missing customer signature",
"插入签名失败": "Failed to insert signature",
"缺少订单号": "Missing order number",
"缺少订单信息": "Missing order information",
"获取套餐列表失败": "Failed to get bundle list",
"创建套餐信息失败": "Failed to create bundle information",
"创建套餐信息成功": "Successfully created bundle information",
"更新套餐信息失败": "Failed to update bundle information",
"更新套餐信息成功": "Successfully updated bundle information",
"删除套餐信息失败": "Failed to delete bundle information",
"删除套餐信息成功": "Successfully deleted bundle information",
"获取套餐信息失败": "Failed to get bundle information",
"创建订单信息失败": "Failed to create order information",
"创建订单信息成功": "Successfully created order information",
"更新订单信息失败": "Failed to update order information",
"更新订单信息成功": "Successfully updated order information",
"获取订单信息失败": "Failed to get order information",
"获取订单列表失败": "Failed to get order list",
"缺少套餐UUID": "Missing bundle UUID",
"缺少客户签名信息": "Missing customer signature",
"插入签名失败": "Failed to insert signature",
"缺少订单号": "Missing order number",
"缺少订单信息": "Missing order information",
"非当前用户订单信息不可操作": "Cannot operate on order information of other users",
"订单已支付": "Order has been paid",
"订单已支付": "Order has been paid",
"您已购买过套餐,无法再次购买": "You have already purchased this bundle and cannot purchase again",
"查询支付信息失败": "Failed to query payment information",
"下载文件失败": "Failed to download file",
"上传文件失败": "Failed to upload file",
"时间格式错误": "Invalid time format",
"查询支付信息失败": "Failed to query payment information",
"下载文件失败": "Failed to download file",
"上传文件失败": "Failed to upload file",
"时间格式错误": "Invalid time format",
"账号或密码错误": "The account or password is incorrect",
"账号或验证码错误": "The account or verification code is incorrect",
"账号已存在": "Account already exists",
"没有找到数据": "No data found",
"已经发送过,验证码尚可用": "It was sent. The verification code is still working",
"系统提示:已经发送过,验证码尚可用": "System message: Already sent, verification code is still available",
"账号或密码错误": "The account or password is incorrect",
"账号或验证码错误": "The account or verification code is incorrect",
"账号已存在": "Account already exists",
"没有找到数据": "No data found",
"已经发送过,验证码尚可用": "It was sent. The verification code is still working",
"系统提示:已经发送过,验证码尚可用": "System message: Already sent, verification code is still available",
"您的手机号当天发送次数过多,请联系管理员通过密码登录": "Your mobile phone number is sent too many times that day, please contact the administrator to log in through the password",
"您的手机号验证码错误,请确认之后注册": "Your phone number verification code is incorrect, please confirm and register",
"手机号不合法": "The phone number is illegal",
"手机号未更改": "The phone number has not been changed",
"新手机号过期": "New phone number expired",
"验证码错误": "Verification code error",
"验证码未发送": "The verification code was not sent",
"账号不存在": "Account does not exist",
"已实名": "In real name",
"实名审核中,请勿重复提交": "During real-name audit, please do not submit repeatedly",
"用户状态异常,无法进行审核": "The user is abnormal and cannot be audited. Procedure",
"验证码已失效": "The verification code is invalid",
"服务器错误": "Server error",
"验证失败,请控制拼图对齐缺口": "Verification failed, please control puzzle alignment gap",
"您的手机号验证码错误,请确认之后注册": "Your phone number verification code is incorrect, please confirm and register",
"手机号不合法": "The phone number is illegal",
"手机号未更改": "The phone number has not been changed",
"新手机号过期": "New phone number expired",
"验证码错误": "Verification code error",
"验证码未发送": "The verification code was not sent",
"账号不存在": "Account does not exist",
"已实名": "In real name",
"实名审核中,请勿重复提交": "During real-name audit, please do not submit repeatedly",
"用户状态异常,无法进行审核": "The user is abnormal and cannot be audited. Procedure",
"验证码已失效": "The verification code is invalid",
"服务器错误": "Server error",
"验证失败,请控制拼图对齐缺口": "Verification failed, please control puzzle alignment gap",
}
var DeDEMessages = map[string]string{

View File

@ -2,18 +2,14 @@ package account
import (
"context"
"errors"
"fmt"
"fonchain-fiee/api/account"
"fonchain-fiee/pkg/cache"
"fonchain-fiee/pkg/e"
"fonchain-fiee/pkg/model/login"
"fonchain-fiee/pkg/model/union"
"fonchain-fiee/pkg/service"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/go-redis/redis"
"time"
)
func UserApproval(c *gin.Context) {
@ -74,45 +70,46 @@ func SendMsg(c *gin.Context) {
if req.Zone != e.ZoneCn && req.Zone != "" {
// ============================== redis检查ip开始
ip := c.ClientIP()
daykey := "day_sms_limit:" + ip
minutekey := "minute_sms_limit:" + ip
duration := time.Second
isBlacklisted, blackErr := cache.RedisClient.SIsMember("nation_sms_blacklist", ip).Result()
if blackErr != nil {
service.Error(c, errors.New("Redis error"))
return
}
if isBlacklisted {
fmt.Println("当前ip手机号在黑名单中", ip, ";手机号:", req.TelNum, ";domain", req.Domain)
service.Success(c, "succes!")
return
}
// 一分钟5次一天30次
if dayCount, redisErr := cache.RedisClient.Get(daykey).Int(); redisErr == redis.Nil {
cache.RedisClient.Set(daykey, 1, 24*time.Hour)
} else if redisErr != nil {
service.Error(c, errors.New("Redis error"))
return
} else if dayCount >= 30 {
cache.RedisClient.SAdd("nation_sms_blacklist", ip)
cache.RedisClient.Expire("nation_sms_blacklist", 24*time.Hour) // 黑名单记录有效期为24小时
fmt.Println("当前ip手机号在黑名单中", ip, ";手机号:", req.TelNum, ";domain", req.Domain)
service.Success(c, "succes!")
return
}
if minuteCount, redisErr := cache.RedisClient.Get(minutekey).Int(); redisErr == redis.Nil {
cache.RedisClient.Set(minutekey, 1, duration)
} else if redisErr != nil {
service.Error(c, errors.New("Redis error"))
return
} else if minuteCount >= 5 {
fmt.Println("当前ip触发每分钟5次限制", ip, ";手机号:", req.TelNum, ";domain", req.Domain)
service.Success(c, "succes!")
return
}
cache.RedisClient.Incr(daykey)
cache.RedisClient.Incr(minutekey)
fmt.Println("当前ip", ip, ";手机号:", req.TelNum, ";domain", req.Domain)
//daykey := "day_sms_limit:" + ip
//minutekey := "minute_sms_limit:" + ip
//duration := time.Second
//isBlacklisted, blackErr := cache.RedisClient.SIsMember("nation_sms_blacklist", ip).Result()
//if blackErr != nil {
// service.Error(c, errors.New("Redis error"))
// return
//}
//if isBlacklisted {
// fmt.Println("当前ip手机号在黑名单中", ip, ";手机号:", req.TelNum, ";domain", req.Domain)
// service.Success(c, "succes!")
// return
//}
//
//// 一分钟5次一天30次
//if dayCount, redisErr := cache.RedisClient.Get(daykey).Int(); redisErr == redis.Nil {
// cache.RedisClient.Set(daykey, 1, 24*time.Hour)
//} else if redisErr != nil {
// service.Error(c, errors.New("Redis error"))
// return
//} else if dayCount >= 30 {
// cache.RedisClient.SAdd("nation_sms_blacklist", ip)
// cache.RedisClient.Expire("nation_sms_blacklist", 24*time.Hour) // 黑名单记录有效期为24小时
// fmt.Println("当前ip手机号在黑名单中", ip, ";手机号:", req.TelNum, ";domain", req.Domain)
// service.Success(c, "succes!")
// return
//}
//if minuteCount, redisErr := cache.RedisClient.Get(minutekey).Int(); redisErr == redis.Nil {
// cache.RedisClient.Set(minutekey, 1, duration)
//} else if redisErr != nil {
// service.Error(c, errors.New("Redis error"))
// return
//} else if minuteCount >= 5 {
// fmt.Println("当前ip触发每分钟5次限制", ip, ";手机号:", req.TelNum, ";domain", req.Domain)
// service.Success(c, "succes!")
// return
//}
//cache.RedisClient.Incr(daykey)
//cache.RedisClient.Incr(minutekey)
// ============================== redis检查ip结束
tempReq := &account.SendNationMsgRequest{