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
b705ac24fa
commit
919e2543ca
@ -46,7 +46,7 @@ func main() {
|
||||
cmsRouterGroup.POST("/query_invitation_code", register.QueryInvitationCode)
|
||||
cmsRouterGroup.POST("/get_invitation_codes", register.GetInvitationCodes)
|
||||
|
||||
cmsRouterGroup.POST("/query_user_ip_limit_login", register.QueryUserIPLimitLogin)
|
||||
cmsRouterGroup.POST("/query_user_ip_limit_login", register.QueryUserIDLimitLogin)
|
||||
cmsRouterGroup.POST("/add_user_ip_limit_login", register.AddUserIPLimitLogin)
|
||||
cmsRouterGroup.POST("/remove_user_ip_limit_login", register.RemoveUserIPLimitLogin)
|
||||
|
||||
|
@ -43,7 +43,7 @@ func QueryIPRegister(c *gin.Context) {
|
||||
resp.UserIDList = userIDList
|
||||
ipLimits, err := imdb.QueryIPLimits(req.IP)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "QueryIPLimits failed", req.IP)
|
||||
log.NewError(req.OperationID, "QueryIPLimits failed", req.IP, err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "QueryIPLimits error!"})
|
||||
return
|
||||
}
|
||||
@ -76,7 +76,7 @@ func AddIPLimit(c *gin.Context) {
|
||||
LimitRegister: 1,
|
||||
LimitLogin: 1,
|
||||
CreateTime: time.Now(),
|
||||
LimitTime: time.Time{},
|
||||
LimitTime: utils.UnixSecondToTime(int64(req.LimitTime)),
|
||||
}); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.IP, req.LimitTime)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "InsertOneIntoIpLimits error!"})
|
||||
@ -94,15 +94,15 @@ type RemoveIPLimitResp struct {
|
||||
}
|
||||
|
||||
func RemoveIPLimit(c *gin.Context) {
|
||||
req := AddIPLimitReq{}
|
||||
req := RemoveIPLimitReq{}
|
||||
//resp := AddIPLimitResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrArgs, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
if err := imdb.DeleteOneFromIpLimits(req.IP); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.IP, req.LimitTime)
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.IP)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "InsertOneIntoIpLimits error!"})
|
||||
return
|
||||
}
|
||||
@ -120,7 +120,7 @@ type QueryUserIDIPLimitLoginReq struct {
|
||||
// UserIpLimit []db.UserIpLimit `json:"userIpLimit"`
|
||||
//}
|
||||
|
||||
func QueryUserIPLimitLogin(c *gin.Context) {
|
||||
func QueryUserIDLimitLogin(c *gin.Context) {
|
||||
req := QueryUserIDIPLimitLoginReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
@ -138,7 +138,7 @@ func QueryUserIPLimitLogin(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": "[]"})
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
|
||||
type AddUserIPLimitLoginReq struct {
|
||||
|
@ -53,7 +53,7 @@ func InsertOneIntoIpLimits(ipLimits db.IpLimit) error {
|
||||
}
|
||||
|
||||
func DeleteOneFromIpLimits(ip string) error {
|
||||
ipLimits := &db.IpLimit{}
|
||||
ipLimits := &db.IpLimit{Ip: ip}
|
||||
return db.DB.MysqlDB.DefaultGormDB().Model(ipLimits).Where("ip=?", ip).Delete(ipLimits).Error
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user