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.
74 lines
1.7 KiB
74 lines
1.7 KiB
2 years ago
|
package model
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"git.gz.internal.jumaiyx.cn/job/room-mike-hot-timer/internal/util"
|
||
|
"github.com/pkg/errors"
|
||
|
"gorm.io/gorm"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
ErrMikeHotLockOvertime = errors.New("lock overtime")
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
MikeStatusNil = iota
|
||
|
MikeStatusUp
|
||
|
MikeStatusOut
|
||
|
MikeStatusApply
|
||
|
MikeStatusInvitation
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
UpMikeTypeNil = iota
|
||
|
UpMikeTypeActive
|
||
|
UpMikeTypeUnActive
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
OutMikeTypeNil = iota
|
||
|
OutMikeTypeActive
|
||
|
OutMikeTypeUnActive
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
MikeUpHotListKey = "room:mike:hot:list"
|
||
|
MikeUpHotHashKey = "room:mike:hot:table:"
|
||
|
MikeHotLockKey = "room-mike-lock-%d-%d"
|
||
|
)
|
||
|
|
||
|
// RoomMike 房间上麦记录 废弃
|
||
|
type RoomMike struct {
|
||
|
gorm.Model
|
||
|
RoomId int64 `json:"room_id" gorm:"index:idx_room_uid;type:int8;comment:房间id"`
|
||
|
Uid int64 `json:"uid" gorm:"index:idx_room_uid;type:int8;comment:用户id"`
|
||
|
UpType int32 `json:"up_type" gorm:"type:int8;comment:上麦类型 1个人 2 邀请"`
|
||
|
OutType int32 `json:"out_type" gorm:"type:int8;comment:下麦类型 1个人 2 邀请"`
|
||
|
MikeNo string `json:"mike_no" gorm:"type:varchar;comment:麦号"`
|
||
|
Status int32 `json:"status" gorm:"default:1;type:int4;comment:1上麦, 2下麦,4、邀请,3、申请上麦"`
|
||
|
OpenStatus int32 `json:"open_status" gorm:"default:1;type:int4;comment:1开麦, 2闭麦"`
|
||
|
}
|
||
|
|
||
|
func (RoomMike) TableName() string {
|
||
|
return "room_mike"
|
||
|
}
|
||
|
|
||
|
func MikeHotLockRedisKey(roomId, uid int64) string {
|
||
|
return fmt.Sprintf(MikeHotLockKey, roomId, uid)
|
||
|
}
|
||
|
func MikeUpHotHashRedisKey(roomId int64) string {
|
||
|
return MikeUpHotHashKey + util.Int64TarnsString(roomId)
|
||
|
}
|
||
|
|
||
|
type MikeUpHot struct {
|
||
|
RoomId int64
|
||
|
StartTime int64
|
||
|
MikeId int64
|
||
|
MikeNo string
|
||
|
Uid int64
|
||
|
Total int64
|
||
|
Timer int64
|
||
|
Status int32
|
||
|
OpenStatus int32
|
||
|
}
|