resource.go 683 B

1234567891011121314151617181920212223242526
  1. package resource
  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. func AddResource(item *Resource) (newId int64, err error) {
  13. o := orm.NewOrmUsingDB("rddp")
  14. newId, err = o.Insert(item)
  15. return
  16. }
  17. func GetResourceById(id string) (item *Resource, err error) {
  18. o := orm.NewOrmUsingDB("rddp")
  19. sql := "SELECT * FROM resource WHERE id=? "
  20. err = o.Raw(sql, id).QueryRow(&item)
  21. return
  22. }