软质押任务修改
This commit is contained in:
@@ -11,6 +11,8 @@ import (
|
||||
"nova_task/internal/config"
|
||||
"nova_task/internal/middleware"
|
||||
"nova_task/internal/model"
|
||||
"nova_task/internal/pkg/errs"
|
||||
"nova_task/internal/types"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
@@ -118,3 +120,24 @@ func (s *ServiceContext) HasBindTwitter(ctx context.Context, uid uint) bool {
|
||||
}
|
||||
return tw.TwitterId != ""
|
||||
}
|
||||
|
||||
func (s *ServiceContext) FindUserByEmail(ctx context.Context, email string) (uint, *types.CarvResult) {
|
||||
u, err := s.UserModel.FindOneByEmail(ctx, email)
|
||||
if err != nil {
|
||||
if !errors.Is(err, model.ErrNotFound) {
|
||||
return 0, &types.CarvResult{
|
||||
Error: &types.Error{
|
||||
Code: int(errs.ErrDatabaseOperate),
|
||||
Message: "system error",
|
||||
},
|
||||
}
|
||||
}
|
||||
return 0, &types.CarvResult{
|
||||
Error: &types.Error{
|
||||
Code: int(errs.ErrUserNotFound),
|
||||
Message: "email not exist",
|
||||
},
|
||||
}
|
||||
}
|
||||
return u.Id, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user