本提交完成了WMS系统的多维度优化升级: 1. 新增RBAC权限系统,支持角色/菜单/按钮三级权限管控 2. 重构库存盘点、物料管理、区域维护等模块的查询筛选与展示逻辑 3. 优化入库/出库/质检等业务流程,完善数据冗余与业务闭环 4. 移除旧装箱表,将装箱逻辑合并到出库主表 5. 新增前端权限判断工具、导出工具与端到端测试用例 6. 补充完善各类注释与数据库字段说明
42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
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.Annotation{Table: "roles"}}
|
||
}
|
||
|
||
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()}
|
||
}
|