package models

import (
	"github.com/beego/beego/v2/client/orm"
	"time"
)

type CygxArticleData struct {
	Id         int       `orm:"column(id);pk"`
	ArticleId  int       `description:"文章id"`
	CreateTime time.Time `description:"创建时间"`
	Cover      string    `description:"封面图片，公司logo"`
}

//新增文章
func AddCygxArticleData(item *CygxArticleData) (lastId int64, err error) {
	o := orm.NewOrm()
	lastId, err = o.Insert(item)
	return
}

//获取数量
func GetCygxArticleDataCount(articcleId int) (count int, err error) {
	o := orm.NewOrm()
	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_data WHERE article_id=? `
	err = o.Raw(sqlCount, articcleId).QueryRow(&count)
	return
}
