package schema

import (
	"time"

	"entgo.io/ent"
	"entgo.io/ent/dialect"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	
	"gitlab.galaxy-immi.com/Backend-group/go-com/validator"
	
)

// DocServerApp holds the schema definition for the DocServerApp entity.
// Comments: 文件转换服务应用表
type DocServerApp struct {
	ent.Schema
}

// Fields of the DocServerApp.
func (DocServerApp) Fields() []ent.Field { 
    
	return []ent.Field{ 
		field.Int32("id").SchemaType(map[string]string{
			dialect.MySQL: "int",
		}).Unique().Comment(`业务id`),
		
		field.String("application").SchemaType(map[string]string{
            dialect.MySQL: "varchar(128)",
        }).Comment(`密钥`),
		
		field.String("name").SchemaType(map[string]string{
            dialect.MySQL: "varchar(32)",
        }).Default(``).Comment(`名称`),
		
		field.Time("created_at").SchemaType(map[string]string{
            dialect.MySQL: "datetime",
        }).Optional().Nillable().UpdateDefault(time.Now).Comment(`创建时间`),
		
	}
}

func (DocServerApp) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.Annotation{Table: `doc_server_app`},
	}
}

func (DocServerApp) Hooks() []ent.Hook {
    return []ent.Hook{ 
        validator.MaxRuneLen("application", 128),
        validator.MaxRuneLen("name", 32),
    }
}
