resource.go 2.0 KB

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