resource.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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:视频 "`
  11. }
  12. type ResourceResp struct {
  13. Id int64 `orm:"column(id);" description:"用户id"`
  14. ResourceUrl string `description:"资源地址"`
  15. PlaySeconds uint32 `description:"播放时长,单位秒"`
  16. }
  17. func AddResource(item *Resource) (newId int64, err error) {
  18. o := orm.NewOrmUsingDB("rddp")
  19. newId, err = o.Insert(item)
  20. return
  21. }
  22. func GetResourceById(id string) (item *Resource, err error) {
  23. o := orm.NewOrmUsingDB("rddp")
  24. sql := "SELECT * FROM resource WHERE id=? "
  25. err = o.Raw(sql, id).QueryRow(&item)
  26. return
  27. }
  28. type FileResourceResp struct {
  29. Id int64 `orm:"column(id);" description:"用户id"`
  30. ResourceUrl string `description:"资源地址"`
  31. ResourceName string `description:"资源名称"`
  32. PlaySeconds uint32 `description:"播放时长,单位秒"`
  33. }