package models

import (
	"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
	"time"
)

type Table struct {
	tableName string `comment:"表" pg:"metadata.tables,alias:table"`
	// 表Id
	TableId int `comment:"表Id" pg:"pk:table_id"`
	// 表类型 MainTable:主表 SideTable:副表 SubTable:分表  ExcelTable:Excel表
	TableType string `comment:"表类型 MainTable:主表 SideTable:副表 SubTable:分表  ExcelTable:Excel表"`
	// 名称
	Name string `comment:"名称"`
	// 对应数据库名称
	SQLName string `comment:"对应数据库名称"`
	// 父级ID
	ParentId int `comment:"父级ID"`
	// 数据字段序号
	DataFieldIndex int `comment:"数据字段序号"`
	// 主键字段
	PK *domain.Field `comment:"主键字段"`
	// 数据列
	DataFields []*domain.Field `comment:"数据列"`
	// 手动添加的列
	ManualFields []*domain.Field `comment:"手动添加的列"`
	// 默认排序列
	//OrderFields []*domain.Field `comment:"默认排序列"`
	// 创建时间
	CreatedAt time.Time `comment:"创建时间"`
	// 更新时间
	UpdatedAt time.Time `comment:"更新时间"`
	// 删除时间
	DeletedAt time.Time `pg:",soft_delete" comment:"删除时间"`
	// 版本
	Version int `comment:"版本"`
	// 行数
	RowCount int `comment:"行数"`
	// 扩展
	Context *domain.Context `comment:"扩展"`
	// 表信息
	TableInfo *domain.TableInfo `comment:"表信息"`
	// 应用于的时间
	ApplyAt time.Time `comment:"应用于的时间"`
}