初始化2

This commit is contained in:
SunYF
2026-08-28 15:06:01 +08:00
parent b34325a16f
commit a9c3fbeb41
537 changed files with 176215 additions and 17 deletions
+38
View File
@@ -0,0 +1,38 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// Role 角色:承载菜单/按钮权限
type Role struct {
ent.Schema
}
func (Role) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "role"}}
}
func (Role) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("name").MaxLen(64).Comment("角色名称"),
field.String("code").Unique().MaxLen(64).Comment("角色编码"),
field.String("remark").Default("").MaxLen(255),
field.JSON("permissionCodes", []string{}).Optional().SchemaType(map[string]string{
dialect.Postgres: "jsonb",
}).Comment("权限编码列表,如 produce.workorder:view"),
field.Time("createdAt").Default(time.Now).Immutable(),
}
}
func (Role) Indexes() []ent.Index {
return []ent.Index{index.Fields("code").Unique()}
}