2024-08-25 07:08:49 +00:00
|
|
|
package member
|
|
|
|
|
|
|
|
import (
|
2024-08-26 08:34:31 +00:00
|
|
|
"app-cloudep-portal-api-gateway/internal/domain"
|
2024-08-25 07:08:49 +00:00
|
|
|
"app-cloudep-portal-api-gateway/internal/svc"
|
|
|
|
"app-cloudep-portal-api-gateway/internal/types"
|
2024-08-26 08:34:31 +00:00
|
|
|
"context"
|
|
|
|
"fmt"
|
2024-08-25 07:08:49 +00:00
|
|
|
|
2024-08-27 07:40:00 +00:00
|
|
|
ers "code.30cm.net/digimon/library-go/errors"
|
|
|
|
accountRpc "code.30cm.net/digimon/proto-all/pkg/member"
|
|
|
|
|
2024-08-25 07:08:49 +00:00
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
)
|
|
|
|
|
|
|
|
type CheckVerifyCodeLogic struct {
|
|
|
|
logx.Logger
|
|
|
|
ctx context.Context
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewCheckVerifyCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckVerifyCodeLogic {
|
|
|
|
return &CheckVerifyCodeLogic{
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
ctx: ctx,
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *CheckVerifyCodeLogic) CheckVerifyCode(req *types.CheckoutVerifyReq) (resp *types.BaseResponse, err error) {
|
2024-08-26 08:34:31 +00:00
|
|
|
// 驗證碼
|
|
|
|
_, err = l.svcCtx.AccountRpc.CheckRefreshCode(l.ctx, &accountRpc.VerifyRefreshCodeReq{
|
|
|
|
Account: req.Account,
|
|
|
|
CodeType: domain.SendVerifyCodeTypeForgetPassword,
|
|
|
|
VerifyCode: req.VerifyCode,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
// 表使沒有這驗證碼
|
|
|
|
return nil, ers.Forbidden("failed to get verify code")
|
|
|
|
}
|
2024-08-25 07:08:49 +00:00
|
|
|
|
2024-08-26 08:34:31 +00:00
|
|
|
// 返回成功響應
|
|
|
|
return &types.BaseResponse{
|
|
|
|
Status: types.Status{
|
|
|
|
Code: domain.SuccessCode,
|
|
|
|
Message: domain.SuccessMsg,
|
|
|
|
},
|
|
|
|
}, nil
|
2024-08-25 07:08:49 +00:00
|
|
|
}
|