package models

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

type CygxArticleCeluePush struct {
	Id         int    `description:"新ID"`
	ArticleId  int    `description:"文章ID"`
	IsHandle   int    `description:"文章ID"`
	Action     string `description:"日志类型：add，edit，move"`
	ModifyTime string `description:"修改时间"`
	CreateTime string `description:"创建时间"`
}

func GetArticleCeluePushList() (item []*CygxArticleCeluePush, err error) {
	o := orm.NewOrm()
	sql := ` SELECT *  FROM	cygx_article_celue_push WHERE	is_handle = 0  AND create_time >DATE_SUB(NOW(), INTERVAL 10 MINUTE)  GROUP BY article_id   `
	_, err = o.Raw(sql).QueryRows(&item)
	return
}

// 更改推送内容是否处理状态
func UpdateCygxArticleCeluePush(articleId int) (err error) {
	o := orm.NewOrm()
	sql := `UPDATE cygx_article_celue_push SET is_handle=1 WHERE article_id=? `
	_, err = o.Raw(sql, articleId).Exec()
	return
}

type CygxArticleCeluePushRedis struct {
	ArticleId  int       `description:"文章ID"`
	Action     string    `description:"日志类型：add，edit，move"`
	CreateTime time.Time `description:"创建时间"`
}
