Browse Source

filter

master
黄梓健 5 years ago
parent
commit
2a6258b8a5
  1. 4
      controllers/author.go
  2. 7
      controllers/client/barrage.go
  3. 7
      controllers/client/bully_screen.go
  4. 9
      controllers/client/reward.go
  5. 30
      controllers/pc/lottery_draw.go
  6. 20
      controllers/pc/order_draw.go
  7. 10
      controllers/pc/shake_red_envelope.go
  8. 7
      libs/filter/filter.go

4
controllers/author.go

@ -48,10 +48,6 @@ func (t *AuthorCtl) MustGetCustomerId() int64 {
return t.claims.CustomerId
}
func (t *AuthorCtl) MustGetCustomerPid() int64 {
return t.claims.CustomerPid
}
func (t *AuthorCtl) MustGetAreaId() int64 {
return t.claims.AreaId
}

7
controllers/client/barrage.go

@ -25,10 +25,9 @@ func (t *BarrageCtl) Send() {
content := t.MustGet("content")
//检查内容是否包含敏感
//if models.IsSensitive(content) {
// t.ERROR("内容包含敏感字", code.MSG_ERR)
//}
content = filter.Replace(content)
if ok, _ := filter.Validate(content); !ok {
t.ERROR("内容包含敏感字", code.MSG_ERR)
}
//查询该活动的所属客户
activity := new(models.Activity)

7
controllers/client/bully_screen.go

@ -34,10 +34,9 @@ func (t *BullyScreenCtl) PaScreen() {
t.CheckRunning(activity.Status)
//检查内容是否包含敏感
//if models.IsSensitive(content) {
// t.ERROR("内容包含敏感字", code.MSG_ERR)
//}
content = filter.Replace(content)
if ok, _ := filter.Validate(content); !ok {
t.ERROR("内容包含敏感字", code.MSG_ERR)
}
//查询该活动的的霸屏服务id
bullyScreenServer := new(models.BullyScreenServer)

9
controllers/client/reward.go

@ -18,20 +18,19 @@ type RewardCtl struct {
controllers.AuthorCtl
}
// todo: 支付接口
func (t *RewardCtl) Reward() {
activityId := t.MustGetInt64("activity_id")
content := t.MustGet("content")
amount := t.MustGetDouble("amount")
uid := t.MustGetUID()
if amount <= 0 {
t.ERROR("打赏金额不能小于0", code.MSG_ERR_Param)
}
//检查内容是否包含敏感
//if models.IsSensitive(content) {
// t.ERROR("内容包含敏感字", code.MSG_ERR)
//}
content = filter.Replace(content)
if ok, _ := filter.Validate(content); !ok {
t.ERROR("内容包含敏感字", code.MSG_ERR)
}
activity := new(models.Activity)
exist, err := models.GetById(activity, activityId)

30
controllers/pc/lottery_draw.go

@ -81,9 +81,15 @@ type LotteryLadderResult struct {
//获取所有抽奖活动列表
func (t *LotteryDrawCtl) List() {
activityId := t.MustGetInt64("activity_id")
customerId := t.MustGetUID()
customer := new(models.Customer)
exist, err := models.GetById(customer, customerId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
activity := new(models.Activity)
exist, err := models.GetById(activity, activityId)
exist, err = models.GetById(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
@ -97,7 +103,7 @@ func (t *LotteryDrawCtl) List() {
// 多地区的一个坑:分配给主会场的area_id不是主账号的area_id
area := new(models.AreaStore)
if t.MustGetCustomerPid() == 0 {
if customer.Pid == 0 {
exist, err = area.GetMainAreaById(activityId)
} else {
exist, err = area.GetAreaStoreById(t.MustGetAreaId())
@ -178,14 +184,20 @@ type LotteryUsersResult struct {
func (t *LotteryDrawCtl) Users() {
activityId := t.MustGetInt64("activity_id")
ruleId := t.MustGetInt64("lottery_draw_rule_id")
customerId := t.MustGetUID()
customer := new(models.Customer)
exist, err := models.GetById(customer, customerId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
activity := new(models.Activity)
exist, err := models.GetById(activity, activityId)
exist, err = models.GetById(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
area := new(models.AreaStore)
if t.MustGetCustomerPid() == 0 {
if customer.Pid == 0 {
exist, err = area.GetMainAreaById(activityId)
} else {
exist, err = area.GetAreaStoreById(t.MustGetAreaId())
@ -227,16 +239,22 @@ func (t *LotteryDrawCtl) Lottery() {
ruleId := t.MustGetInt64("lottery_draw_rule_id")
ladderId := t.MustGetInt64("lottery_draw_ladder_id")
number := t.MustGetInt("number") // 奖品数量
customerId := t.MustGetUID()
customer := new(models.Customer)
exist, err := models.GetById(customer, customerId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
activity := new(models.Activity)
exist, err := models.GetById(activity, activityId)
exist, err = models.GetById(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
t.CheckRunning(activity.Status)
// 多地区设置
area := new(models.AreaStore)
if t.MustGetCustomerPid() == 0 {
if customer.Pid == 0 {
exist, err = area.GetMainAreaById(activity.Id)
} else {
exist, err = area.GetAreaStoreById(t.MustGetAreaId())

20
controllers/pc/order_draw.go

@ -111,9 +111,15 @@ type OrderLadderResult struct {
//获取所有订单奖品
func (t *OrderDrawCtl) List() {
activityId := t.MustGetInt64("activity_id")
customerId := t.MustGetUID()
customer := new(models.Customer)
exist, err := models.GetById(customer, customerId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
activity := new(models.Activity)
exist, err := models.GetById(activity, activityId)
exist, err = models.GetById(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
@ -132,7 +138,7 @@ func (t *OrderDrawCtl) List() {
// 多地区的一个坑:分配给主会场的area_id不是主账号的area_id
area := new(models.AreaStore)
if t.MustGetCustomerPid() == 0 {
if customer.Pid == 0 {
exist, err = area.GetMainAreaById(activityId)
} else {
exist, err = area.GetAreaStoreById(t.MustGetAreaId())
@ -253,15 +259,21 @@ func (t *OrderDrawCtl) Draw() {
ruleId := t.MustGetInt64("order_draw_rule_id")
ladderId := t.MustGetInt64("order_draw_rule_ladder_id")
number := t.MustGetInt("number")
customerId := t.MustGetUID()
customer := new(models.Customer)
exist, err := models.GetById(customer, customerId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
activity := new(models.Activity)
exist, err := models.GetById(activity, activityId)
exist, err = models.GetById(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
t.CheckRunning(activity.Status)
area := new(models.AreaStore)
if t.MustGetCustomerPid() == 0 {
if customer.Pid == 0 {
exist, err = area.GetMainAreaById(activity.Id)
} else {
exist, err = area.GetAreaStoreById(t.MustGetAreaId())

10
controllers/pc/shake_red_envelope.go

@ -91,9 +91,15 @@ func (t *ShakeRedEnvelopeCtl) Stop() {
func (t *ShakeRedEnvelopeCtl) List() {
activityId := t.MustGetInt64("activity_id")
customerId := t.MustGetUID()
customer := new(models.Customer)
exist, err := models.GetById(customer, customerId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
activity := new(models.Activity)
exist, err := models.GetById(activity, activityId)
exist, err = models.GetById(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
t.CheckRunning(activity.Status)
@ -106,7 +112,7 @@ func (t *ShakeRedEnvelopeCtl) List() {
aIds = append(aIds, v.Id)
}
area := new(models.AreaStore)
if t.MustGetCustomerPid() == 0 {
if customer.Pid == 0 {
exist, err = area.GetMainAreaById(activityId)
} else {
exist, err = area.GetAreaStoreById(t.MustGetAreaId())

7
libs/filter/filter.go

@ -24,3 +24,10 @@ func Replace(content string) string {
}
return filter.Replace(content, '*')
}
func Validate(content string) (bool, string) {
if filter == nil {
initFilter()
}
return filter.Validate(content)
}
Loading…
Cancel
Save