mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-30 06:22:44 +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 {
|
||||
Status int32 `json:"status" binding:"required"`
|
||||
Status int32 `json:"status"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
apiStruct.Pagination
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
@ -11,21 +12,21 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type QueryIPReq struct {
|
||||
type QueryIPRegisterReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
IP string `json:"ip"`
|
||||
}
|
||||
|
||||
type QueryIPResp struct {
|
||||
type QueryIPRegisterResp struct {
|
||||
IP string `json:"ip"`
|
||||
RegisterNum int `json:"num"`
|
||||
UserIDList []string `json:"userIDList"`
|
||||
Status int
|
||||
Status int `json:"status"`
|
||||
}
|
||||
|
||||
func QueryIP(c *gin.Context) {
|
||||
req := QueryIPReq{}
|
||||
resp := QueryIPResp{}
|
||||
func QueryIPRegister(c *gin.Context) {
|
||||
req := QueryIPRegisterReq{}
|
||||
resp := QueryIPRegisterResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
@ -42,24 +43,11 @@ func QueryIP(c *gin.Context) {
|
||||
for _, ip := range ips {
|
||||
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)
|
||||
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 {
|
||||
OperationID string `json:"operationID"`
|
||||
IP string `json:"ip"`
|
||||
@ -98,7 +86,7 @@ type RemoveIPLimitResp struct {
|
||||
}
|
||||
|
||||
func RemoveIPLimit(c *gin.Context) {
|
||||
|
||||
//DeleteOneFromIpLimits
|
||||
}
|
||||
|
||||
// ===========================================sk 写
|
||||
|
@ -38,3 +38,8 @@ func QueryUserIPLimits(ip string) ([]db.UserIpLimit, error) {
|
||||
func InsertOneIntoIpLimits(ipLimits db.IpLimit) 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