package whatsapp

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

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

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

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

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

func (l *RemoveQrcodeLogic) RemoveQrcode(req *types.RemoveQrcodeReq) (*types.BaseMsgResp, error) {
	resp := types.BaseMsgResp{Msg: "删除成功"}

	_, err := aliyun.RemoveCamsQrcode(req.Phone, req.WaId, req.QrdlCode)
	l.Logger.Infof("remove qrcode err:%v\n", err)

	if err != nil {
		resp.Msg = err.Error()
		resp.Code = 1
	}

	return &resp, nil
}
