set_automation_logic.go 772 B

12345678910111213141516171819202122232425262728293031323334353637
  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.Phone, req.Prompts)
  23. if err != nil {
  24. resp.Code = 1
  25. resp.Msg = err.Error()
  26. }
  27. resp.Msg = "设置成功"
  28. return &resp, nil
  29. }