ppt2img.go 1.1 KB

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