mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
fix code
This commit is contained in:
parent
cb10df7c9f
commit
dfee8891d3
@ -8,6 +8,7 @@ import (
|
|||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/jinzhu/gorm"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -41,16 +42,19 @@ func QueryIPRegister(c *gin.Context) {
|
|||||||
resp.IP = req.IP
|
resp.IP = req.IP
|
||||||
resp.RegisterNum = len(userIDList)
|
resp.RegisterNum = len(userIDList)
|
||||||
resp.UserIDList = userIDList
|
resp.UserIDList = userIDList
|
||||||
ipLimits, err := imdb.QueryIPLimits(req.IP)
|
_, err = imdb.QueryIPLimits(req.IP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if gorm.IsRecordNotFoundError(err) {
|
||||||
|
resp.Status = 0
|
||||||
|
} else {
|
||||||
log.NewError(req.OperationID, "QueryIPLimits failed", req.IP, err.Error())
|
log.NewError(req.OperationID, "QueryIPLimits failed", req.IP, err.Error())
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "QueryIPLimits error!"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "QueryIPLimits error!"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if ipLimits.Ip != "" {
|
|
||||||
resp.Status = 1
|
resp.Status = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package im_mysql_model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"github.com/jinzhu/gorm"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,10 +34,7 @@ func IsLimitUserLoginIp(userID string, LoginIp string) (bool, error) {
|
|||||||
|
|
||||||
func QueryIPLimits(ip string) (*db.IpLimit, error) {
|
func QueryIPLimits(ip string) (*db.IpLimit, error) {
|
||||||
var ipLimit db.IpLimit
|
var ipLimit db.IpLimit
|
||||||
err := db.DB.MysqlDB.DefaultGormDB().Model(&db.IpLimit{}).Where("ip=?", ip).Take(&ip).Error
|
err := db.DB.MysqlDB.DefaultGormDB().Model(&db.IpLimit{}).Where("ip=?", ip).First(&ip).Error
|
||||||
if gorm.IsRecordNotFoundError(err) {
|
|
||||||
return &ipLimit, nil
|
|
||||||
}
|
|
||||||
return &ipLimit, err
|
return &ipLimit, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user