set_automation_logic.go 751 B

123456789101112131415161718192021222324252627282930313233343536
  1. package whatsapp
  2. import (
  3. "context"
  4. "wechat-api/hook/aliyun"
  5. "wechat-api/internal/svc"
  6. "wechat-api/internal/types"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type SetAutomationLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewSetAutomationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetAutomationLogic {
  15. return &SetAutomationLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx}
  19. }
  20. func (l *SetAutomationLogic) SetAutomation(req *types.SetAutomationReq) (*types.BaseMsgResp, error) {
  21. resp := types.BaseMsgResp{}
  22. _, err := aliyun.SetAutomation(req.WaId, req.PhoneNumber, req.Prompts)
  23. if err != nil {
  24. resp.Code = 1
  25. resp.Msg = err.Error()
  26. }
  27. return &resp, nil
  28. }