作者 yangfu

增加 uuid查重 防止接口重新访问

... ... @@ -138,14 +138,14 @@ func FilterComm(ctx *context.Context) {
//if !CheckSign(ctx) {
// return
//}
//3.查重uuid
if !CheckUuid(ctx) {
return
}
//2.检查token是否有效
if !CheckToken(ctx) {
return
}
//3.查重uuid
//if !CheckUuid(ctx) {
// return
//}
return
}
... ...
... ... @@ -284,18 +284,21 @@ func CheckToken(request *protocol.CheckTokenRequest) (rsp *protocol.CheckTokenRe
//检查uuid 是否重复
func CheckUuid(request *protocol.CheckUuidRequest) (rsp *protocol.CheckUuidResponse, err error) {
//var (
// logUuid *models.LogUuid
//)
//if len(request.Uuid) == 0 {
// err = common.NewErrorWithMsg(4142, "uuid not empty")
//}
//logUuid, err = models.GetLogUuidByUuid(request.Uuid)
//if err == nil && logUuid != nil {
// err = common.NewErrorWithMsg(4142, "uuid not valid")
//}
//models.AddLogUuid(&models.LogUuid{Uuid: request.Uuid})
//rsp = &protocol.CheckUuidResponse{}
var ()
rsp = &protocol.CheckUuidResponse{}
if len(request.Uuid) == 0 || (request.Uuid == "123456" && beego.BConfig.RunMode != "prod") {
return
}
if redis.Hexists(protocol.RedisKey(protocol.HashUuid), request.Uuid) {
err = protocol.NewErrWithMessage(4142)
log.Error("[CheckUuid] 存在:", request.Uuid, err)
return
}
if e := redis.Hset(protocol.RedisKey(protocol.HashUuid), request.Uuid, request.Uuid, 3600*2); e == nil {
err = protocol.NewErrWithMessage(4142)
log.Error("[CheckUuid] 设置:", request.Uuid, e)
return
}
return
}
... ...