This commit is contained in:
wangchuxiao 2022-08-15 20:36:16 +08:00
parent 37193c48d9
commit 7f252909fc
2 changed files with 7 additions and 10 deletions

View File

@ -44,17 +44,14 @@ func QueryIPRegister(c *gin.Context) {
resp.UserIDList = userIDList resp.UserIDList = userIDList
ipLimit, err := imdb.QueryIPLimits(req.IP) ipLimit, err := imdb.QueryIPLimits(req.IP)
if err != nil { if err != nil {
if gorm.IsRecordNotFoundError(err) { log.NewError(req.OperationID, "QueryIPLimits failed", req.IP, err.Error())
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
}
} else { } else {
if ipLimit.Ip != "" { if ipLimit != nil {
resp.Status = 1 if ipLimit.Ip != "" {
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})

View File

@ -34,7 +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).Find(&ip).Error err := db.DB.MysqlDB.DefaultGormDB().Model(&db.IpLimit{}).Where("ip=?", ip).First(&ip).Error
return &ipLimit, err return &ipLimit, err
} }