本提交完成了WMS系统的多维度优化升级: 1. 新增RBAC权限系统,支持角色/菜单/按钮三级权限管控 2. 重构库存盘点、物料管理、区域维护等模块的查询筛选与展示逻辑 3. 优化入库/出库/质检等业务流程,完善数据冗余与业务闭环 4. 移除旧装箱表,将装箱逻辑合并到出库主表 5. 新增前端权限判断工具、导出工具与端到端测试用例 6. 补充完善各类注释与数据库字段说明
37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
package schema
|
|
|
|
import (
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/schema/field"
|
|
"entgo.io/ent/schema/index"
|
|
)
|
|
|
|
// User 系统用户(账号与权限)
|
|
// 角色 role 控制功能权限:admin(管理员) / operator(库房保管员) / inspector(质检员)。
|
|
// 密码以 bcrypt 哈希存储,登录走 JWT。
|
|
type User struct {
|
|
ent.Schema
|
|
}
|
|
|
|
func (User) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.String("username").Unique().Comment("登录名"),
|
|
field.String("password").Comment("密码(哈希)"),
|
|
field.String("real_name").Optional().Comment("姓名"),
|
|
field.String("role").Default("operator").Comment("角色 admin/operator/inspector(旧字段,权限数据化后由 role_id 决定,此字段仅作兼容/展示)"),
|
|
field.Int("role_id").Optional().Comment("角色ID,关联 roles 表;为空时回退按 role 字符串取权限"),
|
|
field.String("dept").Optional().Comment("部门"),
|
|
field.String("phone").Optional().Comment("电话"),
|
|
field.Bool("is_active").Default(true).Comment("是否启用"),
|
|
field.Int64("last_login_at").Optional().Comment("最近登录时间"),
|
|
field.Int64("created_at").DefaultFunc(nowUnix),
|
|
field.Int64("updated_at").DefaultFunc(nowUnix),
|
|
}
|
|
}
|
|
|
|
func (User) Indexes() []ent.Index {
|
|
return []ent.Index{
|
|
index.Fields("role"),
|
|
}
|
|
}
|