package models

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

const (
	EnglishCompanyLogOptionTypeAdd = iota + 1
	EnglishCompanyLogOptionTypeEdit
	EnglishCompanyLogOptionTypeDel
	EnglishCompanyLogOptionTypeEditEnabled
	EnglishCompanyLogOptionTypeSavePermission
)

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

func (item *EnglishCompanyLog) TableName() string {
	return "english_company_log"
}

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

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