package cygx

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

type CygxActivitySignupBreak struct {
	Id          int       `orm:"column(id);pk"`
	ActivityId  int       `description:"活动ID"`
	UserId      int       `description:"用户ID"`
	CreateTime  time.Time `description:"创建时间"`
	Mobile      string    `description:"手机号"`
	Email       string    `description:"邮箱"`
	CompanyId   int       `description:"公司id"`
	CompanyName string    `description:"公司名称"`
	RealName    string    `description:"用户实际名称"`
	SellerName  string    `description:"所属销售"`
}

// 添加爽约记录
func AddCygxActivitySignupBreak(item *CygxActivitySignupBreak) (lastId int64, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	lastId, err = o.Insert(item)
	return
}

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

// 删除
func DeleteCygxActivitySignupBreakById(activityId int) (err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := ` DELETE FROM cygx_activity_signup_break  WHERE  activity_id =? `
	_, err = o.Raw(sql, activityId).Exec()
	return
}
