互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3 KiB

5 years ago
  1. package pc
  2. import (
  3. "hudongzhuanjia/controllers"
  4. "hudongzhuanjia/models"
  5. "hudongzhuanjia/utils/code"
  6. )
  7. //弹幕
  8. type BarrageCtl struct {
  9. controllers.AuthorCtl
  10. }
  11. //获取活动的详情
  12. func (t *BarrageCtl) Details() {
  13. activityId := t.MustGetInt64("activity_id")
  14. server := new(models.DanMuServer)
  15. exist, err := server.GetByActivityId(activityId)
  16. t.CheckErr(err)
  17. t.Assert(exist, code.MSG_BARRAGE_SERVER_NOT_EXIST, "弹幕不存在")
  18. t.JSON(map[string]interface{}{
  19. "server": server,
  20. })
  21. }
  22. func (t *BarrageCtl) SaveSetting() {
  23. activityId := t.MustGetInt64("activity_id")
  24. activity := new(models.Activity)
  25. exist, err := models.GetById(activity, activityId)
  26. t.CheckErr(err)
  27. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  28. danmuId := t.MustGetInt64("danmu_server_id")
  29. server := new(models.DanMuServer)
  30. server.DanmuFontSize = t.MustGet("font_size")
  31. server.DanmuOpacity = t.MustGetInt("opacity")
  32. server.DanmuPosition = t.MustGet("position")
  33. server.DanmuSpeed = t.MustGetInt("speed")
  34. server.ServerDisplay = t.MustGet("display")
  35. models.Save(map[string]interface{}{
  36. "is_delete=": 0,
  37. "id=": danmuId,
  38. }, server, "danmu_font_size", "danmu_opacity", "danmu_position", "danmu_speed", "server_display")
  39. t.CheckErr(err)
  40. t.SUCCESS("success")
  41. }