package whatsapp

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

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

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

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

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

func (l *SetAutomationLogic) SetAutomation(req *types.SetAutomationReq) (*types.BaseMsgResp, error) {
	resp := types.BaseMsgResp{}
	_, err := aliyun.SetAutomation(req.WaId, req.Phone, req.Prompts)

	if err != nil {
		resp.Code = 1
		resp.Msg = err.Error()
	}
	resp.Msg = "设置成功"

	return &resp, nil
}
