strategy.go 785 B

1234567891011121314151617181920212223242526272829303132333435
  1. package api
  2. import (
  3. "github.com/710leo/urlooker/dataobj"
  4. "github.com/710leo/urlooker/modules/web/model"
  5. )
  6. func (this *Web) GetStrategies(req interface{}, resp *dataobj.StrategyResponse) error {
  7. strategies, err := model.GetAllStrategyByCron()
  8. if err != nil {
  9. resp.Message = err.Error()
  10. }
  11. stras := []*dataobj.Strategy{}
  12. for _, s := range strategies {
  13. stras = append(stras, &dataobj.Strategy{
  14. Id: s.Id,
  15. Url: s.Url,
  16. Enable: s.Enable,
  17. IP: s.IP,
  18. Keywords: s.Keywords,
  19. Timeout: s.Timeout,
  20. Creator: s.Creator,
  21. ExpectCode: s.ExpectCode,
  22. Note: s.Note,
  23. Data: s.Data,
  24. Tag: s.Tag,
  25. MaxStep: s.MaxStep,
  26. Times: s.Times,
  27. Teams: s.Teams,
  28. })
  29. }
  30. resp.Data = stras
  31. return nil
  32. }