package cygx

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

type CygxUserLabelActivity struct {
	Id                     int       `orm:"column(id);pk"`
	UserId                 int       `description:"用户ID"`
	CompanyId              int       `description:"公司id"`
	RealName               string    `description:"用户实际名称"`
	Mobile                 string    `description:"手机号"`
	Email                  string    `description:"邮箱"`
	Label                  string    `description:"标签内容"`
	IndustrialManagementId int       `description:"cygx_industrial_management表的主键ID"`
	ActivityId             int       `description:"活动ID"`
	CreateTime             time.Time `description:"创建时间"`
	ModifyTime             time.Time `description:"更新时间"`
}

// 列表
func GetCygxUserLabelActivity(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxUserLabelActivity, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := `SELECT * FROM cygx_user_label_activity as art WHERE 1= 1 `
	if condition != "" {
		sql += condition
	}
	sql += ` LIMIT ?,?  `
	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
	return
}

// 批量添加
func AddCygxUserLabelActivityList(items []*CygxUserLabelActivity) (lastId int64, err error) {
	lenitems := len(items)
	if lenitems == 0 {
		return
	}
	o := orm.NewOrmUsingDB("hz_cygx")
	_, err = o.InsertMulti(1, items)
	return
}