123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- package anchorsnipemodel
- import (
- "active/internal/model/broadcast"
- "git.jiaxianghudong.com/go/logs"
- "git.jiaxianghudong.com/webs/pkg/xgorm"
- )
- const Blocklist = "blocklist"
- // 活动开启返回
- type ActiveDetailRsp struct {
- StartTimestamp int64 `json:"start_timestamp"` // 活动开始时间戳(秒)
- EndTimestamp int64 `json:"end_timestamp"` // 活动结束时间戳(秒)
- }
- // 主播上线/进入游戏 上报数据,更新配置
- type ReportAnchorReq struct {
- ActType int32 `json:"act_type" form:"act_type"` // 上报行为,0-上线,1-进入游戏
- Beans int64 `json:"beans" form:"beans"` // 上线-豆豆数量
- GameID int32 `json:"game_id" form:"game_id"` // 进入游戏-进入的哪个游戏id
- PlayMode string `json:"play_mode" form:"play_mode"` // 游戏玩法
- RoomType int64 `json:"room_type" form:"room_type"` // 房间类型
- }
- // 主播配置
- type AnchorData struct {
- UserID int32 `json:"user_id" form:"user_id"` // 主播的游戏id
- Beans int64 `json:"beans" form:"beans"` // 豆豆数
- GameID int32 `json:"game_id" form:"game_id"` // 主播直播的游戏
- PlayMode string `json:"play_mode" form:"play_mode"` // 主播直播的游戏玩法
- IsOnline int32 `json:"is_online" form:"is_online"` // 是否在直播
- Starttime int32 `json:"starttime" form:"starttime"` // 开播时间戳(秒)
- Endtime int32 `json:"endtime" form:"endtime"` // 下播时间戳(秒)
- RoomType int64 `json:"room_type" form:"room_type"` // 房间类型
- }
- // 返回狙击主播列表
- type SnipeAnchorlistRsp struct {
- RemainCt int32 `json:"remain_ct" form:"remain_ct"` // 剩余次数
- TotalCt int32 `json:"total_ct" form:"total_ct"` // 总次数
- FailAward int32 `json:"fail_award" form:"fail_award"` // 狙击失败奖励,现在只有豆豆
- IsBlock bool `json:"is_block" form:"is_block"` // 是否被拉黑
- Anchors []AnchorData `json:"anchors" form:"anchors"` // 主播配置列表
- }
- // 游戏结果玩家数据
- type UserGameData struct {
- UserID int32 `json:"user_id" form:"user_id"` // 玩家id
- GameRes int32 `json:"game_res" form:"game_res"` // 玩家输赢结果
- BeansWin int64 `json:"beans_win" form:"beans_win"` // 赢取的豆豆数,赢为正,输为负
- Identity int32 `json:"identity" form:"identity"` // 身份,客户端自己约定
- }
- // 请求狙击排行榜
- type DayRanklistReq struct {
- AnUserID int32 `json:"an_userid" form:"an_userid"` // 主播的游戏id
- }
- // 狙击者数据
- type SniperData struct {
- UserID int32 `json:"user_id" form:"user_id"` // 玩家id
- SnipeCount int32 `json:"snipe_count" form:"snipe_count"` // 狙击次数
- WinBeans int64 `json:"win_beans" form:"win_beans"` // 狙击金币
- }
- // 返回日榜家数据
- type DayRanklistRsp struct {
- AnUserID int32 `json:"an_userid" form:"an_userid"` // 主播的游戏id
- SnipedCount int32 `json:"sniped_count" form:"sniped_count"` // 被狙击次数
- DefendSuccess int32 `json:"defend_success" form:"defend_success"` // 防守成功次数
- DefendFail int32 `json:"defend_fail" form:"defend_fail"` // 防守失败次数
- SniperList []SniperData `json:"sniper_list" form:"sniper_list"` // 狙击者数据
- }
- // 请求每天对局记录
- type DayRecordsReq struct {
- AnUserID int32 `json:"an_userid" form:"an_userid"` // 主播的游戏id
- }
- // 对局记录
- type SnipeRecord struct {
- RoomType int32 `json:"room_type" form:"room_type"` // 游戏场次
- GameID int32 `json:"game_id" form:"game_id"` // 主播直播的游戏
- PlayMode string `json:"play_mode" form:"play_mode"` // 主播直播的游戏玩法
- Endtime int32 `json:"endtime" form:"endtime"` // 结束时间戳(秒)
- GameRes int32 `json:"game_res" form:"game_res"` // 玩家输赢结果 0-失败,1-胜利,2-平局
- LoseBeans int64 `json:"lose_beans" form:"lose_beans"` // 主播输掉的豆豆数,被褥豆豆数
- Identity int32 `json:"identity" form:"identity"` // 身份,客户端自己约定
- Snipers []UserGameData `json:"sniper" form:"sniper"` // 狙击者数据
- }
- // 返回每天对局记录
- type DayRecordsRsp struct {
- Records []SnipeRecord `json:"records" form:"records"` // 对局记录
- }
- // 主播拉黑玩家
- type BlockUserReq struct {
- ChallengerID uint32 `json:"challenger_id" form:"challenger_id"` // 挑战者ID
- }
- // 拉黑列表mysql数据
- type BlockUserData struct {
- BlockId uint32 `json:"blockid" gorm:"column:blockid"` // 被拉黑玩家id
- AnchorId uint32 `json:"anchorid" gorm:"column:anchorid"` // 主播id
- }
- // 保存拉黑数据
- func (this *BlockUserData) Save() {
- xdb := xgorm.NewConn(broadcast.AnchorGorm)
- if err := xdb.Table(Blocklist).Create(this).Error; err != nil {
- logs.Errorf("save blockUserData:%+v, err=%v", *this, err)
- return
- }
- logs.Infof("user beblock,blickid:%d,anchorid:%v", this.BlockId, this.AnchorId)
- }
- // 是否被拉黑
- func IsBlock(userid uint32) bool {
- xdb := xgorm.NewConn(broadcast.AnchorGorm)
- count := int64(0)
- xdb.Table(Blocklist).Select("blockid").Where("blockid = ?", userid).Count(&count)
- if count > 0 {
- return true
- }
- return false
- }
- //****************************************服务器接口****************************************
- type ParamConfigReq struct {
- UserID int32 `json:"user_id" form:"user_id"` // 玩家ID
- }
- // 返回配置给游戏服务器
- type ParamsConfigRsp struct {
- UserID int32 `json:"user_id" form:"user_id"` // 玩家ID
- RemainCt int32 `json:"remain_ct" form:"remain_ct"` // 剩余次数
- MaxCount int32 `json:"max_count" form:"max_count"` // 狙击最大次数
- FailBeans int32 `json:"fail_beans" form:"fail_beans"` // 狙击失败奖励的豆豆数
- }
- // 上报游戏结果数据
- type ReportGameResultReq struct {
- RoomType int32 `json:"room_type" form:"room_type"` // 游戏场次
- Snipers []int32 `json:"snipers" form:"snipers"` // 参与者ID
- UsersData []UserGameData `json:"users_data" form:"users_data"` // 玩家列表
- }
- //****************************************服务器接口****************************************
|