[feature] migrate to monorepo
This commit is contained in:
commit
05ddc1f783
267 changed files with 75165 additions and 0 deletions
52
backend/ent/schema/permission.go
Normal file
52
backend/ent/schema/permission.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Permission holds the schema definition for the Permission entity.
|
||||
type Permission struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the Permission.
|
||||
func (Permission) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("resource").
|
||||
NotEmpty().
|
||||
Comment("Resource name, e.g., 'media', 'post'"),
|
||||
field.String("action").
|
||||
NotEmpty().
|
||||
Comment("Action name, e.g., 'create', 'read', 'update', 'delete'"),
|
||||
field.String("description").
|
||||
Optional().
|
||||
Comment("Human readable description of the permission"),
|
||||
field.Time("created_at").
|
||||
Default(time.Now).
|
||||
Immutable(),
|
||||
field.Time("updated_at").
|
||||
Default(time.Now).
|
||||
UpdateDefault(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Permission.
|
||||
func (Permission) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("roles", Role.Type).
|
||||
Ref("permissions"),
|
||||
}
|
||||
}
|
||||
|
||||
// Indexes of the Permission.
|
||||
func (Permission) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
// Create a unique index on resource and action
|
||||
index.Fields("resource", "action").
|
||||
Unique(),
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue