129 lines
4.3 KiB
Go
129 lines
4.3 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package permission
|
|
|
|
import (
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
)
|
|
|
|
const (
|
|
// Label holds the string label denoting the permission type in the database.
|
|
Label = "permission"
|
|
// FieldID holds the string denoting the id field in the database.
|
|
FieldID = "id"
|
|
// FieldResource holds the string denoting the resource field in the database.
|
|
FieldResource = "resource"
|
|
// FieldAction holds the string denoting the action field in the database.
|
|
FieldAction = "action"
|
|
// FieldDescription holds the string denoting the description field in the database.
|
|
FieldDescription = "description"
|
|
// 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"
|
|
// EdgeRoles holds the string denoting the roles edge name in mutations.
|
|
EdgeRoles = "roles"
|
|
// Table holds the table name of the permission in the database.
|
|
Table = "permissions"
|
|
// RolesTable is the table that holds the roles relation/edge. The primary key declared below.
|
|
RolesTable = "role_permissions"
|
|
// 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 = "roles"
|
|
)
|
|
|
|
// Columns holds all SQL columns for permission fields.
|
|
var Columns = []string{
|
|
FieldID,
|
|
FieldResource,
|
|
FieldAction,
|
|
FieldDescription,
|
|
FieldCreatedAt,
|
|
FieldUpdatedAt,
|
|
}
|
|
|
|
var (
|
|
// RolesPrimaryKey and RolesColumn2 are the table columns denoting the
|
|
// primary key for the roles relation (M2M).
|
|
RolesPrimaryKey = []string{"role_id", "permission_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
|
|
}
|
|
|
|
var (
|
|
// ResourceValidator is a validator for the "resource" field. It is called by the builders before save.
|
|
ResourceValidator func(string) error
|
|
// ActionValidator is a validator for the "action" field. It is called by the builders before save.
|
|
ActionValidator func(string) error
|
|
// 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
|
|
)
|
|
|
|
// OrderOption defines the ordering options for the Permission 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()
|
|
}
|
|
|
|
// ByResource orders the results by the resource field.
|
|
func ByResource(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldResource, opts...).ToFunc()
|
|
}
|
|
|
|
// ByAction orders the results by the action field.
|
|
func ByAction(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldAction, opts...).ToFunc()
|
|
}
|
|
|
|
// ByDescription orders the results by the description field.
|
|
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldDescription, 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()
|
|
}
|
|
|
|
// 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...)...)
|
|
}
|
|
}
|
|
func newRolesStep() *sqlgraph.Step {
|
|
return sqlgraph.NewStep(
|
|
sqlgraph.From(Table, FieldID),
|
|
sqlgraph.To(RolesInverseTable, FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2M, true, RolesTable, RolesPrimaryKey...),
|
|
)
|
|
}
|