Files
bj_power/bj_power_wms/schema/role.go
T
SunYF 1f7a42fc38 refactor(mes): 移除工位接驳台绑定逻辑,改为独立dock主数据
- 移除station表的hasDock、dockCode字段及相关代码
- 新增dock表注释及关联逻辑,支持一个工位绑定多个接驳台
- 更新工位相关的seed、logic、schema及前端代码,适配新的接驳台管理方式
- 新增SQL注释固化脚本,完善MES表注释
2026-10-08 13:09:53 +08:00

42 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package schema
import (
"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 角色:承载菜单/按钮权限
// 模型移植自 MES(schema/role.go),但按 WMS 约定调整:
// - 字段名 snake_case(由 tools/generate.go 统一转 camelCase 输出 JSON)
// - 时间字段用 Int64 unix 秒,与 WMS 其余表保持一致
// - 与 MES 的差异:MES 的角色/权限为"系统预置只读",WMS 要求可维护,故支持增删改
type Role struct {
ent.Schema
}
func (Role) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Table("roles"), entsql.WithComments(true), schema.Comment("Role 角色:承载菜单/按钮权限")}
}
func (Role) Fields() []ent.Field {
return []ent.Field{
field.String("name").MaxLen(64).Comment("角色名称"),
field.String("code").Unique().MaxLen(64).Comment("角色编码,如 admin/operator/inspector"),
field.String("remark").Default("").MaxLen(255).Optional().Comment("备注"),
// 权限编码列表,如 inbound:view / inbound:create
field.JSON("permission_codes", []string{}).Optional().SchemaType(map[string]string{
dialect.Postgres: "jsonb",
}).Comment("权限编码列表"),
field.Int64("created_at").DefaultFunc(nowUnix).Comment("创建时间"),
field.Int64("updated_at").DefaultFunc(nowUnix).Comment("更新时间"),
}
}
func (Role) Indexes() []ent.Index {
return []ent.Index{index.Fields("code").Unique()}
}