package models

import "github.com/beego/beego/v2/client/orm"

type UserTemplateRecord struct {
	Id         int `orm:"column(id);pk"`
	UserId     int
	OpenId     string
	Resource   string
	SendData   string
	Result     string
	CreateDate string
	CreateTime string
	SendStatus int
	SendType   int
}

//添加banner
func AddUserTemplateRecord(item *UserTemplateRecord) (err error) {
	o := orm.NewOrm()
	_, err = o.Insert(item)
	return
}

//GeUserTemplateRecordListBysendType 根据模板消息会议类型，获取已推送的用户的信息
func GeUserTemplateRecordListBysendType(sendType int, resource string) (items []*UserTemplateRecord, err error) {
	sql := `SELECT * FROM user_template_record WHERE send_type = ? AND resource = ? `
	o := orm.NewOrm()
	_, err = o.Raw(sql, sendType, resource).QueryRows(&items)
	return
}
