package model

import "time"

type OperateEvent struct {
	ID           int64     `orm:"column(id)" json:"id"`
	CreatedAt    time.Time `orm:"auto_now_add;type(datetime)" json:"createdAt"`
	LastOperator string    `orm:"size(32)" json:"lastOperator"` // 最后操作员
	AccessUUID   string    `orm:"column(access_uuid)" json:"accessUUID"`
	UserID       string    `orm:"column(user_id)" json:"userID"`
	APIFunction  string    `orm:"column(api_function)" json:"apiFunction"`
	JsonData     string    `orm:"size(3200)" json:"jsonData"`
	ErrCode      string    `orm:"size(32)" json:"errCode"`
	ErrMsg       string    `orm:"size(9999)" json:"errMsg"`
	UseTime      int       `json:"useTime"`
}

func (v *OperateEvent) TableIndex() [][]string {
	return [][]string{
		[]string{"AccessUUID"},
		[]string{"UserID"},
		[]string{"APIFunction"},
		[]string{"CreatedAt"},
	}
}

type OperateEventDetail struct {
	ID          int64  `orm:"column(id)" json:"id"`
	OperateType int    `json:"operateType"` // 1为修改，2为新增，4为删除
	ThingID     int    `orm:"column(thing_id)" json:"thingID"`
	ThingType   int    `json:"thingType"` //各字段类型
	StoreID     int    `orm:"column(store_id)" json:"storeID"`
	AccessUUID  string `orm:"column(access_uuid)" json:"accessUUID"`
	BeforeData  string `orm:"size(3200)" json:"beforeData"`
	AfterData   string `orm:"size(3200)" json:"afterData"`
}

func (v *OperateEventDetail) TableIndex() [][]string {
	return [][]string{
		[]string{"AccessUUID"},
	}
}

func (*OperateEventDetail) TableUnique() [][]string {
	return [][]string{
		[]string{"ThingID", "StoreID", "AccessUUID"},
	}
}
