mic.go 734 Bytes
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
package mic_c

import (
	"git.hilo.cn/hilo-common/domain"
	"git.hilo.cn/hilo-common/resource/config"
	"git.hilo.cn/hilo-common/resource/mysql"
	"hilo-group/_const/redis_key/mic_k"
	"time"
)

// 增加上麦邀请次数,一天只需要第一次进房弹出
// return show:true 今天已经展示过了
func IsMicDayInviteDialogShowToday(model *domain.Model, userId mysql.ID) (show bool, err error) {
	key := mic_k.GetUserMicDayInvite(userId)
	ttl := time.Hour * 24
	if !config.AppIsRelease() {
		ttl = time.Hour
	}
	lock, err := model.Redis.SetNX(model, key, 1, ttl).Result()
	if err != nil {
		model.Log.Errorf("IsMicDayInviteDialogShowToday uid:%v, fail:%v", userId, err)
		return false, err
	}
	// !lock = show
	return !lock, err
}