package whatsapp

import (
	"context"
	"wechat-api/hook/aliyun"

	"wechat-api/internal/svc"
	"wechat-api/internal/types"

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

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

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

func (l *RegisterPhoneNumberLogic) RegisterPhoneNumber(req *types.RegisterReq) (*types.BaseMsgResp, error) {
	resp := types.BaseMsgResp{Msg: "注册成功"}

	_, err := aliyun.RegisterCamsPhoneNumber(*req.Phone, *req.WaId)
	if err != nil {
		resp.Msg = err.Error()
		resp.Code = 1
	}

	return &resp, nil
}
