|
|
@ -43,7 +43,7 @@ func QueryIPRegister(c *gin.Context) {
|
|
|
|
resp.UserIDList = userIDList
|
|
|
|
resp.UserIDList = userIDList
|
|
|
|
ipLimits, err := imdb.QueryIPLimits(req.IP)
|
|
|
|
ipLimits, err := imdb.QueryIPLimits(req.IP)
|
|
|
|
if err != nil {
|
|
|
|
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!"})
|
|
|
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "QueryIPLimits error!"})
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -76,7 +76,7 @@ func AddIPLimit(c *gin.Context) {
|
|
|
|
LimitRegister: 1,
|
|
|
|
LimitRegister: 1,
|
|
|
|
LimitLogin: 1,
|
|
|
|
LimitLogin: 1,
|
|
|
|
CreateTime: time.Now(),
|
|
|
|
CreateTime: time.Now(),
|
|
|
|
LimitTime: time.Time{},
|
|
|
|
LimitTime: utils.UnixSecondToTime(int64(req.LimitTime)),
|
|
|
|
}); err != nil {
|
|
|
|
}); err != nil {
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.IP, req.LimitTime)
|
|
|
|
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!"})
|
|
|
|
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) {
|
|
|
|
func RemoveIPLimit(c *gin.Context) {
|
|
|
|
req := AddIPLimitReq{}
|
|
|
|
req := RemoveIPLimitReq{}
|
|
|
|
//resp := AddIPLimitResp{}
|
|
|
|
//resp := AddIPLimitResp{}
|
|
|
|
if err := c.BindJSON(&req); err != nil {
|
|
|
|
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
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
|
|
|
if err := imdb.DeleteOneFromIpLimits(req.IP); err != nil {
|
|
|
|
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!"})
|
|
|
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "InsertOneIntoIpLimits error!"})
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -120,7 +120,7 @@ type QueryUserIDIPLimitLoginReq struct {
|
|
|
|
// UserIpLimit []db.UserIpLimit `json:"userIpLimit"`
|
|
|
|
// UserIpLimit []db.UserIpLimit `json:"userIpLimit"`
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
func QueryUserIPLimitLogin(c *gin.Context) {
|
|
|
|
func QueryUserIDLimitLogin(c *gin.Context) {
|
|
|
|
req := QueryUserIDIPLimitLoginReq{}
|
|
|
|
req := QueryUserIDIPLimitLoginReq{}
|
|
|
|
if err := c.BindJSON(&req); err != nil {
|
|
|
|
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.FormattingError, "errMsg": err.Error()})
|
|
|
@ -138,7 +138,7 @@ func QueryUserIPLimitLogin(c *gin.Context) {
|
|
|
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
|
|
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
|
|
|
return
|
|
|
|
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 {
|
|
|
|
type AddUserIPLimitLoginReq struct {
|
|
|
|