package schema

import (
	"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"
	
)

// DocServerProject holds the schema definition for the DocServerProject entity.
// Comments: 文件转换服务项目表
type DocServerProject struct {
	ent.Schema
}

// Fields of the DocServerProject.
func (DocServerProject) Fields() []ent.Field { 
    
	return []ent.Field{ 
		field.Int32("id").SchemaType(map[string]string{
			dialect.MySQL: "int",
		}).Unique().Comment(`id`),
		
		field.String("project_name").SchemaType(map[string]string{
            dialect.MySQL: "varchar(32)",
        }).Default(``).Comment(`项目名称`),
		
		field.String("source_type").SchemaType(map[string]string{
            dialect.MySQL: "varchar(16)",
        }).Default(``).Comment(`来源类型`),
		
		field.String("target_type").SchemaType(map[string]string{
            dialect.MySQL: "varchar(16)",
        }).Default(``).Comment(`文件类型`),
		
		field.Text("source_url").SchemaType(map[string]string{
            dialect.MySQL: "text",
        }).Optional().Nillable().MaxLen(65535).Comment(`原url`),
		
		field.Text("target_url").SchemaType(map[string]string{
            dialect.MySQL: "text",
        }).Optional().Nillable().MaxLen(65535).Comment(`目标url`),
		
		field.String("task_id").SchemaType(map[string]string{
            dialect.MySQL: "varchar(128)",
        }).Default(``).Comment(`返回的文件转换任务id`),
		
		field.Int32("app_id").SchemaType(map[string]string{
			dialect.MySQL: "int",
		}).Default(0).Comment(`应用id`),
		
		field.Int32("status").SchemaType(map[string]string{
			dialect.MySQL: "int",
		}).Default(0).Comment(`状态`),
		
		field.Time("created_at").SchemaType(map[string]string{
            dialect.MySQL: "datetime",
        }).Optional().Nillable().Comment(`创建时间`),
		
	}
}

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

func (DocServerProject) Hooks() []ent.Hook {
    return []ent.Hook{ 
        validator.MaxRuneLen("project_name", 32),
        validator.MaxRuneLen("source_type", 16),
        validator.MaxRuneLen("target_type", 16),
        validator.MaxRuneLen("task_id", 128),
    }
}
