// Code generated by ent, DO NOT EDIT. package user 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 user type in the database. Label = "user" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldStatus holds the string denoting the status field in the database. FieldStatus = "status" // 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" // FieldVersion holds the string denoting the version field in the database. FieldVersion = "version" // FieldDeletedAt holds the string denoting the deleted_at field in the database. FieldDeletedAt = "deleted_at" // FieldUsername holds the string denoting the username field in the database. FieldUsername = "username" // FieldPhoneNumber holds the string denoting the phone_number field in the database. FieldPhoneNumber = "phone_number" // FieldEmail holds the string denoting the email field in the database. FieldEmail = "email" // FieldPassword holds the string denoting the password field in the database. FieldPassword = "password" // FieldNickname holds the string denoting the nickname field in the database. FieldNickname = "nickname" // EdgeMetas holds the string denoting the metas edge name in mutations. EdgeMetas = "metas" // EdgeRoles holds the string denoting the roles edge name in mutations. EdgeRoles = "roles" // EdgeSocials holds the string denoting the socials edge name in mutations. EdgeSocials = "socials" // EdgeDepartments holds the string denoting the departments edge name in mutations. EdgeDepartments = "departments" // EdgeToken holds the string denoting the token edge name in mutations. EdgeToken = "token" // EdgeLoginRecord holds the string denoting the loginrecord edge name in mutations. EdgeLoginRecord = "loginRecord" // Table holds the table name of the user in the database. Table = "sys_user" // MetasTable is the table that holds the metas relation/edge. MetasTable = "sys_usermeta" // MetasInverseTable is the table name for the UserMeta entity. // It exists in this package in order to avoid circular dependency with the "usermeta" package. MetasInverseTable = "sys_usermeta" // MetasColumn is the table column denoting the metas relation/edge. MetasColumn = "user_id" // RolesTable is the table that holds the roles relation/edge. The primary key declared below. RolesTable = "user_roles" // RolesInverseTable is the table name for the Role entity. // It exists in this package in order to avoid circular dependency with the "role" package. RolesInverseTable = "sys_role" // SocialsTable is the table that holds the socials relation/edge. SocialsTable = "sys_user_social" // SocialsInverseTable is the table name for the UserSocial entity. // It exists in this package in order to avoid circular dependency with the "usersocial" package. SocialsInverseTable = "sys_user_social" // SocialsColumn is the table column denoting the socials relation/edge. SocialsColumn = "user_id" // DepartmentsTable is the table that holds the departments relation/edge. DepartmentsTable = "sys_department" // DepartmentsInverseTable is the table name for the Department entity. // It exists in this package in order to avoid circular dependency with the "department" package. DepartmentsInverseTable = "sys_department" // DepartmentsColumn is the table column denoting the departments relation/edge. DepartmentsColumn = "user_departments" // TokenTable is the table that holds the token relation/edge. TokenTable = "sys_token" // TokenInverseTable is the table name for the Token entity. // It exists in this package in order to avoid circular dependency with the "token" package. TokenInverseTable = "sys_token" // TokenColumn is the table column denoting the token relation/edge. TokenColumn = "user_id" // LoginRecordTable is the table that holds the loginRecord relation/edge. LoginRecordTable = "sys_login_record" // LoginRecordInverseTable is the table name for the LoginRecord entity. // It exists in this package in order to avoid circular dependency with the "loginrecord" package. LoginRecordInverseTable = "sys_login_record" // LoginRecordColumn is the table column denoting the loginRecord relation/edge. LoginRecordColumn = "user_id" ) // Columns holds all SQL columns for user fields. var Columns = []string{ FieldID, FieldStatus, FieldCreatedAt, FieldUpdatedAt, FieldVersion, FieldDeletedAt, FieldUsername, FieldPhoneNumber, FieldEmail, FieldPassword, FieldNickname, } var ( // RolesPrimaryKey and RolesColumn2 are the table columns denoting the // primary key for the roles relation (M2M). RolesPrimaryKey = []string{"user_id", "role_id"} ) // 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 } } 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("user: invalid enum value for status field: %q", s) } } // OrderOption defines the ordering options for the User 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() } // ByStatus orders the results by the status field. func ByStatus(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldStatus, 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() } // ByVersion orders the results by the version field. func ByVersion(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldVersion, opts...).ToFunc() } // ByDeletedAt orders the results by the deleted_at field. func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() } // ByUsername orders the results by the username field. func ByUsername(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUsername, opts...).ToFunc() } // ByPhoneNumber orders the results by the phone_number field. func ByPhoneNumber(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldPhoneNumber, opts...).ToFunc() } // ByEmail orders the results by the email field. func ByEmail(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldEmail, opts...).ToFunc() } // ByPassword orders the results by the password field. func ByPassword(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldPassword, opts...).ToFunc() } // ByNickname orders the results by the nickname field. func ByNickname(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldNickname, opts...).ToFunc() } // ByMetasCount orders the results by metas count. func ByMetasCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborsCount(s, newMetasStep(), opts...) } } // ByMetas orders the results by metas terms. func ByMetas(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newMetasStep(), append([]sql.OrderTerm{term}, terms...)...) } } // ByRolesCount orders the results by roles count. func ByRolesCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborsCount(s, newRolesStep(), opts...) } } // ByRoles orders the results by roles terms. func ByRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newRolesStep(), append([]sql.OrderTerm{term}, terms...)...) } } // BySocialsCount orders the results by socials count. func BySocialsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborsCount(s, newSocialsStep(), opts...) } } // BySocials orders the results by socials terms. func BySocials(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newSocialsStep(), append([]sql.OrderTerm{term}, terms...)...) } } // ByDepartmentsCount orders the results by departments count. func ByDepartmentsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborsCount(s, newDepartmentsStep(), opts...) } } // ByDepartments orders the results by departments terms. func ByDepartments(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newDepartmentsStep(), append([]sql.OrderTerm{term}, terms...)...) } } // ByTokenCount orders the results by token count. func ByTokenCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborsCount(s, newTokenStep(), opts...) } } // ByToken orders the results by token terms. func ByToken(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newTokenStep(), append([]sql.OrderTerm{term}, terms...)...) } } // ByLoginRecordField orders the results by loginRecord field. func ByLoginRecordField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newLoginRecordStep(), sql.OrderByField(field, opts...)) } } func newMetasStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(MetasInverseTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, MetasTable, MetasColumn), ) } func newRolesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(RolesInverseTable, FieldID), sqlgraph.Edge(sqlgraph.M2M, false, RolesTable, RolesPrimaryKey...), ) } func newSocialsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(SocialsInverseTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, SocialsTable, SocialsColumn), ) } func newDepartmentsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(DepartmentsInverseTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, DepartmentsTable, DepartmentsColumn), ) } func newTokenStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(TokenInverseTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, TokenTable, TokenColumn), ) } func newLoginRecordStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(LoginRecordInverseTable, FieldID), sqlgraph.Edge(sqlgraph.O2O, false, LoginRecordTable, LoginRecordColumn), ) }