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

// DocServerCallback holds the schema definition for the DocServerCallback entity.
// Comments: 业务创建项目回调
type DocServerCallback struct {
	ent.Schema
}

// Fields of the DocServerCallback.
func (DocServerCallback) Fields() []ent.Field { 
    
	return []ent.Field{ 
		field.Int32("id").SchemaType(map[string]string{
			dialect.MySQL: "int",
		}).Unique().Comment(`id`),
		
		field.Int32("server_project_id").SchemaType(map[string]string{
			dialect.MySQL: "int",
		}).Default(0).Comment(`创建项目表id`),
		
		field.String("callback_url").SchemaType(map[string]string{
            dialect.MySQL: "varchar(255)",
        }).Default(``).Comment(`业务回调地址`),
		
		field.String("callback_data").SchemaType(map[string]string{
            dialect.MySQL: "varchar(255)",
        }).Default(``).Comment(`业务回调参数`),
		
		field.Int8("callback_type").SchemaType(map[string]string{
			dialect.MySQL: "tinyint",
		}).Default(0).Comment(`业务需要的回调类型，1 回调地址，2 直接改表`),
		
		field.Int8("status").SchemaType(map[string]string{
			dialect.MySQL: "tinyint",
		}).Comment(`状态 0 待执行  1 执行成功....`),
		
		field.Int32("curr_num").SchemaType(map[string]string{
			dialect.MySQL: "int",
		}).Default(0).Comment(`执行次数`),
		
		field.Time("created_at").SchemaType(map[string]string{
            dialect.MySQL: "datetime",
        }).Optional().Nillable(),
		
		field.Time("updated_at").SchemaType(map[string]string{
            dialect.MySQL: "datetime",
        }).Optional().Nillable(),
		
		field.Time("deleted_at").SchemaType(map[string]string{
            dialect.MySQL: "datetime",
        }).Optional().Nillable(),
		
	}
}

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

func (DocServerCallback) Hooks() []ent.Hook {
    return []ent.Hook{ 
        validator.MaxRuneLen("callback_url", 255),
        validator.MaxRuneLen("callback_data", 255),
    }
}
