55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
package querier
|
|
|
|
import (
|
|
"gorm.io/gen"
|
|
)
|
|
|
|
type AppAccountQuerier interface {
|
|
//GetAppConfig 获取所有小游戏配置
|
|
//
|
|
//select `app_id`,`secret`,`ecpm_value`,`ecpm_view`,`type` from `app_account` left join douyin_ecpm_config on app_account.id = douyin_ecpm_config.app_account_id
|
|
GetAppConfig() ([]*gen.T, error)
|
|
}
|
|
|
|
type GameScoreQuerier interface {
|
|
/*
|
|
|
|
SELECT
|
|
app_user.nickname,
|
|
app_user.avatar,
|
|
gs.score,
|
|
gs.app_user_id,
|
|
gs.t_rank
|
|
FROM
|
|
(
|
|
SELECT
|
|
game_score.score,
|
|
game_score.app_user_id,
|
|
game_score.app_account,
|
|
rank() OVER (ORDER BY game_score.score DESC) t_rank
|
|
FROM
|
|
game_score
|
|
WHERE
|
|
game_score.t = ?
|
|
AND game_score.app_account = ?
|
|
) AS gs
|
|
LEFT JOIN app_user ON app_user.id = gs.app_user_id
|
|
WHERE
|
|
gs.app_user_id = ?
|
|
LIMIT 1;
|
|
*/
|
|
GetUserRank(appId uint32, userId uint64, t uint32) (resp RankingData, err error)
|
|
|
|
//select DISTINCT app_account,t from game_score
|
|
FindDistinctRanking() (resp []*gen.T, err error)
|
|
}
|
|
|
|
type RankingData struct {
|
|
Nickname string `json:"nickname" db:"nickname"` // 昵称
|
|
Avatar string `json:"avatar" db:"avatar"` // 头像
|
|
Score uint32 `json:"score" db:"score"` // 得分
|
|
UserId uint64 `json:"userId" db:"app_user_id"` // 用户 ID
|
|
Rank uint32 `json:"rank" db:"t_rank"` // 排名
|
|
Self bool `json:"self" db:"-"` // 是否是自己
|
|
}
|