50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package code
|
|
|
|
import (
|
|
"context"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"mingyang-admin-app-rpc/internal/logic/cacherepo"
|
|
"mingyang-admin-app-rpc/internal/svc"
|
|
"mingyang-admin-app-rpc/types/app"
|
|
)
|
|
|
|
type GetVerifyCodeLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
cacheRepo *cacherepo.CacheRepository
|
|
}
|
|
|
|
func NewGetVerifyCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVerifyCodeLogic {
|
|
return &GetVerifyCodeLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
cacheRepo: cacherepo.NewCacheRepository(ctx, svcCtx),
|
|
}
|
|
}
|
|
|
|
// GetVerifyCode 获取验证码
|
|
func (l *GetVerifyCodeLogic) GetVerifyCode(in *app.VerifyCodeReq) (*app.VerifyCodeResp, error) {
|
|
codeType := in.GetAccountType()
|
|
switch codeType {
|
|
case app.AccountType_MOBILE:
|
|
// TODO: 调用短信服务获取验证码
|
|
l.SendMobileMessage(in)
|
|
case app.AccountType_EMAIL:
|
|
// TODO: 调用邮件服务获取验证码
|
|
l.SendEmailMessage(in)
|
|
}
|
|
|
|
return &app.VerifyCodeResp{}, nil
|
|
}
|
|
|
|
func (l *GetVerifyCodeLogic) SendMobileMessage(in *app.VerifyCodeReq) {
|
|
//l.cacheRepo.SetVerificationCode(l.ctx, in.Value, nil, 10*time.Minute)
|
|
|
|
}
|
|
|
|
func (l *GetVerifyCodeLogic) SendEmailMessage(in *app.VerifyCodeReq) {
|
|
|
|
}
|