ppt2img.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package ppt2img
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. "github.com/rdlucklib/rdluck_tools/http"
  7. "hongze/hongze_ETA_mobile_api/utils"
  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. // Ppt2Img ppt转图片
  19. // @params pptUrl ppt的在线url
  20. func Ppt2Img(pptUrl string) (resourceUrlList []string, err error) {
  21. params := make(map[string]interface{})
  22. params["PptUrl"] = pptUrl
  23. param, err := json.Marshal(params)
  24. if err != nil {
  25. utils.FileLog.Info("Ppt2Img json.Marshal Err:" + err.Error())
  26. return
  27. }
  28. body, err := http.Post(utils.Ppt2ImageUrl, string(param))
  29. var result Ppt2ImgResponse
  30. err = json.Unmarshal(body, &result)
  31. if err != nil {
  32. fmt.Println("err:" + err.Error())
  33. return
  34. }
  35. if result.Ret != 200 {
  36. err = errors.New("获取token失败,Err:" + result.Msg)
  37. return
  38. }
  39. resourceUrlList = result.Data
  40. return
  41. }