fix
This commit is contained in:
parent
5e7770e955
commit
02e95503cf
34
dev/generate_token.go
Normal file
34
dev/generate_token.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/golang-jwt/jwt/v4"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
claims := make(jwt.MapClaims)
|
||||||
|
claims["exp"] = time.Now().Add(time.Hour * 24).Unix()
|
||||||
|
claims["iat"] = 86400
|
||||||
|
type AccessToken struct {
|
||||||
|
AppId uint64 `json:"appId"`
|
||||||
|
UserId uint64 `json:"userId"`
|
||||||
|
AppIdStr string `json:"appIdStr"`
|
||||||
|
OpenId string `json:"openId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
claims["payload"] = &AccessToken{
|
||||||
|
AppId: 2,
|
||||||
|
UserId: 59,
|
||||||
|
AppIdStr: "1",
|
||||||
|
OpenId: "1",
|
||||||
|
}
|
||||||
|
token := jwt.New(jwt.SigningMethodHS256)
|
||||||
|
token.Claims = claims
|
||||||
|
tokenStr, err := token.SignedString([]byte("youtu123!"))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
fmt.Println(tokenStr)
|
||||||
|
}
|
@ -70,6 +70,8 @@ func (l *DouyinCode2tokenLogic) DouyinCode2token(req *types.DouyinCode2TokenRequ
|
|||||||
AppIdStr: req.AppId,
|
AppIdStr: req.AppId,
|
||||||
OpenId: res.Openid,
|
OpenId: res.Openid,
|
||||||
}
|
}
|
||||||
|
l.Logger.Debugf("payload: %+v", claims["payload"])
|
||||||
|
|
||||||
token := jwt.New(jwt.SigningMethodHS256)
|
token := jwt.New(jwt.SigningMethodHS256)
|
||||||
token.Claims = claims
|
token.Claims = claims
|
||||||
resp.Token, err = token.SignedString([]byte(l.svcCtx.Config.Auth.AccessSecret))
|
resp.Token, err = token.SignedString([]byte(l.svcCtx.Config.Auth.AccessSecret))
|
||||||
|
@ -29,6 +29,9 @@ func (l *RankingListLogic) RankingList(req *types.RankingListRequest) (resp *typ
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
l.Logger.Debugf("at: %+v", at)
|
||||||
|
l.Logger.Debugf("req: %+v", req)
|
||||||
|
|
||||||
resp.RankingData, err = l.svcCtx.GameScore.GetRankList(l.ctx, at.AppId, req.Type, req.PageBase)
|
resp.RankingData, err = l.svcCtx.GameScore.GetRankList(l.ctx, at.AppId, req.Type, req.PageBase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -38,7 +41,8 @@ func (l *RankingListLogic) RankingList(req *types.RankingListRequest) (resp *typ
|
|||||||
for i := range resp.RankingData {
|
for i := range resp.RankingData {
|
||||||
if resp.RankingData[i].UserId == at.UserId {
|
if resp.RankingData[i].UserId == at.UserId {
|
||||||
resp.RankingData[i].Self = true
|
resp.RankingData[i].Self = true
|
||||||
resp.RankingData = append(resp.RankingData, resp.RankingData[i])
|
d := resp.RankingData[i]
|
||||||
|
resp.RankingData = append(resp.RankingData, d)
|
||||||
flag = true
|
flag = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -46,12 +46,15 @@ func (l *RankingSetScoreLogic) RankingSetScore(req *types.SetUserGameScoreReques
|
|||||||
oldScore.Score = req.Score
|
oldScore.Score = req.Score
|
||||||
err = l.svcCtx.GameScore.UpdateScore(l.ctx, oldScore)
|
err = l.svcCtx.GameScore.UpdateScore(l.ctx, oldScore)
|
||||||
} else {
|
} else {
|
||||||
err = l.svcCtx.GameScore.CreateScore(l.ctx, &model.GameScore{
|
oldScore = &model.GameScore{
|
||||||
AppUserId: at.UserId,
|
AppUserId: at.UserId,
|
||||||
AppAccount: at.AppId,
|
AppAccount: at.AppId,
|
||||||
Score: req.Score,
|
Score: req.Score,
|
||||||
})
|
}
|
||||||
|
err = l.svcCtx.GameScore.CreateScore(l.ctx, oldScore)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
l.Logger.Debugf("GameScore: %+v", oldScore)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -118,11 +118,8 @@ FROM
|
|||||||
WHERE
|
WHERE
|
||||||
game_score.t = ?) AS gs
|
game_score.t = ?) AS gs
|
||||||
LEFT JOIN app_user ON app_user.id = gs.app_user_id
|
LEFT JOIN app_user ON app_user.id = gs.app_user_id
|
||||||
AND gs.app_account = ?
|
AND gs.app_account = ? AND game_score.app_user_id = ? LIMIT 1`
|
||||||
WHERE
|
return conn.QueryRowsPartialCtx(ctx, v, query, t, userId, appId)
|
||||||
gs.app_user_id = ?
|
|
||||||
LIMIT 1`
|
|
||||||
return conn.QueryRowsPartialCtx(ctx, v, query, t, appId, userId)
|
|
||||||
})
|
})
|
||||||
switch {
|
switch {
|
||||||
case err == nil:
|
case err == nil:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user