resource.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package models
  2. import (
  3. "eta/eta_api/global"
  4. "eta/eta_api/utils"
  5. "time"
  6. )
  7. type Resource struct {
  8. Id int `gorm:"column:id;primaryKey;autoIncrement" description:"资源id"`
  9. ResourceUrl string `description:"资源地址"`
  10. CreateTime time.Time `description:"创建时间"`
  11. ResourceType int `description:"资源类型,1:图片,2:音频,3:视频 ,4:ppt"`
  12. }
  13. type ResourceResp struct {
  14. Id int64 `gorm:"column:id;primaryKey;autoIncrement" description:"用户id"`
  15. ResourceUrl string `description:"资源地址"`
  16. PlaySeconds uint32 `description:"播放时长,单位秒"`
  17. Source string
  18. CacheKey string
  19. ResourceName string `description:"资源名称"`
  20. OpenaiFileId string `description:"openai返回的文件id"`
  21. AiChatTopicId int `description:"主题id"`
  22. }
  23. func AddResource(item *Resource) (newId int64, err error) {
  24. o := global.DbMap[utils.DbNameReport]
  25. err = o.Create(item).Error
  26. if err != nil {
  27. return
  28. }
  29. newId = int64(item.Id)
  30. return
  31. }
  32. //func GetResourceById(id string) (item *Resource, err error) {
  33. // o := global.DbMap[utils.DbNameReport]
  34. // sql := "SELECT * FROM resource WHERE id=? "
  35. // err = o.Raw(sql, id).First(&item).Error
  36. // return
  37. //}
  38. type ResourceBase64Resp struct {
  39. Image string `description:"图片,base64字符串"`
  40. }
  41. type PptResourceResp struct {
  42. Id int64 `orm:"column(id);" description:"用户id"`
  43. ResourceUrl []string `description:"资源地址"`
  44. PlaySeconds uint32 `description:"播放时长,单位秒"`
  45. }
  46. type ImageSvgToPngResp struct {
  47. Data struct {
  48. ResourceURL string `json:"ResourceUrl"`
  49. } `json:"Data"`
  50. ErrCode string `json:"ErrCode"`
  51. ErrMsg string `json:"ErrMsg"`
  52. IsSendEmail bool `json:"IsSendEmail"`
  53. Msg string `json:"Msg"`
  54. Ret int64 `json:"Ret"`
  55. Success bool `json:"Success"`
  56. }
  57. type UploadImgResp struct {
  58. ResourceUrl string `description:"资源地址"`
  59. }