resource.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. OpenaiFileId string `description:"openai返回的文件id"`
  20. }
  21. func AddResource(item *Resource) (newId int64, err error) {
  22. o := orm.NewOrmUsingDB("rddp")
  23. newId, err = o.Insert(item)
  24. return
  25. }
  26. func GetResourceById(id string) (item *Resource, err error) {
  27. o := orm.NewOrmUsingDB("rddp")
  28. sql := "SELECT * FROM resource WHERE id=? "
  29. err = o.Raw(sql, id).QueryRow(&item)
  30. return
  31. }
  32. type ResourceBase64Resp struct {
  33. Image string `description:"图片,base64字符串"`
  34. }
  35. type PptResourceResp struct {
  36. Id int64 `orm:"column(id);" description:"用户id"`
  37. ResourceUrl []string `description:"资源地址"`
  38. PlaySeconds uint32 `description:"播放时长,单位秒"`
  39. }
  40. type ImageSvgToPngResp struct {
  41. Data struct {
  42. ResourceURL string `json:"ResourceUrl"`
  43. } `json:"Data"`
  44. ErrCode string `json:"ErrCode"`
  45. ErrMsg string `json:"ErrMsg"`
  46. IsSendEmail bool `json:"IsSendEmail"`
  47. Msg string `json:"Msg"`
  48. Ret int64 `json:"Ret"`
  49. Success bool `json:"Success"`
  50. }