Pārlūkot izejas kodu

signIn 进行限频

master
DengBiao pirms 1 gada
vecāks
revīzija
75814ae11f
2 mainītis faili ar 9 papildinājumiem un 2 dzēšanām
  1. +1
    -1
      config/config.go
  2. +8
    -1
      internal/logic/domain/device/device_service.go

+ 1
- 1
config/config.go Parādīt failu

@@ -21,7 +21,7 @@ const (

var (
NameSpace string = "gim"
MySQL string = "root:Fnuo123com@@tcp(119.23.182.117:3306)/gim?charset=utf8&parseTime=true"
MySQL string = "root:Fnuo123com@@tcp(119.23.182.117:3306)/gim?charset=utf8&parseTime=true&loc=Local"
RedisIP string = "120.24.28.6:32572"
RedisPassword string = ""



+ 8
- 1
internal/logic/domain/device/device_service.go Parādīt failu

@@ -41,9 +41,16 @@ func (*deviceService) SignIn(ctx context.Context, userId, deviceId int64, token
masterId, _ := grpclib.GetCtxMasterId(ctx)
cacheKey := fmt.Sprintf(SignInKey, masterId, utils.Int64ToStr(userId))
if db.RedisUtil.Exists(cacheKey) {
utils.FilePutContents("sign_in", utils.SerializeStr(map[string]interface{}{
"user_id": userId,
"device_id": deviceId,
"token": token,
"conn_addr": connAddr,
"client_addr": clientAddr,
}))
return errors.New("限频!!!")
} else {
err := db.RedisUtil.Set(SignInKey, "already", SignInExpire)
err := db.RedisUtil.Set(cacheKey, "already", SignInExpire)
if err != nil {
return gerrors.WrapError(err)
}


Notiek ielāde…
Atcelt
Saglabāt