resource.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package models
  2. import (
  3. "eta_gn/eta_api/global"
  4. "time"
  5. )
  6. type Resource struct {
  7. Id int `gorm:"column:id;primaryKey;type:int" orm:"column(id);" description:"资源ID"`
  8. ResourceUrl string `gorm:"column:resource_url;type:varchar(255)" orm:"column(resource_url)" description:"资源地址"`
  9. CreateTime time.Time `gorm:"column:create_time;type:datetime" orm:"column(create_time)" description:"创建时间"`
  10. ResourceType int `gorm:"column:resource_type;type:int" orm:"column(resource_type)" 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. err = global.DmSQL["rddp"].Create(item).Error
  26. newId = int64(item.Id)
  27. return
  28. }
  29. func GetResourceById(id string) (item *Resource, err error) {
  30. //o := orm.NewOrmUsingDB("rddp")
  31. sql := "SELECT * FROM resource WHERE id=? "
  32. //err = o.Raw(sql, id).QueryRow(&item)
  33. err = global.DmSQL["rddp"].Raw(sql, id).First(&item).Error
  34. return
  35. }
  36. type ResourceBase64Resp struct {
  37. Image string `description:"图片,base64字符串"`
  38. }
  39. type PptResourceResp struct {
  40. Id int64 `orm:"column(id);" description:"用户id"`
  41. ResourceUrl []string `description:"资源地址"`
  42. PlaySeconds uint32 `description:"播放时长,单位秒"`
  43. }
  44. type ImageSvgToPngResp struct {
  45. Data struct {
  46. ResourceURL string `json:"ResourceUrl"`
  47. } `json:"Data"`
  48. ErrCode string `json:"ErrCode"`
  49. ErrMsg string `json:"ErrMsg"`
  50. IsSendEmail bool `json:"IsSendEmail"`
  51. Msg string `json:"Msg"`
  52. Ret int64 `json:"Ret"`
  53. Success bool `json:"Success"`
  54. }