resource.go 769 B

123456789101112131415161718192021222324252627282930
  1. package models
  2. import (
  3. "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. type ResourceResp struct {
  13. Id int64 `orm:"column(id);" description:"用户id"`
  14. ResourceUrl string `description:"资源地址"`
  15. }
  16. func AddResource(item *Resource) (newId int64, err error) {
  17. o := orm.NewOrm()
  18. newId, err = o.Insert(item)
  19. return
  20. }
  21. func GetResourceById(id string) (item *Resource, err error) {
  22. sql := "SELECT * FROM resource WHERE id=? "
  23. err = orm.NewOrm().Raw(sql, id).QueryRow(&item)
  24. return
  25. }