初始化2
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// Permission 权限/菜单
|
||||
type Permission struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Permission) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{entsql.Annotation{Table: "permission"}}
|
||||
}
|
||||
|
||||
func (Permission) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("id").Positive(),
|
||||
field.String("code").Unique().MaxLen(64).Comment("权限编码"),
|
||||
field.String("name").MaxLen(64).Comment("名称"),
|
||||
// MENU / BUTTON
|
||||
field.String("type").Default("MENU").MaxLen(20),
|
||||
field.String("path").Default("").MaxLen(128).Comment("前端路由"),
|
||||
field.String("icon").Default("").MaxLen(64),
|
||||
field.Int("sort").Default(0).Optional(),
|
||||
field.String("remark").Default("").MaxLen(255),
|
||||
field.Time("createdAt").Default(time.Now).Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (Permission) Indexes() []ent.Index {
|
||||
return []ent.Index{index.Fields("code").Unique()}
|
||||
}
|
||||
Reference in New Issue
Block a user