datamodel.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. package anchorsnipemodel
  2. import (
  3. "active/internal/model/broadcast"
  4. "git.jiaxianghudong.com/go/logs"
  5. "git.jiaxianghudong.com/webs/pkg/xgorm"
  6. )
  7. const Blocklist = "blocklist"
  8. // 活动开启返回
  9. type ActiveDetailRsp struct {
  10. StartTimestamp int64 `json:"start_timestamp"` // 活动开始时间戳(秒)
  11. EndTimestamp int64 `json:"end_timestamp"` // 活动结束时间戳(秒)
  12. }
  13. // 主播上线/进入游戏 上报数据,更新配置
  14. type ReportAnchorReq struct {
  15. ActType int32 `json:"act_type" form:"act_type"` // 上报行为,0-上线,1-进入游戏
  16. Beans int64 `json:"beans" form:"beans"` // 上线-豆豆数量
  17. GameID int32 `json:"game_id" form:"game_id"` // 进入游戏-进入的哪个游戏id
  18. PlayMode string `json:"play_mode" form:"play_mode"` // 游戏玩法
  19. RoomType int64 `json:"room_type" form:"room_type"` // 房间类型
  20. }
  21. // 主播配置
  22. type AnchorData struct {
  23. UserID int32 `json:"user_id" form:"user_id"` // 主播的游戏id
  24. Beans int64 `json:"beans" form:"beans"` // 豆豆数
  25. GameID int32 `json:"game_id" form:"game_id"` // 主播直播的游戏
  26. PlayMode string `json:"play_mode" form:"play_mode"` // 主播直播的游戏玩法
  27. IsOnline int32 `json:"is_online" form:"is_online"` // 是否在直播
  28. Starttime int32 `json:"starttime" form:"starttime"` // 开播时间戳(秒)
  29. Endtime int32 `json:"endtime" form:"endtime"` // 下播时间戳(秒)
  30. RoomType int64 `json:"room_type" form:"room_type"` // 房间类型
  31. }
  32. // 返回狙击主播列表
  33. type SnipeAnchorlistRsp struct {
  34. RemainCt int32 `json:"remain_ct" form:"remain_ct"` // 剩余次数
  35. TotalCt int32 `json:"total_ct" form:"total_ct"` // 总次数
  36. FailAward int32 `json:"fail_award" form:"fail_award"` // 狙击失败奖励,现在只有豆豆
  37. IsBlock bool `json:"is_block" form:"is_block"` // 是否被拉黑
  38. Anchors []AnchorData `json:"anchors" form:"anchors"` // 主播配置列表
  39. }
  40. // 游戏结果玩家数据
  41. type UserGameData struct {
  42. UserID int32 `json:"user_id" form:"user_id"` // 玩家id
  43. GameRes int32 `json:"game_res" form:"game_res"` // 玩家输赢结果
  44. BeansWin int64 `json:"beans_win" form:"beans_win"` // 赢取的豆豆数,赢为正,输为负
  45. Identity int32 `json:"identity" form:"identity"` // 身份,客户端自己约定
  46. }
  47. // 请求狙击排行榜
  48. type DayRanklistReq struct {
  49. AnUserID int32 `json:"an_userid" form:"an_userid"` // 主播的游戏id
  50. }
  51. // 狙击者数据
  52. type SniperData struct {
  53. UserID int32 `json:"user_id" form:"user_id"` // 玩家id
  54. SnipeCount int32 `json:"snipe_count" form:"snipe_count"` // 狙击次数
  55. WinBeans int64 `json:"win_beans" form:"win_beans"` // 狙击金币
  56. }
  57. // 返回日榜家数据
  58. type DayRanklistRsp struct {
  59. AnUserID int32 `json:"an_userid" form:"an_userid"` // 主播的游戏id
  60. SnipedCount int32 `json:"sniped_count" form:"sniped_count"` // 被狙击次数
  61. DefendSuccess int32 `json:"defend_success" form:"defend_success"` // 防守成功次数
  62. DefendFail int32 `json:"defend_fail" form:"defend_fail"` // 防守失败次数
  63. SniperList []SniperData `json:"sniper_list" form:"sniper_list"` // 狙击者数据
  64. }
  65. // 请求每天对局记录
  66. type DayRecordsReq struct {
  67. AnUserID int32 `json:"an_userid" form:"an_userid"` // 主播的游戏id
  68. }
  69. // 对局记录
  70. type SnipeRecord struct {
  71. RoomType int32 `json:"room_type" form:"room_type"` // 游戏场次
  72. GameID int32 `json:"game_id" form:"game_id"` // 主播直播的游戏
  73. PlayMode string `json:"play_mode" form:"play_mode"` // 主播直播的游戏玩法
  74. Endtime int32 `json:"endtime" form:"endtime"` // 结束时间戳(秒)
  75. GameRes int32 `json:"game_res" form:"game_res"` // 玩家输赢结果 0-失败,1-胜利,2-平局
  76. LoseBeans int64 `json:"lose_beans" form:"lose_beans"` // 主播输掉的豆豆数,被褥豆豆数
  77. Identity int32 `json:"identity" form:"identity"` // 身份,客户端自己约定
  78. Snipers []UserGameData `json:"sniper" form:"sniper"` // 狙击者数据
  79. }
  80. // 返回每天对局记录
  81. type DayRecordsRsp struct {
  82. Records []SnipeRecord `json:"records" form:"records"` // 对局记录
  83. }
  84. // 主播拉黑玩家
  85. type BlockUserReq struct {
  86. ChallengerID uint32 `json:"challenger_id" form:"challenger_id"` // 挑战者ID
  87. }
  88. // 拉黑列表mysql数据
  89. type BlockUserData struct {
  90. BlockId uint32 `json:"blockid" gorm:"column:blockid"` // 被拉黑玩家id
  91. AnchorId uint32 `json:"anchorid" gorm:"column:anchorid"` // 主播id
  92. }
  93. // 保存拉黑数据
  94. func (this *BlockUserData) Save() {
  95. xdb := xgorm.NewConn(broadcast.AnchorGorm)
  96. if err := xdb.Table(Blocklist).Create(this).Error; err != nil {
  97. logs.Errorf("save blockUserData:%+v, err=%v", *this, err)
  98. return
  99. }
  100. logs.Infof("user beblock,blickid:%d,anchorid:%v", this.BlockId, this.AnchorId)
  101. }
  102. // 是否被拉黑
  103. func IsBlock(userid uint32) bool {
  104. xdb := xgorm.NewConn(broadcast.AnchorGorm)
  105. count := int64(0)
  106. xdb.Table(Blocklist).Select("blockid").Where("blockid = ?", userid).Count(&count)
  107. if count > 0 {
  108. return true
  109. }
  110. return false
  111. }
  112. //****************************************服务器接口****************************************
  113. type ParamConfigReq struct {
  114. UserID int32 `json:"user_id" form:"user_id"` // 玩家ID
  115. }
  116. // 返回配置给游戏服务器
  117. type ParamsConfigRsp struct {
  118. UserID int32 `json:"user_id" form:"user_id"` // 玩家ID
  119. RemainCt int32 `json:"remain_ct" form:"remain_ct"` // 剩余次数
  120. MaxCount int32 `json:"max_count" form:"max_count"` // 狙击最大次数
  121. FailBeans int32 `json:"fail_beans" form:"fail_beans"` // 狙击失败奖励的豆豆数
  122. }
  123. // 上报游戏结果数据
  124. type ReportGameResultReq struct {
  125. RoomType int32 `json:"room_type" form:"room_type"` // 游戏场次
  126. Snipers []int32 `json:"snipers" form:"snipers"` // 参与者ID
  127. UsersData []UserGameData `json:"users_data" form:"users_data"` // 玩家列表
  128. }
  129. //****************************************服务器接口****************************************