carv api logic

This commit is contained in:
lianghuanjie
2025-01-08 17:53:43 +08:00
parent 5c4862fd70
commit 5d2a0a8b5d
14 changed files with 252 additions and 62 deletions

View File

@@ -2,6 +2,9 @@ package carv
import (
"context"
"errors"
"nova_task/internal/model"
"nova_task/internal/pkg/errs"
"nova_task/internal/svc"
"nova_task/internal/types"
@@ -24,8 +27,25 @@ func NewUnlockChapterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Unl
}
}
func (l *UnlockChapterLogic) UnlockChapter(req *types.UnlockChapterReq) (resp *types.CarvResult, err error) {
// todo: add your logic here and delete this line
return
func (l *UnlockChapterLogic) UnlockChapter(req *types.UnlockChapterReq) *types.CarvResult {
uid, errResult := l.svcCtx.GetUidByEmail(l.ctx, req.Email)
if errResult != nil {
return errResult
}
gp, err := l.svcCtx.GameReportModel.FindOneByUid(l.ctx, uid)
if err != nil {
if !errors.Is(err, model.ErrNotFound) {
return &types.CarvResult{
Error: &types.Error{
Code: int(errs.ErrDatabaseOperate),
Message: "system error",
},
}
}
return &types.CarvResult{Result: &types.Result{IsValid: false}}
}
if gp.Chapter >= req.Chapter {
return &types.CarvResult{Result: &types.Result{IsValid: true}}
}
return &types.CarvResult{Result: &types.Result{IsValid: false}}
}