user_label_article.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxUserLabelArticle struct {
  7. Id int `orm:"column(id);pk"`
  8. UserId int `description:"用户ID"`
  9. CompanyId int `description:"公司id"`
  10. RealName string `description:"用户实际名称"`
  11. Mobile string `description:"手机号"`
  12. Email string `description:"邮箱"`
  13. Label string `description:"标签内容"`
  14. ArticleId int `description:"文章ID"`
  15. SourceId int `description:"来源ID(产业ID,系列ID)"`
  16. Source int `description:"来源1:产业、2:系列"`
  17. CreateTime time.Time `description:"创建时间"`
  18. ModifyTime time.Time `description:"更新时间"`
  19. }
  20. // 添加
  21. func AddCygxUserLabelArticle(item *CygxUserLabelArticle) (lastId int64, err error) {
  22. o := orm.NewOrm()
  23. lastId, err = o.Insert(item)
  24. return
  25. }
  26. // 批量添加
  27. func AddCygxUserLabelArticleList(items []*CygxUserLabelArticle) (lastId int64, err error) {
  28. lenitems := len(items)
  29. if lenitems == 0 {
  30. return
  31. }
  32. o := orm.NewOrm()
  33. _, err = o.InsertMulti(1, items)
  34. return
  35. }
  36. // 列表
  37. func GetCygxUserLabelArticleList(condition string, pars []interface{}) (items []*CygxUserLabelArticle, err error) {
  38. o := orm.NewOrm()
  39. sql := `SELECT * FROM cygx_user_label_article as art WHERE 1= 1 `
  40. if condition != "" {
  41. sql += condition
  42. }
  43. _, err = o.Raw(sql, pars).QueryRows(&items)
  44. return
  45. }