resource.go 692 B

12345678910111213141516171819202122232425262728
  1. package resource
  2. import (
  3. "github.com/rdlucklib/rdluck_tools/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.NewOrm()
  14. o.Using("rddp")
  15. newId, err = o.Insert(item)
  16. return
  17. }
  18. func GetResourceById(id string) (item *Resource, err error) {
  19. o := orm.NewOrm()
  20. o.Using("rddp")
  21. sql := "SELECT * FROM resource WHERE id=? "
  22. err = o.Raw(sql, id).QueryRow(&item)
  23. return
  24. }