// Code generated by ent, DO NOT EDIT. package department import ( "fmt" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "git.noahlan.cn/noahlan/ntool-biz/core/orm/nent/types" ) const ( // Label holds the string label denoting the department type in the database. Label = "department" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldCreatedAt holds the string denoting the created_at field in the database. FieldCreatedAt = "created_at" // FieldUpdatedAt holds the string denoting the updated_at field in the database. FieldUpdatedAt = "updated_at" // FieldStatus holds the string denoting the status field in the database. FieldStatus = "status" // FieldVersion holds the string denoting the version field in the database. FieldVersion = "version" // FieldName holds the string denoting the name field in the database. FieldName = "name" // FieldLeaderID holds the string denoting the leader_id field in the database. FieldLeaderID = "leader_id" // FieldRemark holds the string denoting the remark field in the database. FieldRemark = "remark" // FieldParentID holds the string denoting the parent_id field in the database. FieldParentID = "parent_id" // EdgeParent holds the string denoting the parent edge name in mutations. EdgeParent = "parent" // EdgeChildren holds the string denoting the children edge name in mutations. EdgeChildren = "children" // EdgeUser holds the string denoting the user edge name in mutations. EdgeUser = "user" // EdgeLeader holds the string denoting the leader edge name in mutations. EdgeLeader = "leader" // Table holds the table name of the department in the database. Table = "sys_department" // ParentTable is the table that holds the parent relation/edge. ParentTable = "sys_department" // ParentColumn is the table column denoting the parent relation/edge. ParentColumn = "parent_id" // ChildrenTable is the table that holds the children relation/edge. ChildrenTable = "sys_department" // ChildrenColumn is the table column denoting the children relation/edge. ChildrenColumn = "parent_id" // UserTable is the table that holds the user relation/edge. UserTable = "sys_department" // UserInverseTable is the table name for the User entity. // It exists in this package in order to avoid circular dependency with the "user" package. UserInverseTable = "sys_user" // UserColumn is the table column denoting the user relation/edge. UserColumn = "user_departments" // LeaderTable is the table that holds the leader relation/edge. LeaderTable = "sys_department" // LeaderInverseTable is the table name for the User entity. // It exists in this package in order to avoid circular dependency with the "user" package. LeaderInverseTable = "sys_user" // LeaderColumn is the table column denoting the leader relation/edge. LeaderColumn = "leader_id" ) // Columns holds all SQL columns for department fields. var Columns = []string{ FieldID, FieldCreatedAt, FieldUpdatedAt, FieldStatus, FieldVersion, FieldName, FieldLeaderID, FieldRemark, FieldParentID, } // ForeignKeys holds the SQL foreign-keys that are owned by the "sys_department" // table and are not defined as standalone fields in the schema. var ForeignKeys = []string{ "user_departments", } // ValidColumn reports if the column name is valid (part of the table columns). func ValidColumn(column string) bool { for i := range Columns { if column == Columns[i] { return true } } for i := range ForeignKeys { if column == ForeignKeys[i] { return true } } return false } // Note that the variables below are initialized by the runtime // package on the initialization of the application. Therefore, // it should be imported in the main as follows: // // import _ "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/runtime" var ( Hooks [1]ent.Hook // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() time.Time // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. DefaultUpdatedAt func() time.Time // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. UpdateDefaultUpdatedAt func() time.Time // DefaultVersion holds the default value on creation for the "version" field. DefaultVersion int64 // DefaultID holds the default value on creation for the "id" field. DefaultID func() int64 ) const DefaultStatus types.Status = "Normal" // StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. func StatusValidator(s types.Status) error { switch s.String() { case "Normal", "Pending", "Disabled", "Locked": return nil default: return fmt.Errorf("department: invalid enum value for status field: %q", s) } } // OrderOption defines the ordering options for the Department queries. type OrderOption func(*sql.Selector) // ByID orders the results by the id field. func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } // ByCreatedAt orders the results by the created_at field. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() } // ByUpdatedAt orders the results by the updated_at field. func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() } // ByStatus orders the results by the status field. func ByStatus(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldStatus, opts...).ToFunc() } // ByVersion orders the results by the version field. func ByVersion(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldVersion, opts...).ToFunc() } // ByName orders the results by the name field. func ByName(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldName, opts...).ToFunc() } // ByLeaderID orders the results by the leader_id field. func ByLeaderID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldLeaderID, opts...).ToFunc() } // ByRemark orders the results by the remark field. func ByRemark(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldRemark, opts...).ToFunc() } // ByParentID orders the results by the parent_id field. func ByParentID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldParentID, opts...).ToFunc() } // ByParentField orders the results by parent field. func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...)) } } // ByChildrenCount orders the results by children count. func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...) } } // ByChildren orders the results by children terms. func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...) } } // ByUserField orders the results by user field. func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) } } // ByLeaderField orders the results by leader field. func ByLeaderField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newLeaderStep(), sql.OrderByField(field, opts...)) } } func newParentStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(Table, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), ) } func newChildrenStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(Table, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), ) } func newUserStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(UserInverseTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), ) } func newLeaderStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(LeaderInverseTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, false, LeaderTable, LeaderColumn), ) }