article_data.go 716 B

12345678910111213141516171819202122232425262728
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxArticleData struct {
  7. Id int `orm:"column(id);pk"`
  8. ArticleId int `description:"文章id"`
  9. CreateTime time.Time `description:"创建时间"`
  10. Cover string `description:"封面图片,公司logo"`
  11. }
  12. //新增文章
  13. func AddCygxArticleData(item *CygxArticleData) (lastId int64, err error) {
  14. o := orm.NewOrm()
  15. lastId, err = o.Insert(item)
  16. return
  17. }
  18. //获取数量
  19. func GetCygxArticleDataCount(articcleId int) (count int, err error) {
  20. o := orm.NewOrm()
  21. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_article_data WHERE article_id=? `
  22. err = o.Raw(sqlCount, articcleId).QueryRow(&count)
  23. return
  24. }