mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-07 19:50:07 +08:00
fix code
This commit is contained in:
parent
37193c48d9
commit
7f252909fc
@ -44,17 +44,14 @@ func QueryIPRegister(c *gin.Context) {
|
||||
resp.UserIDList = userIDList
|
||||
ipLimit, err := imdb.QueryIPLimits(req.IP)
|
||||
if err != nil {
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
resp.Status = 0
|
||||
} else {
|
||||
log.NewError(req.OperationID, "QueryIPLimits failed", req.IP, err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "QueryIPLimits error!"})
|
||||
return
|
||||
}
|
||||
log.NewError(req.OperationID, "QueryIPLimits failed", req.IP, err.Error())
|
||||
} else {
|
||||
if ipLimit.Ip != "" {
|
||||
resp.Status = 1
|
||||
if ipLimit != nil {
|
||||
if ipLimit.Ip != "" {
|
||||
resp.Status = 1
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
|
@ -34,7 +34,7 @@ func IsLimitUserLoginIp(userID string, LoginIp string) (bool, error) {
|
||||
|
||||
func QueryIPLimits(ip string) (*db.IpLimit, error) {
|
||||
var ipLimit db.IpLimit
|
||||
err := db.DB.MysqlDB.DefaultGormDB().Model(&db.IpLimit{}).Where("ip=?", ip).Find(&ip).Error
|
||||
err := db.DB.MysqlDB.DefaultGormDB().Model(&db.IpLimit{}).Where("ip=?", ip).First(&ip).Error
|
||||
return &ipLimit, err
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user