Commit 99ef0fec authored by hujiebin's avatar hujiebin

fix:day->date

parent b2582ee0
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
// 用户上麦 // 用户上麦
type UserOnMic struct { type UserOnMic struct {
Day string Date string
UserId mysql.ID UserId mysql.ID
Seconds mysql.Num Seconds mysql.Num
LastCalTs int64 LastCalTs int64
...@@ -24,7 +24,7 @@ type UserOnMic struct { ...@@ -24,7 +24,7 @@ type UserOnMic struct {
func GetUserOnMic(model *domain.Model, userId mysql.ID) (*UserOnMic, error) { func GetUserOnMic(model *domain.Model, userId mysql.ID) (*UserOnMic, error) {
res := new(UserOnMic) res := new(UserOnMic)
day := time.Now().Format("2006-01-02") day := time.Now().Format("2006-01-02")
if err := model.DB().Where("day = ? AND user_id = ?", day, userId).First(res).Error; err != nil { if err := model.DB().Where("date = ? AND user_id = ?", day, userId).First(res).Error; err != nil {
return nil, err return nil, err
} }
return res, nil return res, nil
...@@ -51,7 +51,7 @@ func IncrUserOnMic(model *domain.Model, userId mysql.ID, joinMicTimestamp int64) ...@@ -51,7 +51,7 @@ func IncrUserOnMic(model *domain.Model, userId mysql.ID, joinMicTimestamp int64)
score := nowTs - curTs score := nowTs - curTs
day := time.Now().Format("2006-01-02") day := time.Now().Format("2006-01-02")
onMicNew := &UserOnMic{ onMicNew := &UserOnMic{
Day: day, Date: day,
UserId: userId, UserId: userId,
Seconds: mysql.Num(score), Seconds: mysql.Num(score),
} }
...@@ -74,7 +74,7 @@ func IncrUserOnMic(model *domain.Model, userId mysql.ID, joinMicTimestamp int64) ...@@ -74,7 +74,7 @@ func IncrUserOnMic(model *domain.Model, userId mysql.ID, joinMicTimestamp int64)
func MGetUserOnMicSeconds(model *domain.Model, day string, userIds []uint64) (map[mysql.ID]mysql.Num, error) { func MGetUserOnMicSeconds(model *domain.Model, day string, userIds []uint64) (map[mysql.ID]mysql.Num, error) {
var rows []UserOnMic var rows []UserOnMic
res := make(map[mysql.ID]mysql.Num) res := make(map[mysql.ID]mysql.Num)
if err := model.DB().Model(UserOnMic{}).Where("`day`= ? AND user_id in ?", day, userIds).Find(&rows).Error; err != nil { if err := model.DB().Model(UserOnMic{}).Where("`date`= ? AND user_id in ?", day, userIds).Find(&rows).Error; err != nil {
model.Log.Errorf("MGetUserOnMic fail:%v", err) model.Log.Errorf("MGetUserOnMic fail:%v", err)
return res, err return res, err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment