carv api logic
This commit is contained in:
@@ -27,10 +27,10 @@ func NewBindWalletLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BindWa
|
||||
}
|
||||
}
|
||||
|
||||
func (l *BindWalletLogic) BindWallet(req *types.EmailKey) (*types.CarvResult, error) {
|
||||
uid, errResult := l.svcCtx.FindUserByEmail(l.ctx, req.Email)
|
||||
func (l *BindWalletLogic) BindWallet(req *types.EmailKey) *types.CarvResult {
|
||||
uid, errResult := l.svcCtx.GetUidByEmail(l.ctx, req.Email)
|
||||
if errResult != nil {
|
||||
return errResult, nil
|
||||
return errResult
|
||||
}
|
||||
|
||||
_, err := l.svcCtx.WalletModel.FindAddressByUid(l.ctx, uid)
|
||||
@@ -41,13 +41,13 @@ func (l *BindWalletLogic) BindWallet(req *types.EmailKey) (*types.CarvResult, er
|
||||
Code: int(errs.ErrDatabaseOperate),
|
||||
Message: "system error",
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
return &types.CarvResult{
|
||||
Result: &types.Result{IsValid: false},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
return &types.CarvResult{
|
||||
Result: &types.Result{IsValid: true},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ func NewDownloadAndBindRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DownloadAndBindRoleLogic) DownloadAndBindRole(req *types.EmailKey) (*types.CarvResult, error) {
|
||||
uid, errResult := l.svcCtx.FindUserByEmail(l.ctx, req.Email)
|
||||
func (l *DownloadAndBindRoleLogic) DownloadAndBindRole(req *types.EmailKey) *types.CarvResult {
|
||||
uid, errResult := l.svcCtx.GetUidByEmail(l.ctx, req.Email)
|
||||
if errResult != nil {
|
||||
return errResult, nil
|
||||
return errResult
|
||||
}
|
||||
|
||||
pb, err := l.svcCtx.PromoteBindModel.FindOneByInvitedUid(l.ctx, uid)
|
||||
@@ -38,20 +38,20 @@ func (l *DownloadAndBindRoleLogic) DownloadAndBindRole(req *types.EmailKey) (*ty
|
||||
return &types.CarvResult{Error: &types.Error{
|
||||
Code: int(errs.ErrDatabaseOperate),
|
||||
Message: "system error",
|
||||
}}, nil
|
||||
}}
|
||||
}
|
||||
return &types.CarvResult{Result: &types.Result{
|
||||
IsValid: false,
|
||||
}}, nil
|
||||
}}
|
||||
}
|
||||
|
||||
if pb.IsCreateRole == 0 {
|
||||
return &types.CarvResult{Result: &types.Result{
|
||||
IsValid: false,
|
||||
}}, nil
|
||||
}}
|
||||
}
|
||||
|
||||
return &types.CarvResult{
|
||||
Result: &types.Result{IsValid: true},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ func NewWalletCheckInLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Wal
|
||||
}
|
||||
}
|
||||
|
||||
func (l *WalletCheckInLogic) WalletCheckIn(req *types.EmailKey) (*types.CarvResult, error) {
|
||||
uid, errResult := l.svcCtx.FindUserByEmail(l.ctx, req.Email)
|
||||
func (l *WalletCheckInLogic) WalletCheckIn(req *types.EmailKey) *types.CarvResult {
|
||||
uid, errResult := l.svcCtx.GetUidByEmail(l.ctx, req.Email)
|
||||
if errResult != nil {
|
||||
return errResult, nil
|
||||
return errResult
|
||||
}
|
||||
|
||||
task, err := l.svcCtx.TaskModel.FindDailyPayTask(l.ctx)
|
||||
@@ -43,14 +43,14 @@ func (l *WalletCheckInLogic) WalletCheckIn(req *types.EmailKey) (*types.CarvResu
|
||||
Code: int(errs.ErrDatabaseOperate),
|
||||
Message: "system error",
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
return &types.CarvResult{
|
||||
Error: &types.Error{
|
||||
Code: int(errs.ErrTaskNotFound),
|
||||
Message: "task not exist",
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
taskSeq := cast.ToInt(time.Now().Format("20060102"))
|
||||
tp, err := l.svcCtx.TaskProgressModel.FindOneByUidTaskIdTaskSeq(l.ctx, int(uid), task.Id, taskSeq)
|
||||
@@ -61,19 +61,19 @@ func (l *WalletCheckInLogic) WalletCheckIn(req *types.EmailKey) (*types.CarvResu
|
||||
Code: int(errs.ErrDatabaseOperate),
|
||||
Message: "system error",
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
return &types.CarvResult{
|
||||
Result: &types.Result{IsValid: false},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
if tp.Stage >= model.TASK_PROGRESS_WAIT_REWARD {
|
||||
return &types.CarvResult{
|
||||
Result: &types.Result{IsValid: true},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
return &types.CarvResult{
|
||||
Result: &types.Result{IsValid: false},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user