resource.go 1.7 KB

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