ppt2img.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package ppt2img
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "eta_gn/eta_api/utils"
  6. "fmt"
  7. "github.com/rdlucklib/rdluck_tools/http"
  8. )
  9. type Ppt2ImgResponse struct {
  10. Ret int
  11. Msg string
  12. ErrMsg string
  13. ErrCode string
  14. Data []string
  15. Success bool `description:"true 执行成功,false 执行失败"`
  16. IsSendEmail bool `description:"true 发送邮件,false 不发送邮件"`
  17. }
  18. func Ppt2Img(pptUrl string) (resourceUrlList []string, err error) {
  19. if utils.Ppt2ImageUrl == `` {
  20. return
  21. }
  22. params := make(map[string]interface{})
  23. params["PptUrl"] = pptUrl
  24. param, err := json.Marshal(params)
  25. if err != nil {
  26. utils.FileLog.Info("Ppt2Img json.Marshal Err:" + err.Error())
  27. return
  28. }
  29. body, err := http.Post(utils.Ppt2ImageUrl, string(param))
  30. var result Ppt2ImgResponse
  31. err = json.Unmarshal(body, &result)
  32. if err != nil {
  33. fmt.Println("err:" + err.Error())
  34. return
  35. }
  36. if result.Ret != 200 {
  37. err = errors.New("获取token失败,Err:" + result.Msg)
  38. return
  39. }
  40. resourceUrlList = result.Data
  41. return
  42. }