42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package user_public
|
|
|
|
import (
|
|
"context"
|
|
"github.com/pkg/errors"
|
|
"mingyang-admin-app-api/internal/svc"
|
|
"mingyang-admin-app-api/internal/types"
|
|
"mingyang-admin-app-rpc/types/app"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetVerifyCodeLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewGetVerifyCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVerifyCodeLogic {
|
|
return &GetVerifyCodeLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetVerifyCodeLogic) GetVerifyCode(req *types.VerifyCodeReq) (resp *types.VerifyCodeResp, err error) {
|
|
verifyCode, err := l.svcCtx.AppRpc.GetVerifyCode(l.ctx, &app.VerifyCodeReq{
|
|
AccountType: app.AccountType(req.AccountType),
|
|
Value: req.Value,
|
|
Type: app.VerifyCodeType(req.VerifyCodeType),
|
|
})
|
|
if err != nil {
|
|
logx.Errorw("failed to get verify code", logx.Field("detail", err))
|
|
return nil, errors.New("failed to get verify code")
|
|
}
|
|
return &types.VerifyCodeResp{
|
|
ExpireTime: verifyCode.Expire,
|
|
CaptchaCode: verifyCode.CaptchaCode,
|
|
}, nil
|
|
}
|