common_sms_code_logic.go 1.0 KB
package common

import (
	"context"
	"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/smslib"
	"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"

	"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
	"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CommonSmsCodeLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCommonSmsCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommonSmsCodeLogic {
	return &CommonSmsCodeLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CommonSmsCodeLogic) CommonSmsCode(req *types.CommonSmsCodeRequest) (resp *types.CommonSmsCodeResposne, err error) {
	_, err = l.svcCtx.SmsService.SendSmsCode(l.ctx, smslib.RequestSendSmsCode{
		Phone: req.Phone,
	})
	if err != nil {
		return nil, xerr.NewErrMsgErr(err.Error(), err)
	}
	resp = &types.CommonSmsCodeResposne{}
	return
}