package models

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

const (
	EnglishReportEmailOpLogTypeAdd = iota + 1
	EnglishReportEmailOpLogTypeEdit
	EnglishReportEmailOpLogTypeDel
	EnglishReportEmailOpLogTypeImport
	EnglishReportEmailOpLogTypeEditEnabled
	EnglishReportEmailOpLogTypeMoveToCurrent
)

// EnglishReportEmailOpLog 英文邮箱/联系人-操作日志表
type EnglishReportEmailOpLog struct {
	Id         int       `orm:"column(id);pk"`
	CompanyId  int       `description:"客户ID"`
	EmailId    int       `description:"联系人ID"`
	AdminId    int       `description:"操作人ID"`
	OptionData string    `description:"操作数据-JSON"`
	OptionType int       `description:"操作类型：1-新增；2-编辑；3-删除；4-导入"`
	CreateTime time.Time `description:"创建时间"`
}

func (item *EnglishReportEmailOpLog) TableName() string {
	return "english_report_email_op_log"
}

func (item *EnglishReportEmailOpLog) Create() (err error) {
	o := orm.NewOrmUsingDB("rddp")
	id, err := o.Insert(item)
	if err != nil {
		return
	}
	item.Id = int(id)
	return
}

func (item *EnglishReportEmailOpLog) MultiCreate(items []*EnglishReportEmailOpLog) (err error) {
	o := orm.NewOrmUsingDB("rddp")
	_, err = o.InsertMulti(len(items), items)
	return
}

func (item *EnglishReportEmailOpLog) Update(cols []string) (err error) {
	o := orm.NewOrmUsingDB("rddp")
	_, err = o.Update(item, cols...)
	return
}
