fix
This commit is contained in:
parent
e5831ea5b7
commit
3fd6b6a881
@ -2,9 +2,11 @@ package game
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gitea.youtukeji.com.cn/xiabin/youtu_server/game_open_api/internal/logic/rankings"
|
||||
"gitea.youtukeji.com.cn/xiabin/youtu_server/game_open_api/internal/svc"
|
||||
"gitea.youtukeji.com.cn/xiabin/youtu_server/game_open_api/internal/types"
|
||||
"gorm.io/gorm"
|
||||
"strconv"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
@ -70,7 +72,7 @@ func (l *RankingListLogic) RankingList(req *types.RankingListRequest) (resp *typ
|
||||
|
||||
if !flag {
|
||||
tmp, err := l.svcCtx.Query.GameScore.GetUserRank(at.AppId, at.UserId, req.Type)
|
||||
if err != nil {
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, err
|
||||
}
|
||||
userRank = types.RankingData(tmp)
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"gitea.youtukeji.com.cn/xiabin/youtu_server/game_open_api/internal/logic/rankings"
|
||||
"gitea.youtukeji.com.cn/xiabin/youtu_server/game_open_api/internal/svc"
|
||||
"gitea.youtukeji.com.cn/xiabin/youtu_server/game_open_api/internal/types"
|
||||
"gitea.youtukeji.com.cn/xiabin/youtu_server/gorm-gen/dao/model"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"gorm.io/gorm"
|
||||
|
||||
@ -49,6 +50,10 @@ func (l *RankingSetScoreLogic) RankingSetScore(req *types.SetUserGameScoreReques
|
||||
return
|
||||
}
|
||||
|
||||
if oldScore == nil {
|
||||
oldScore = new(model.GameScore)
|
||||
}
|
||||
|
||||
// 判断是否需要更新(只保留最高分)
|
||||
if req.Score <= oldScore.Score {
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user