resource.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type Resource struct {
  7. Id int `orm:"column(id);" description:"资源id"`
  8. ResourceUrl string `description:"资源地址"`
  9. CreateTime time.Time `description:"创建时间"`
  10. ResourceType int `description:"资源类型,1:图片,2:音频,3:视频 ,4:ppt"`
  11. }
  12. type ResourceResp struct {
  13. Id int64 `orm:"column(id);" description:"用户id"`
  14. ResourceUrl string `description:"资源地址"`
  15. PlaySeconds uint32 `description:"播放时长,单位秒"`
  16. Source string
  17. CacheKey string
  18. ResourceName string `description:"资源名称"`
  19. }
  20. func AddResource(item *Resource) (newId int64, err error) {
  21. o := orm.NewOrmUsingDB("rddp")
  22. newId, err = o.Insert(item)
  23. return
  24. }
  25. func GetResourceById(id string) (item *Resource, err error) {
  26. o := orm.NewOrmUsingDB("rddp")
  27. sql := "SELECT * FROM resource WHERE id=? "
  28. err = o.Raw(sql, id).QueryRow(&item)
  29. return
  30. }
  31. type ResourceBase64Resp struct {
  32. Image string `description:"图片,base64字符串"`
  33. }
  34. type PptResourceResp struct {
  35. Id int64 `orm:"column(id);" description:"用户id"`
  36. ResourceUrl []string `description:"资源地址"`
  37. PlaySeconds uint32 `description:"播放时长,单位秒"`
  38. }
  39. type ImageSvgToPngResp struct {
  40. Data struct {
  41. ResourceURL string `json:"ResourceUrl"`
  42. } `json:"Data"`
  43. ErrCode string `json:"ErrCode"`
  44. ErrMsg string `json:"ErrMsg"`
  45. IsSendEmail bool `json:"IsSendEmail"`
  46. Msg string `json:"Msg"`
  47. Ret int64 `json:"Ret"`
  48. Success bool `json:"Success"`
  49. }