fix: game7 user not exist role bug

This commit is contained in:
lianghuanjie
2025-01-17 21:08:18 +08:00
parent b9c369c4d8
commit 7cc62b8b4f
2 changed files with 15 additions and 8 deletions

View File

@@ -59,6 +59,7 @@ func (l *UnlockChapterLogic) UnlockChapter(req *types.UnlockChapterReq) *types.C
gp, err := l.svcCtx.GameReportModel.FindMaxByEmail(l.ctx, req.Email) gp, err := l.svcCtx.GameReportModel.FindMaxByEmail(l.ctx, req.Email)
if err != nil { if err != nil {
if !errors.Is(err, model.ErrNotFound) {
l.Errorw("find game report error", logx.Field("err", err), logx.Field("email", req.Email)) l.Errorw("find game report error", logx.Field("err", err), logx.Field("email", req.Email))
return &types.CarvResult{ return &types.CarvResult{
Error: &types.Error{ Error: &types.Error{
@@ -67,6 +68,8 @@ func (l *UnlockChapterLogic) UnlockChapter(req *types.UnlockChapterReq) *types.C
}, },
} }
} }
return &types.CarvResult{Result: &types.Result{IsValid: false}}
}
if gp.Chapter >= req.Chapter { if gp.Chapter >= req.Chapter {
return &types.CarvResult{Result: &types.Result{IsValid: true}} return &types.CarvResult{Result: &types.Result{IsValid: true}}

View File

@@ -48,10 +48,14 @@ GROUP BY
` `
var resp GameReport var resp GameReport
err := m.conn.QueryRowCtx(ctx, &resp, query, email) err := m.conn.QueryRowCtx(ctx, &resp, query, email)
if err != nil && !errors.Is(err, sqlx.ErrNotFound) { switch {
case err == nil:
return &resp, nil
case errors.Is(err, sqlx.ErrNotFound):
return nil, ErrNotFound
default:
return nil, err return nil, err
} }
return &resp, nil
} }
// NewNhGameReportModel returns a model for the database table. // NewNhGameReportModel returns a model for the database table.