Files
bj_power/bj_power_mes/schema/role.go
T

38 lines
973 B
Go
Raw Normal View History

2026-08-28 15:06:01 +08:00
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()}
}