调整黑白名单
This commit is contained in:
parent
a1cd0acd25
commit
f3e2165269
@ -30,10 +30,10 @@ func (bpa *BlockPlayerApi) List(c *gin.Context) {
|
|||||||
constant.CONF_DB,
|
constant.CONF_DB,
|
||||||
q5.ToInt32(req.PageDto.PageSize),
|
q5.ToInt32(req.PageDto.PageSize),
|
||||||
q5.ToInt32(req.PageDto.Page),
|
q5.ToInt32(req.PageDto.Page),
|
||||||
"SELECT * FROM t_blockplayer WHERE 1=1 AND deleted = 0",
|
"SELECT * FROM t_blacklist WHERE 1=1",
|
||||||
[]string{},
|
[]string{},
|
||||||
f5.GetDbFilter().Comp([]f5.DbQueryFilter{}...),
|
f5.GetDbFilter().Comp([]f5.DbQueryFilter{}...),
|
||||||
" ORDER BY account_id ",
|
" ORDER BY user_identity ",
|
||||||
func(err error, pg *f5.Pagination) {
|
func(err error, pg *f5.Pagination) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
@ -45,8 +45,8 @@ func (bpa *BlockPlayerApi) List(c *gin.Context) {
|
|||||||
|
|
||||||
for pg.Rows.Next() {
|
for pg.Rows.Next() {
|
||||||
p := new(system.BlockPlayer)
|
p := new(system.BlockPlayer)
|
||||||
p.Blocked = q5.SafeToInt32(pg.Rows.GetByName("blocked"))
|
p.Enable = q5.SafeToInt32(pg.Rows.GetByName("enable"))
|
||||||
p.Account = pg.Rows.GetByName("account_id")
|
p.Identity = pg.Rows.GetByName("user_identity")
|
||||||
p.CreateTime = q5.SafeToInt32(pg.Rows.GetByName("createtime"))
|
p.CreateTime = q5.SafeToInt32(pg.Rows.GetByName("createtime"))
|
||||||
p.ModifyTime = q5.SafeToInt32(pg.Rows.GetByName("modifytime"))
|
p.ModifyTime = q5.SafeToInt32(pg.Rows.GetByName("modifytime"))
|
||||||
q5.AppendSlice(&result, p)
|
q5.AppendSlice(&result, p)
|
||||||
@ -64,7 +64,8 @@ func (bpa *BlockPlayerApi) List(c *gin.Context) {
|
|||||||
|
|
||||||
func (bpa *BlockPlayerApi) Add(c *gin.Context) {
|
func (bpa *BlockPlayerApi) Add(c *gin.Context) {
|
||||||
req := struct {
|
req := struct {
|
||||||
Account string `binding:"required" json:"account_id"`
|
Identity string `binding:"required" json:"user_identity"`
|
||||||
|
Enable int32 `json:"enable"`
|
||||||
}{}
|
}{}
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
@ -74,34 +75,20 @@ func (bpa *BlockPlayerApi) Add(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
info := new(system.BlockPlayer)
|
|
||||||
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
|
||||||
|
|
||||||
var count int64 = 0
|
var count int64 = 0
|
||||||
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Table("t_blockplayer").Where("account_id =?", req.Account)
|
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Table("t_blacklist").Where("user_identity =?", req.Identity)
|
||||||
if err := db.Count(&count).Error; err == nil && count > 0 {
|
if err := db.Count(&count).Error; err == nil && count > 0 {
|
||||||
db.Take(info)
|
c.JSON(http.StatusOK, gin.H{
|
||||||
if info.Deleted == 0 {
|
"code": 1,
|
||||||
c.JSON(http.StatusOK, gin.H{
|
"message": "数据存在",
|
||||||
"code": 1,
|
})
|
||||||
"message": "数据存在",
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
info.Blocked = 1
|
|
||||||
info.Deleted = 0
|
|
||||||
info.ModifyTime = nowDaySeconds
|
|
||||||
db.Save(info)
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"code": 0,
|
|
||||||
"message": "添加成功",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
info.Account = req.Account
|
info := new(system.BlockPlayer)
|
||||||
info.Blocked = 1
|
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
||||||
|
info.Identity = req.Identity
|
||||||
|
info.Enable = req.Enable
|
||||||
info.CreateTime = nowDaySeconds
|
info.CreateTime = nowDaySeconds
|
||||||
info.ModifyTime = nowDaySeconds
|
info.ModifyTime = nowDaySeconds
|
||||||
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(info).Error; err != nil {
|
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(info).Error; err != nil {
|
||||||
@ -119,8 +106,8 @@ func (bpa *BlockPlayerApi) Add(c *gin.Context) {
|
|||||||
|
|
||||||
func (bpa *BlockPlayerApi) Edit(c *gin.Context) {
|
func (bpa *BlockPlayerApi) Edit(c *gin.Context) {
|
||||||
req := struct {
|
req := struct {
|
||||||
Account string `binding:"required" json:"account_id"`
|
Identity string `binding:"required" json:"user_identity"`
|
||||||
Blocked int32 `json:"blocked"`
|
Enable int32 `json:"enable"`
|
||||||
}{}
|
}{}
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
@ -132,7 +119,7 @@ func (bpa *BlockPlayerApi) Edit(c *gin.Context) {
|
|||||||
|
|
||||||
blockplayer := new(system.BlockPlayer)
|
blockplayer := new(system.BlockPlayer)
|
||||||
db := f5.GetApp().GetOrmDb(constant.CONF_DB)
|
db := f5.GetApp().GetOrmDb(constant.CONF_DB)
|
||||||
if err := db.Take(blockplayer, "account_id = ? AND deleted = 0", req.Account).Error; err != nil {
|
if err := db.Take(blockplayer, "user_identity = ?", req.Identity).Error; err != nil {
|
||||||
if !f5.IsOrmErrRecordNotFound(err) {
|
if !f5.IsOrmErrRecordNotFound(err) {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 500,
|
"code": 500,
|
||||||
@ -148,15 +135,16 @@ func (bpa *BlockPlayerApi) Edit(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
if blockplayer.Enable != req.Enable {
|
||||||
blockplayer.Blocked = req.Blocked
|
blockplayer.Enable = req.Enable
|
||||||
blockplayer.ModifyTime = nowDaySeconds
|
blockplayer.ModifyTime = int32(f5.GetApp().GetRealSeconds())
|
||||||
if err := db.Where("account_id = ?", req.Account).Save(blockplayer).Error; err != nil {
|
if err := db.Where("user_identity = ?", req.Identity).Save(blockplayer).Error; err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 500,
|
"code": 500,
|
||||||
"message": "sever internal error:" + err.Error(),
|
"message": "sever internal error:" + err.Error(),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 0,
|
"code": 0,
|
||||||
@ -165,49 +153,49 @@ func (bpa *BlockPlayerApi) Edit(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (bpa *BlockPlayerApi) Del(c *gin.Context) {
|
func (bpa *BlockPlayerApi) Del(c *gin.Context) {
|
||||||
req := struct {
|
// req := struct {
|
||||||
Account string `binding:"required" json:"account_id"`
|
// Identity string `binding:"required" json:"user_identity"`
|
||||||
}{}
|
// }{}
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
// if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
// c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
// "code": 1,
|
||||||
"message": err.Error(),
|
// "message": err.Error(),
|
||||||
})
|
// })
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
blockplayer := new(system.BlockPlayer)
|
// blockplayer := new(system.BlockPlayer)
|
||||||
db := f5.GetApp().GetOrmDb(constant.CONF_DB)
|
// db := f5.GetApp().GetOrmDb(constant.CONF_DB)
|
||||||
if err := db.Take(blockplayer, "account_id = ? AND deleted = 0", req.Account).Error; err != nil {
|
// if err := db.Take(blockplayer, "user_identity = ?", req.Identity).Error; err != nil {
|
||||||
if !f5.IsOrmErrRecordNotFound(err) {
|
// if !f5.IsOrmErrRecordNotFound(err) {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
// c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 500,
|
// "code": 500,
|
||||||
"message": "sever internal error:" + err.Error(),
|
// "message": "sever internal error:" + err.Error(),
|
||||||
})
|
// })
|
||||||
return
|
// return
|
||||||
} else {
|
// } else {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
// c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 2,
|
// "code": 2,
|
||||||
"message": "无法查到记录",
|
// "message": "无法查到记录",
|
||||||
})
|
// })
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
}
|
// }
|
||||||
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
// nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
||||||
blockplayer.Deleted = 1
|
// blockplayer.Deleted = 1
|
||||||
blockplayer.ModifyTime = nowDaySeconds
|
// blockplayer.ModifyTime = nowDaySeconds
|
||||||
if err := db.Where("account_id = ?", req.Account).Save(blockplayer).Error; err != nil {
|
// if err := db.Where("user_identity = ?", req.Identity).Save(blockplayer).Error; err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
// c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 500,
|
// "code": 500,
|
||||||
"message": "sever internal error:" + err.Error(),
|
// "message": "sever internal error:" + err.Error(),
|
||||||
})
|
// })
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
c.JSON(http.StatusOK, gin.H{
|
// c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 0,
|
// "code": 0,
|
||||||
"message": "",
|
// "message": "",
|
||||||
})
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bpa *BlockPlayerApi) UploadExcel(c *gin.Context) {
|
func (bpa *BlockPlayerApi) UploadExcel(c *gin.Context) {
|
||||||
@ -242,8 +230,8 @@ func (bpa *BlockPlayerApi) UploadExcel(c *gin.Context) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
member := new(system.BlockPlayer)
|
member := new(system.BlockPlayer)
|
||||||
member.Account = row[0]
|
member.Identity = row[0]
|
||||||
member.Blocked = 1
|
member.Enable = 1
|
||||||
member.CreateTime = nowDaySeconds
|
member.CreateTime = nowDaySeconds
|
||||||
member.ModifyTime = nowDaySeconds
|
member.ModifyTime = nowDaySeconds
|
||||||
blockplayers = append(blockplayers, member)
|
blockplayers = append(blockplayers, member)
|
||||||
|
@ -16,7 +16,6 @@ type WhiteListApi struct {
|
|||||||
|
|
||||||
func (bpa *WhiteListApi) List(c *gin.Context) {
|
func (bpa *WhiteListApi) List(c *gin.Context) {
|
||||||
req := struct {
|
req := struct {
|
||||||
Type string `json:"type"`
|
|
||||||
PageDto system.PageDto `json:"page_dto"`
|
PageDto system.PageDto `json:"page_dto"`
|
||||||
}{}
|
}{}
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
@ -26,12 +25,8 @@ func (bpa *WhiteListApi) List(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sql := "SELECT * FROM t_whitelist WHERE 1=1 AND deleted = 0"
|
sql := "SELECT * FROM t_whitelist WHERE 1=1"
|
||||||
params := []string{}
|
params := []string{}
|
||||||
if req.Type != "" {
|
|
||||||
sql += " AND type = ?"
|
|
||||||
params = append(params, req.Type)
|
|
||||||
}
|
|
||||||
result := []*system.WhiteListItem{}
|
result := []*system.WhiteListItem{}
|
||||||
f5.GetGoStyleDb().PageQuery(
|
f5.GetGoStyleDb().PageQuery(
|
||||||
constant.CONF_DB,
|
constant.CONF_DB,
|
||||||
@ -40,7 +35,7 @@ func (bpa *WhiteListApi) List(c *gin.Context) {
|
|||||||
sql,
|
sql,
|
||||||
params,
|
params,
|
||||||
f5.GetDbFilter().Comp([]f5.DbQueryFilter{}...),
|
f5.GetDbFilter().Comp([]f5.DbQueryFilter{}...),
|
||||||
" ORDER BY account_id ",
|
" ORDER BY user_identity ",
|
||||||
func(err error, pg *f5.Pagination) {
|
func(err error, pg *f5.Pagination) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
@ -52,8 +47,8 @@ func (bpa *WhiteListApi) List(c *gin.Context) {
|
|||||||
|
|
||||||
for pg.Rows.Next() {
|
for pg.Rows.Next() {
|
||||||
p := new(system.WhiteListItem)
|
p := new(system.WhiteListItem)
|
||||||
p.Type = pg.Rows.GetByName("type")
|
p.Enable = q5.SafeToInt32(pg.Rows.GetByName("enable"))
|
||||||
p.Account = pg.Rows.GetByName("account_id")
|
p.Identity = pg.Rows.GetByName("user_identity")
|
||||||
p.CreateTime = q5.SafeToInt32(pg.Rows.GetByName("createtime"))
|
p.CreateTime = q5.SafeToInt32(pg.Rows.GetByName("createtime"))
|
||||||
p.ModifyTime = q5.SafeToInt32(pg.Rows.GetByName("modifytime"))
|
p.ModifyTime = q5.SafeToInt32(pg.Rows.GetByName("modifytime"))
|
||||||
q5.AppendSlice(&result, p)
|
q5.AppendSlice(&result, p)
|
||||||
@ -71,8 +66,8 @@ func (bpa *WhiteListApi) List(c *gin.Context) {
|
|||||||
|
|
||||||
func (bpa *WhiteListApi) Add(c *gin.Context) {
|
func (bpa *WhiteListApi) Add(c *gin.Context) {
|
||||||
req := struct {
|
req := struct {
|
||||||
Account string `binding:"required" json:"account_id"`
|
Identity string `binding:"required" json:"user_identity"`
|
||||||
Type string `binding:"required" json:"type"`
|
Enable int32 `json:"enable"`
|
||||||
}{}
|
}{}
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
@ -86,29 +81,17 @@ func (bpa *WhiteListApi) Add(c *gin.Context) {
|
|||||||
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
||||||
|
|
||||||
var count int64 = 0
|
var count int64 = 0
|
||||||
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Table("t_whitelist").Where("account_id = ? AND type = ?", req.Account, req.Type)
|
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Table("t_whitelist").Where("user_identity = ?", req.Identity)
|
||||||
if err := db.Count(&count).Error; err == nil && count > 0 {
|
if err := db.Count(&count).Error; err == nil && count > 0 {
|
||||||
db.Take(info)
|
c.JSON(http.StatusOK, gin.H{
|
||||||
if info.Deleted == 0 {
|
"code": 1,
|
||||||
c.JSON(http.StatusOK, gin.H{
|
"message": "数据存在",
|
||||||
"code": 1,
|
})
|
||||||
"message": "数据存在",
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
info.Deleted = 0
|
|
||||||
info.ModifyTime = nowDaySeconds
|
|
||||||
db.Save(info)
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"code": 0,
|
|
||||||
"message": "添加成功",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
info.Account = req.Account
|
info.Identity = req.Identity
|
||||||
info.Type = req.Type
|
info.Enable = req.Enable
|
||||||
info.CreateTime = nowDaySeconds
|
info.CreateTime = nowDaySeconds
|
||||||
info.ModifyTime = nowDaySeconds
|
info.ModifyTime = nowDaySeconds
|
||||||
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(info).Error; err != nil {
|
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(info).Error; err != nil {
|
||||||
@ -125,56 +108,9 @@ func (bpa *WhiteListApi) Add(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (bpa *WhiteListApi) Edit(c *gin.Context) {
|
func (bpa *WhiteListApi) Edit(c *gin.Context) {
|
||||||
// req := struct {
|
|
||||||
// Account string `binding:"required" json:"account_id"`
|
|
||||||
// Type string `json:"type"`
|
|
||||||
// }{}
|
|
||||||
// if err := c.ShouldBindJSON(&req); err != nil {
|
|
||||||
// c.JSON(http.StatusOK, gin.H{
|
|
||||||
// "code": 1,
|
|
||||||
// "message": err.Error(),
|
|
||||||
// })
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// whitelistitem := new(system.WhiteListItem)
|
|
||||||
// db := f5.GetApp().GetOrmDb(constant.CONF_DB)
|
|
||||||
// if err := db.Take(whitelistitem, "account_id =?", req.Account).Error; err != nil {
|
|
||||||
// if !f5.IsOrmErrRecordNotFound(err) {
|
|
||||||
// c.JSON(http.StatusOK, gin.H{
|
|
||||||
// "code": 500,
|
|
||||||
// "message": "sever internal error:" + err.Error(),
|
|
||||||
// })
|
|
||||||
// return
|
|
||||||
// } else {
|
|
||||||
// c.JSON(http.StatusOK, gin.H{
|
|
||||||
// "code": 2,
|
|
||||||
// "message": "无法查到记录",
|
|
||||||
// })
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
|
||||||
// whiteListItem.Blocked = req.Blocked
|
|
||||||
// whiteListItem.ModifyTime = nowDaySeconds
|
|
||||||
// if err := db.Where("account_id = ?", req.Account).Save(whiteListItem).Error; err != nil {
|
|
||||||
// c.JSON(http.StatusOK, gin.H{
|
|
||||||
// "code": 500,
|
|
||||||
// "message": "sever internal error:" + err.Error(),
|
|
||||||
// })
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// c.JSON(http.StatusOK, gin.H{
|
|
||||||
// "code": 0,
|
|
||||||
// "message": "",
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bpa *WhiteListApi) Del(c *gin.Context) {
|
|
||||||
req := struct {
|
req := struct {
|
||||||
Account string `binding:"required" json:"account_id"`
|
Identity string `binding:"required" json:"user_identity"`
|
||||||
Type string `json:"type"`
|
Enable int32 `json:"enable"`
|
||||||
}{}
|
}{}
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
@ -185,12 +121,8 @@ func (bpa *WhiteListApi) Del(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
whiteListItem := new(system.WhiteListItem)
|
whiteListItem := new(system.WhiteListItem)
|
||||||
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Where("account_id = ?", req.Account)
|
db := f5.GetApp().GetOrmDb(constant.CONF_DB)
|
||||||
if req.Type != "" {
|
if err := db.Take(whiteListItem, "user_identity =?", req.Identity).Error; err != nil {
|
||||||
db = db.Where("type = ?", req.Type)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := db.Take(whiteListItem).Error; err != nil {
|
|
||||||
if !f5.IsOrmErrRecordNotFound(err) {
|
if !f5.IsOrmErrRecordNotFound(err) {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 500,
|
"code": 500,
|
||||||
@ -204,33 +136,86 @@ func (bpa *WhiteListApi) Del(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if whiteListItem.Deleted == 1 {
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"code": 2,
|
|
||||||
"message": "无法查到记录",
|
|
||||||
})
|
|
||||||
|
|
||||||
|
if whiteListItem.Enable != req.Enable {
|
||||||
|
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
||||||
|
whiteListItem.Enable = req.Enable
|
||||||
|
whiteListItem.ModifyTime = nowDaySeconds
|
||||||
|
if err := db.Where("user_identity = ?", req.Identity).Save(whiteListItem).Error; err != nil {
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
"code": 500,
|
||||||
|
"message": "sever internal error:" + err.Error(),
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
|
||||||
whiteListItem.Deleted = 1
|
|
||||||
whiteListItem.ModifyTime = nowDaySeconds
|
|
||||||
|
|
||||||
if err := db.Save(whiteListItem).Error; err != nil {
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"code": 500,
|
|
||||||
"message": "sever internal error:" + err.Error(),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 0,
|
"code": 0,
|
||||||
"message": "",
|
"message": "",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (bpa *WhiteListApi) Del(c *gin.Context) {
|
||||||
|
// req := struct {
|
||||||
|
// Account string `binding:"required" json:"user_identity"`
|
||||||
|
// Type string `json:"type"`
|
||||||
|
// }{}
|
||||||
|
// if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
// c.JSON(http.StatusOK, gin.H{
|
||||||
|
// "code": 1,
|
||||||
|
// "message": err.Error(),
|
||||||
|
// })
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// whiteListItem := new(system.WhiteListItem)
|
||||||
|
// db := f5.GetApp().GetOrmDb(constant.CONF_DB).Where("user_identity = ?", req.Account)
|
||||||
|
// if req.Type != "" {
|
||||||
|
// db = db.Where("type = ?", req.Type)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if err := db.Take(whiteListItem).Error; err != nil {
|
||||||
|
// if !f5.IsOrmErrRecordNotFound(err) {
|
||||||
|
// c.JSON(http.StatusOK, gin.H{
|
||||||
|
// "code": 500,
|
||||||
|
// "message": "sever internal error:" + err.Error(),
|
||||||
|
// })
|
||||||
|
// return
|
||||||
|
// } else {
|
||||||
|
// c.JSON(http.StatusOK, gin.H{
|
||||||
|
// "code": 2,
|
||||||
|
// "message": "无法查到记录",
|
||||||
|
// })
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// if whiteListItem.Deleted == 1 {
|
||||||
|
// c.JSON(http.StatusOK, gin.H{
|
||||||
|
// "code": 2,
|
||||||
|
// "message": "无法查到记录",
|
||||||
|
// })
|
||||||
|
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
||||||
|
// whiteListItem.Deleted = 1
|
||||||
|
// whiteListItem.ModifyTime = nowDaySeconds
|
||||||
|
|
||||||
|
// if err := db.Save(whiteListItem).Error; err != nil {
|
||||||
|
// c.JSON(http.StatusOK, gin.H{
|
||||||
|
// "code": 500,
|
||||||
|
// "message": "sever internal error:" + err.Error(),
|
||||||
|
// })
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// c.JSON(http.StatusOK, gin.H{
|
||||||
|
// "code": 0,
|
||||||
|
// "message": "",
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
|
||||||
func (bpa *WhiteListApi) UploadExcel(c *gin.Context) {
|
func (bpa *WhiteListApi) UploadExcel(c *gin.Context) {
|
||||||
file, _, err := c.Request.FormFile("file")
|
file, _, err := c.Request.FormFile("file")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -263,9 +248,8 @@ func (bpa *WhiteListApi) UploadExcel(c *gin.Context) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
member := new(system.WhiteListItem)
|
member := new(system.WhiteListItem)
|
||||||
member.Account = row[0]
|
member.Identity = row[0]
|
||||||
member.Type = row[1]
|
member.Enable = 1
|
||||||
member.Deleted = 0
|
|
||||||
member.CreateTime = nowDaySeconds
|
member.CreateTime = nowDaySeconds
|
||||||
member.ModifyTime = nowDaySeconds
|
member.ModifyTime = nowDaySeconds
|
||||||
whitelist = append(whitelist, member)
|
whitelist = append(whitelist, member)
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package system
|
package system
|
||||||
|
|
||||||
type BlockPlayer struct {
|
type BlockPlayer struct {
|
||||||
Account string `gorm:"column:account_id" json:"account_id"`
|
Identity string `gorm:"column:user_identity" json:"user_identity"`
|
||||||
Blocked int32 `gorm:"column:blocked" json:"blocked"`
|
Enable int32 `gorm:"column:enable" json:"enable"`
|
||||||
Deleted int32 `gorm:"column:deleted" json:"deleted"`
|
|
||||||
CreateTime int32 `gorm:"column:createtime" json:"createtime"`
|
CreateTime int32 `gorm:"column:createtime" json:"createtime"`
|
||||||
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
|
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (BlockPlayer) TableName() string {
|
func (BlockPlayer) TableName() string {
|
||||||
return "t_blockplayer"
|
return "t_blacklist"
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package system
|
package system
|
||||||
|
|
||||||
type WhiteListItem struct {
|
type WhiteListItem struct {
|
||||||
Account string `gorm:"column:account_id" json:"account_id"`
|
Identity string `gorm:"column:user_identity" json:"user_identity"`
|
||||||
Type string `gorm:"column:type" json:"type"`
|
Enable int32 `gorm:"column:enable" json:"enable"`
|
||||||
Deleted int32 `gorm:"column:deleted" json:"deleted"`
|
|
||||||
CreateTime int32 `gorm:"column:createtime" json:"createtime"`
|
CreateTime int32 `gorm:"column:createtime" json:"createtime"`
|
||||||
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
|
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
|
||||||
}
|
}
|
||||||
@ -13,10 +12,7 @@ func (WhiteListItem) TableName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SuperWhiteListItem struct {
|
type SuperWhiteListItem struct {
|
||||||
Identity string `gorm:"column:user_identity" json:"user_identity"`
|
WhiteListItem
|
||||||
Enable int32 `gorm:"column:enable" json:"enable"`
|
|
||||||
CreateTime int32 `gorm:"column:createtime" json:"createtime"`
|
|
||||||
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (SuperWhiteListItem) TableName() string {
|
func (SuperWhiteListItem) TableName() string {
|
||||||
|
@ -16,7 +16,7 @@ func (this *BlockPlayerRoute) InitBlockPlayerRouter(priRouter *gin.RouterGroup)
|
|||||||
{
|
{
|
||||||
group.POST("add", middleware.Permission("api/v1/block_player/add", api.Add))
|
group.POST("add", middleware.Permission("api/v1/block_player/add", api.Add))
|
||||||
group.POST("edit", middleware.Permission("api/v1/block_player/edit", api.Edit))
|
group.POST("edit", middleware.Permission("api/v1/block_player/edit", api.Edit))
|
||||||
group.POST("del", middleware.Permission("api/v1/block_player/del", api.Del))
|
// group.POST("del", middleware.Permission("api/v1/block_player/del", api.Del))
|
||||||
group.POST("list", middleware.Permission("api/v1/block_player/list", api.List))
|
group.POST("list", middleware.Permission("api/v1/block_player/list", api.List))
|
||||||
group.POST("uploadExcel", middleware.Permission("api/v1/block_player/uploadExcel", api.UploadExcel))
|
group.POST("uploadExcel", middleware.Permission("api/v1/block_player/uploadExcel", api.UploadExcel))
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ func (this *WhiteListRoute) InitWhiteListRouter(priRouter *gin.RouterGroup) {
|
|||||||
api := v1.ApiGroupApp.SystemApiGroup.WhiteListApi
|
api := v1.ApiGroupApp.SystemApiGroup.WhiteListApi
|
||||||
{
|
{
|
||||||
group.POST("add", middleware.Permission("api/v1/white_list/add", api.Add))
|
group.POST("add", middleware.Permission("api/v1/white_list/add", api.Add))
|
||||||
//group.POST("edit", middleware.Permission("api/v1/white_list/edit", api.Edit))
|
group.POST("edit", middleware.Permission("api/v1/white_list/edit", api.Edit))
|
||||||
group.POST("del", middleware.Permission("api/v1/white_list/del", api.Del))
|
// group.POST("del", middleware.Permission("api/v1/white_list/del", api.Del))
|
||||||
group.POST("list", middleware.Permission("api/v1/white_list/list", api.List))
|
group.POST("list", middleware.Permission("api/v1/white_list/list", api.List))
|
||||||
group.POST("uploadExcel", middleware.Permission("api/v1/white_list/uploadExcel", api.UploadExcel))
|
group.POST("uploadExcel", middleware.Permission("api/v1/white_list/uploadExcel", api.UploadExcel))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user