黑名单封禁时间

master
czx 2023-08-16 12:12:11 +08:00
parent 4672866814
commit 952ed777eb
2 changed files with 15 additions and 2 deletions

View File

@ -965,6 +965,7 @@ func (action *Action) DelWhiteList(r *ghttp.Request) {
//黑名单列表
func (action *Action) BlackList(r *ghttp.Request) {
var timeLayoutStr = "2006-01-02 15:04:05"
form := base.NewForm(r.GetMap())
bs := bson.D{}
if form.Params != nil {
@ -992,6 +993,11 @@ func (action *Action) BlackList(r *ghttp.Request) {
}
dayMap.Set("id", blackList.Id)
dayMap.Set("openId", blackList.OpenId)
if blackList.UnblockTime > 0 {
dayMap.Set("unblockTime", time.Unix(blackList.UnblockTime, 0).Format(timeLayoutStr))
} else {
dayMap.Set("unblockTime", "永久封禁")
}
data = append(g.ListAnyAny{gconv.Map(dayMap)}, data...)
}
fmt.Println(data)
@ -1008,6 +1014,7 @@ func (action *Action) BlackList(r *ghttp.Request) {
func (action *Action) SaveBlackList(r *ghttp.Request) {
id := r.Form.Get("id")
openid := r.Form.Get("openId")
blockTime := gconv.Int64(r.Form.Get("time"))
obj_id := primitive.NewObjectID()
if id != "" {
obj_id, _ = primitive.ObjectIDFromHex(id)
@ -1015,6 +1022,11 @@ func (action *Action) SaveBlackList(r *ghttp.Request) {
blackList := new(gameinfo.BlackList)
blackList.Id = obj_id
blackList.OpenId = openid
if blockTime > 0 {
blackList.UnblockTime = time.Now().Unix() + blockTime*60
} else {
blackList.UnblockTime = -1
}
res := gameinfo.ModelBlackList.AddBlackList(id, openid, blackList)
if res > 0 {
base.Succ(r, g.Map{"code": 0, "result": "操作成功"})

View File

@ -7,8 +7,9 @@ import (
)
type BlackList struct {
Id primitive.ObjectID `bson:"_id" json:"id"`
OpenId string `bson:"openId" json:"openId"`
Id primitive.ObjectID `bson:"_id" json:"id"`
OpenId string `bson:"openId" json:"openId"`
UnblockTime int64 `bson:"unblockTime" json:"unblockTime"`
}
var (