mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-30 14:32:37 +08:00
ip limit
This commit is contained in:
parent
7d1707ca7c
commit
05d45c94d5
@ -80,7 +80,7 @@ func QueryInvitationCode(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetInvitationCodesReq struct {
|
type GetInvitationCodesReq struct {
|
||||||
Status int32 `json:"status" binding:"required"`
|
Status int32 `json:"status"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
apiStruct.Pagination
|
apiStruct.Pagination
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package register
|
package register
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
api "Open_IM/pkg/base_info"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
@ -11,21 +12,21 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type QueryIPReq struct {
|
type QueryIPRegisterReq struct {
|
||||||
OperationID string `json:"operationID"`
|
OperationID string `json:"operationID"`
|
||||||
IP string `json:"ip"`
|
IP string `json:"ip"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type QueryIPResp struct {
|
type QueryIPRegisterResp struct {
|
||||||
IP string `json:"ip"`
|
IP string `json:"ip"`
|
||||||
RegisterNum int `json:"num"`
|
RegisterNum int `json:"num"`
|
||||||
UserIDList []string `json:"userIDList"`
|
UserIDList []string `json:"userIDList"`
|
||||||
Status int
|
Status int `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func QueryIP(c *gin.Context) {
|
func QueryIPRegister(c *gin.Context) {
|
||||||
req := QueryIPReq{}
|
req := QueryIPRegisterReq{}
|
||||||
resp := QueryIPResp{}
|
resp := QueryIPRegisterResp{}
|
||||||
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()})
|
||||||
return
|
return
|
||||||
@ -42,24 +43,11 @@ func QueryIP(c *gin.Context) {
|
|||||||
for _, ip := range ips {
|
for _, ip := range ips {
|
||||||
resp.UserIDList = append(resp.UserIDList, ip.UserID)
|
resp.UserIDList = append(resp.UserIDList, ip.UserID)
|
||||||
}
|
}
|
||||||
b, _ := imdb.IsLimitLoginIp(req.IP)
|
|
||||||
if b == true {
|
|
||||||
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})
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetIPListReq struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetIPListResp struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetIPList(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type AddIPLimitReq struct {
|
type AddIPLimitReq struct {
|
||||||
OperationID string `json:"operationID"`
|
OperationID string `json:"operationID"`
|
||||||
IP string `json:"ip"`
|
IP string `json:"ip"`
|
||||||
@ -98,7 +86,7 @@ type RemoveIPLimitResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RemoveIPLimit(c *gin.Context) {
|
func RemoveIPLimit(c *gin.Context) {
|
||||||
|
//DeleteOneFromIpLimits
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================sk 写
|
// ===========================================sk 写
|
||||||
|
@ -38,3 +38,8 @@ func QueryUserIPLimits(ip string) ([]db.UserIpLimit, error) {
|
|||||||
func InsertOneIntoIpLimits(ipLimits db.IpLimit) error {
|
func InsertOneIntoIpLimits(ipLimits db.IpLimit) error {
|
||||||
return db.DB.MysqlDB.DefaultGormDB().Model(&db.IpLimit{}).Create(ipLimits).Error
|
return db.DB.MysqlDB.DefaultGormDB().Model(&db.IpLimit{}).Create(ipLimits).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DeleteOneFromIpLimits(ip string) error {
|
||||||
|
ipLimits := &db.IpLimit{}
|
||||||
|
return db.DB.MysqlDB.DefaultGormDB().Model(ipLimits).Where("ip=?", ip).Delete(ipLimits).Error
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user