From 79a97464477d36567ed469baed6335e8493df80f Mon Sep 17 00:00:00 2001 From: Yavolte Date: Wed, 18 Jun 2025 14:46:21 +0800 Subject: [PATCH] add logic and menu service --- formatter.go | 80 +++ internal/logic/department.go | 93 +++ internal/logic/menu.go | 44 ++ internal/logic/role.go | 54 ++ internal/logic/user.go | 63 ++ {defaults => migrate}/default.go | 48 +- migrate/migrate.go | 67 ++ pb/organize.pb.go | 805 +++++++++++++++++---- pb/organize.pb.validate.go | 1144 ++++++++++++++++++++++++++++++ pb/organize.proto | 71 +- pb/organize_grpc.pb.go | 180 ++++- pb/organize_http.pb.go | 71 +- pb/organize_model.pb.go | 19 +- permission.go | 27 +- server.go | 37 +- service/auth.go | 78 +- service/department.go | 107 ++- service/menu.go | 68 ++ service/role.go | 36 +- service/user.go | 116 +-- 20 files changed, 2860 insertions(+), 348 deletions(-) create mode 100644 formatter.go create mode 100644 internal/logic/department.go create mode 100644 internal/logic/menu.go create mode 100644 internal/logic/role.go create mode 100644 internal/logic/user.go rename {defaults => migrate}/default.go (68%) create mode 100644 migrate/migrate.go create mode 100644 service/menu.go diff --git a/formatter.go b/formatter.go new file mode 100644 index 0000000..347a723 --- /dev/null +++ b/formatter.go @@ -0,0 +1,80 @@ +package aeusadmin + +import ( + "context" + "fmt" + + "git.nobla.cn/golang/aeus-admin/internal/logic" + "git.nobla.cn/golang/rest" + "git.nobla.cn/golang/rest/types" + "gorm.io/gorm" +) + +type Formatter struct { + db *gorm.DB + user *logic.User + department *logic.Department + role *logic.Role + menu *logic.Menu +} + +func (f *Formatter) FormatUser(ctx context.Context, value, model any, scm *types.Schema) any { + if values, err := f.user.GetLabels(ctx); err == nil { + for _, row := range values { + if row.Value == value { + return fmt.Sprintf("%s(%s)", row.Label, row.Value) + } + } + } + return value +} + +func (f *Formatter) FormatDepartment(ctx context.Context, value, model any, scm *types.Schema) any { + if values, err := f.department.GetLabels(ctx); err == nil { + for _, row := range values { + if row.Value == value { + return row.Label + } + } + } + return value +} + +func (f *Formatter) FormatRole(ctx context.Context, value, model any, scm *types.Schema) any { + if values, err := f.role.GetLabels(ctx); err == nil { + for _, row := range values { + if row.Value == value { + return row.Label + } + } + } + return value +} + +func (f *Formatter) FormatMenu(ctx context.Context, value, model any, scm *types.Schema) any { + if values, err := f.menu.GetLabels(ctx); err == nil { + for _, row := range values { + if row.Value == value { + return row.Label + } + } + } + return value +} + +func (f *Formatter) Register() { + rest.DefaultFormatter.Register("user", f.FormatUser) + rest.DefaultFormatter.Register("department", f.FormatDepartment) + rest.DefaultFormatter.Register("role", f.FormatRole) + rest.DefaultFormatter.Register("menu", f.FormatMenu) +} + +func NewFormatter(db *gorm.DB) *Formatter { + return &Formatter{ + db: db, + user: logic.NewUserLogic(db), + department: logic.NewDepartmentLogic(db), + role: logic.NewRoleLogic(db), + menu: logic.NewMenuLogic(db), + } +} diff --git a/internal/logic/department.go b/internal/logic/department.go new file mode 100644 index 0000000..f79456c --- /dev/null +++ b/internal/logic/department.go @@ -0,0 +1,93 @@ +package logic + +import ( + "context" + "fmt" + "strings" + + "git.nobla.cn/golang/aeus-admin/models" + "git.nobla.cn/golang/aeus-admin/pkg/dbcache" + "git.nobla.cn/golang/rest" + "git.nobla.cn/golang/rest/types" + "gorm.io/gorm" +) + +type Department struct { + db *gorm.DB + sqlDependency *dbcache.SqlDependency +} + +func (u *Department) RecursiveDepartment(ctx context.Context, parent int64, level int, departments []*models.Department) []*types.TypeValue[int64] { + var ( + child []*types.TypeValue[int64] + ) + values := make([]*types.TypeValue[int64], 0, len(departments)) + for _, dept := range departments { + if dept.ParentId == parent { + if level == 0 { + values = append(values, &types.TypeValue[int64]{ + Label: dept.Name, + Value: dept.Id, + }) + } else { + values = append(values, &types.TypeValue[int64]{ + Label: strings.Repeat("--", level) + dept.Name, + Value: dept.Id, + }) + } + child = u.RecursiveDepartment(ctx, dept.Id, level+1, departments) + if len(child) > 0 { + for _, row := range child { + values = append(values, row) + } + } + } + } + return values +} + +// GetLevelLabels 获取层级标签 +func (u *Department) GetLevelLabels(ctx context.Context) (values []*types.TypeValue[int64], err error) { + values, err = dbcache.TryCache(ctx, fmt.Sprintf("department:level:labels"), func(tx *gorm.DB) ([]*types.TypeValue[int64], error) { + var values []*models.Department + if err = tx.Find(&values).Error; err != nil { + return nil, err + } + return u.RecursiveDepartment(ctx, 0, 0, values), nil + }, + dbcache.WithDB(u.db), + dbcache.WithDependency(u.sqlDependency), + ) + return +} + +// GetLabels 获取用户标签 +func (u *Department) GetLabels(ctx context.Context) (values []*types.TypeValue[int64], err error) { + values, err = dbcache.TryCache(ctx, fmt.Sprintf("department:labels"), func(tx *gorm.DB) ([]*types.TypeValue[int64], error) { + return rest.ModelTypes[int64](ctx, tx, &models.Department{}, "", "name", "id") + }, + dbcache.WithDB(u.db), + dbcache.WithDependency(u.sqlDependency), + ) + return +} + +// GetDepartments 获取部门列表 +func (u *Department) GetDepartments(ctx context.Context) (values []*models.Department, err error) { + values, err = dbcache.TryCache(ctx, fmt.Sprintf("department:list"), func(tx *gorm.DB) ([]*models.Department, error) { + var items []*models.Department + err = tx.Find(&items).Error + return items, err + }, + dbcache.WithDB(u.db), + dbcache.WithDependency(u.sqlDependency), + ) + return +} + +func NewDepartmentLogic(db *gorm.DB) *Department { + return &Department{ + db: db, + sqlDependency: dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM departments"), + } +} diff --git a/internal/logic/menu.go b/internal/logic/menu.go new file mode 100644 index 0000000..4e26c92 --- /dev/null +++ b/internal/logic/menu.go @@ -0,0 +1,44 @@ +package logic + +import ( + "context" + "fmt" + + "git.nobla.cn/golang/aeus-admin/models" + "git.nobla.cn/golang/aeus-admin/pkg/dbcache" + "git.nobla.cn/golang/rest" + "git.nobla.cn/golang/rest/types" + "gorm.io/gorm" +) + +type Menu struct { + db *gorm.DB + sqlDependency *dbcache.SqlDependency +} + +func (u *Menu) GetMenus(ctx context.Context) (values []*models.Menu, err error) { + return dbcache.TryCache(ctx, "menus", func(tx *gorm.DB) ([]*models.Menu, error) { + var items []*models.Menu + err = tx.Order("`position`,`id` ASC").Find(&items).Error + return items, err + }, + dbcache.WithDB(u.db), + dbcache.WithDependency(u.sqlDependency), + ) +} + +func (u *Menu) GetLabels(ctx context.Context) (values []*types.TypeValue[string], err error) { + return dbcache.TryCache(ctx, fmt.Sprintf("menu:labels"), func(tx *gorm.DB) ([]*types.TypeValue[string], error) { + return rest.ModelTypes[string](ctx, tx, &models.Menu{}, "", "label", "name") + }, + dbcache.WithDB(u.db), + dbcache.WithDependency(u.sqlDependency), + ) +} + +func NewMenuLogic(db *gorm.DB) *Menu { + return &Menu{ + db: db, + sqlDependency: dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM menus"), + } +} diff --git a/internal/logic/role.go b/internal/logic/role.go new file mode 100644 index 0000000..2b91d01 --- /dev/null +++ b/internal/logic/role.go @@ -0,0 +1,54 @@ +package logic + +import ( + "context" + "fmt" + + "git.nobla.cn/golang/aeus-admin/models" + "git.nobla.cn/golang/aeus-admin/pkg/dbcache" + "git.nobla.cn/golang/rest" + "git.nobla.cn/golang/rest/types" + "gorm.io/gorm" +) + +type Role struct { + db *gorm.DB + sqlDependency *dbcache.SqlDependency + permissionSqlDependency *dbcache.SqlDependency +} + +func (u *Role) GetLabels(ctx context.Context) (values []*types.TypeValue[string], err error) { + values, err = dbcache.TryCache(ctx, fmt.Sprintf("role:labels"), func(tx *gorm.DB) ([]*types.TypeValue[string], error) { + return rest.ModelTypes[string](ctx, tx, &models.Role{}, "", "label", "name") + }, + dbcache.WithDB(u.db), + dbcache.WithDependency(u.sqlDependency), + ) + return +} + +func (u *Role) GetPermissions(ctx context.Context, role string) (values []*models.Permission, err error) { + values, err = dbcache.TryCache(ctx, fmt.Sprintf("role:permissions-items:%s", role), func(tx *gorm.DB) ([]*models.Permission, error) { + var items []*models.Permission + if role == "" { + err = tx.Find(&items).Error + } else { + err = tx. + Where("`permission` IN (SELECT `permission` FROM role_permissions WHERE `role` = ?)", role). + Find(&items).Error + } + return items, err + }, + dbcache.WithDB(u.db), + dbcache.WithDependency(u.permissionSqlDependency), + ) + return +} + +func NewRoleLogic(db *gorm.DB) *Role { + return &Role{ + db: db, + sqlDependency: dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM roles"), + permissionSqlDependency: dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM permissions"), + } +} diff --git a/internal/logic/user.go b/internal/logic/user.go new file mode 100644 index 0000000..a0d1398 --- /dev/null +++ b/internal/logic/user.go @@ -0,0 +1,63 @@ +package logic + +import ( + "context" + "fmt" + "time" + + "git.nobla.cn/golang/aeus-admin/models" + "git.nobla.cn/golang/aeus-admin/pkg/dbcache" + "git.nobla.cn/golang/rest" + "git.nobla.cn/golang/rest/types" + "gorm.io/gorm" +) + +type User struct { + db *gorm.DB + sqlDependency *dbcache.SqlDependency +} + +// GetPermissions 获取用户权限 +func (u *User) GetPermissions(ctx context.Context, uid string) (permissions []string, err error) { + permissions, err = dbcache.TryCache(ctx, fmt.Sprintf("user:permissions:%s", uid), func(tx *gorm.DB) ([]string, error) { + var ss []string + err = tx.Select("permission").Model(&models.RolePermission{}). + Joins("LEFT JOIN users on users.role = role_permissions.role"). + Where("users.uid = ?", uid). + Pluck("permission", &ss). + Error + return ss, err + }, dbcache.WithCacheDuration(time.Minute), dbcache.WithDB(u.db)) + return +} + +// GetLabels 获取用户标签 +func (u *User) GetLabels(ctx context.Context) (values []*types.TypeValue[string], err error) { + values, err = dbcache.TryCache(ctx, fmt.Sprintf("user:labels"), func(tx *gorm.DB) ([]*types.TypeValue[string], error) { + return rest.ModelTypes[string](ctx, tx, &models.User{}, "", "username", "uid") + }, + dbcache.WithDB(u.db), + dbcache.WithDependency(u.sqlDependency), + ) + return +} + +// GeUsers 获取部门列表 +func (u *User) GeUsers(ctx context.Context) (values []*models.User, err error) { + values, err = dbcache.TryCache(ctx, fmt.Sprintf("user:list"), func(tx *gorm.DB) ([]*models.User, error) { + var items []*models.User + err = tx.Find(&items).Error + return items, err + }, + dbcache.WithDB(u.db), + dbcache.WithDependency(u.sqlDependency), + ) + return +} + +func NewUserLogic(db *gorm.DB) *User { + return &User{ + db: db, + sqlDependency: dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM users"), + } +} diff --git a/defaults/default.go b/migrate/default.go similarity index 68% rename from defaults/default.go rename to migrate/default.go index 75b1bf4..fccc0c3 100644 --- a/defaults/default.go +++ b/migrate/default.go @@ -1,10 +1,7 @@ -package defaults +package migrate import ( - "errors" - "git.nobla.cn/golang/aeus-admin/models" - "gorm.io/gorm" ) var ( @@ -84,46 +81,3 @@ func init() { systemDepartment.Description = "" defaultDepartments = append(defaultDepartments, systemDepartment) } - -func MergeMenu(db *gorm.DB, model *models.Menu) (err error) { - if err = db.Where("name = ?", model.Name).First(model).Error; err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - err = db.Create(model).Error - } - } - return -} - -func Generate(db *gorm.DB) (err error) { - var ( - n int64 - ) - for _, row := range defaultMenus { - if err = MergeMenu(db, row); err != nil { - return - } - } - if db.Model(&models.Role{}).Count(&n); n == 0 { - db.Create(defaultRoles) - permissions := make([]*models.Permission, 0) - db.Find(&permissions) - for _, row := range defaultRoles { - items := make([]*models.RolePermission, 0) - for _, perm := range permissions { - item := &models.RolePermission{} - item.Role = row.Name - item.Permission = perm.Permission - items = append(items, item) - } - db.Save(items) - } - } - - if db.Model(&models.Department{}).Count(&n); n == 0 { - db.Create(defaultDepartments) - } - if db.Model(&models.User{}).Count(&n); n == 0 { - db.Create(defaultUsers) - } - return -} diff --git a/migrate/migrate.go b/migrate/migrate.go new file mode 100644 index 0000000..70510b6 --- /dev/null +++ b/migrate/migrate.go @@ -0,0 +1,67 @@ +package migrate + +import ( + "errors" + + "git.nobla.cn/golang/aeus-admin/models" + "gorm.io/gorm" +) + +// Menu 合并菜单 +func Menu(db *gorm.DB, model *models.Menu) (err error) { + if err = db.Where("name = ?", model.Name).First(model).Error; err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + err = db.Create(model).Error + } + } + return +} + +// Permission 合并权限数据 +func Permission(db *gorm.DB, menuName string, permission string, label string) (permissionModel *models.Permission, err error) { + permissionModel = &models.Permission{} + if err = db.Where("permission = ? AND menu = ?", permission, menuName).First(permissionModel).Error; err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + permissionModel.Menu = menuName + permissionModel.Label = label + permissionModel.Permission = permission + err = db.Create(permissionModel).Error + } + } + return +} + +// Default 合并初始化数据集 +func Default(db *gorm.DB) (err error) { + var ( + n int64 + ) + for _, row := range defaultMenus { + if err = Menu(db, row); err != nil { + return + } + } + if db.Model(&models.Role{}).Count(&n); n == 0 { + db.Create(defaultRoles) + permissions := make([]*models.Permission, 0) + db.Find(&permissions) + for _, row := range defaultRoles { + items := make([]*models.RolePermission, 0) + for _, perm := range permissions { + item := &models.RolePermission{} + item.Role = row.Name + item.Permission = perm.Permission + items = append(items, item) + } + db.Save(items) + } + } + + if db.Model(&models.Department{}).Count(&n); n == 0 { + db.Create(defaultDepartments) + } + if db.Model(&models.User{}).Count(&n); n == 0 { + db.Create(defaultUsers) + } + return +} diff --git a/pb/organize.pb.go b/pb/organize.pb.go index a6c6d24..3f10d6b 100644 --- a/pb/organize.pb.go +++ b/pb/organize.pb.go @@ -40,6 +40,7 @@ type Menu struct { Hidden bool `protobuf:"varint,10,opt,name=hidden,proto3" json:"hidden,omitempty"` Public bool `protobuf:"varint,11,opt,name=public,proto3" json:"public,omitempty"` Description string `protobuf:"bytes,12,opt,name=description,proto3" json:"description,omitempty"` + Position int64 `protobuf:"varint,13,opt,name=position,proto3" json:"position,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -158,6 +159,13 @@ func (x *Menu) GetDescription() string { return "" } +func (x *Menu) GetPosition() int64 { + if x != nil { + return x.Position + } + return 0 +} + // Role 角色模型定义 type Role struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -247,9 +255,11 @@ func (x *Role) GetDescription() string { type Permission struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Menu string `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` - Permission string `protobuf:"bytes,3,opt,name=permission,proto3" json:"permission,omitempty"` - Label string `protobuf:"bytes,4,opt,name=label,proto3" json:"label,omitempty"` + CreatedAt int64 `protobuf:"varint,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + UpdatedAt int64 `protobuf:"varint,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` + Menu string `protobuf:"bytes,4,opt,name=menu,proto3" json:"menu,omitempty"` + Permission string `protobuf:"bytes,5,opt,name=permission,proto3" json:"permission,omitempty"` + Label string `protobuf:"bytes,6,opt,name=label,proto3" json:"label,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -291,6 +301,20 @@ func (x *Permission) GetId() int64 { return 0 } +func (x *Permission) GetCreatedAt() int64 { + if x != nil { + return x.CreatedAt + } + return 0 +} + +func (x *Permission) GetUpdatedAt() int64 { + if x != nil { + return x.UpdatedAt + } + return 0 +} + func (x *Permission) GetMenu() string { if x != nil { return x.Menu @@ -1874,6 +1898,74 @@ func (x *DepartmentLabelValue) GetValue() int64 { return 0 } +type DepartmentUserValue struct { + state protoimpl.MessageState `protogen:"open.v1"` + Label string `protobuf:"bytes,1,opt,name=label,proto3" json:"label,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + Isuser bool `protobuf:"varint,3,opt,name=isuser,proto3" json:"isuser,omitempty"` + Children []*DepartmentUserValue `protobuf:"bytes,4,rep,name=children,proto3" json:"children,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DepartmentUserValue) Reset() { + *x = DepartmentUserValue{} + mi := &file_organize_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DepartmentUserValue) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DepartmentUserValue) ProtoMessage() {} + +func (x *DepartmentUserValue) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[27] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DepartmentUserValue.ProtoReflect.Descriptor instead. +func (*DepartmentUserValue) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{27} +} + +func (x *DepartmentUserValue) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *DepartmentUserValue) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *DepartmentUserValue) GetIsuser() bool { + if x != nil { + return x.Isuser + } + return false +} + +func (x *DepartmentUserValue) GetChildren() []*DepartmentUserValue { + if x != nil { + return x.Children + } + return nil +} + type GetDepartmentLabelRequest struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields @@ -1882,7 +1974,7 @@ type GetDepartmentLabelRequest struct { func (x *GetDepartmentLabelRequest) Reset() { *x = GetDepartmentLabelRequest{} - mi := &file_organize_proto_msgTypes[27] + mi := &file_organize_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1894,7 +1986,7 @@ func (x *GetDepartmentLabelRequest) String() string { func (*GetDepartmentLabelRequest) ProtoMessage() {} func (x *GetDepartmentLabelRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[27] + mi := &file_organize_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1907,7 +1999,7 @@ func (x *GetDepartmentLabelRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetDepartmentLabelRequest.ProtoReflect.Descriptor instead. func (*GetDepartmentLabelRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{27} + return file_organize_proto_rawDescGZIP(), []int{28} } type GetDepartmentLabelResponse struct { @@ -1919,7 +2011,7 @@ type GetDepartmentLabelResponse struct { func (x *GetDepartmentLabelResponse) Reset() { *x = GetDepartmentLabelResponse{} - mi := &file_organize_proto_msgTypes[28] + mi := &file_organize_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1931,7 +2023,7 @@ func (x *GetDepartmentLabelResponse) String() string { func (*GetDepartmentLabelResponse) ProtoMessage() {} func (x *GetDepartmentLabelResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[28] + mi := &file_organize_proto_msgTypes[29] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1944,7 +2036,7 @@ func (x *GetDepartmentLabelResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetDepartmentLabelResponse.ProtoReflect.Descriptor instead. func (*GetDepartmentLabelResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{28} + return file_organize_proto_rawDescGZIP(), []int{29} } func (x *GetDepartmentLabelResponse) GetData() []*DepartmentLabelValue { @@ -1954,6 +2046,226 @@ func (x *GetDepartmentLabelResponse) GetData() []*DepartmentLabelValue { return nil } +type GetDepartmentUserRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDepartmentUserRequest) Reset() { + *x = GetDepartmentUserRequest{} + mi := &file_organize_proto_msgTypes[30] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDepartmentUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDepartmentUserRequest) ProtoMessage() {} + +func (x *GetDepartmentUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[30] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetDepartmentUserRequest.ProtoReflect.Descriptor instead. +func (*GetDepartmentUserRequest) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{30} +} + +type GetDepartmentUserResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data []*DepartmentUserValue `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDepartmentUserResponse) Reset() { + *x = GetDepartmentUserResponse{} + mi := &file_organize_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDepartmentUserResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDepartmentUserResponse) ProtoMessage() {} + +func (x *GetDepartmentUserResponse) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[31] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetDepartmentUserResponse.ProtoReflect.Descriptor instead. +func (*GetDepartmentUserResponse) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{31} +} + +func (x *GetDepartmentUserResponse) GetData() []*DepartmentUserValue { + if x != nil { + return x.Data + } + return nil +} + +type DepartmentLevelValue struct { + state protoimpl.MessageState `protogen:"open.v1"` + Label string `protobuf:"bytes,1,opt,name=label,proto3" json:"label,omitempty"` + Value int64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"` + Children []*DepartmentLevelValue `protobuf:"bytes,4,rep,name=children,proto3" json:"children,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DepartmentLevelValue) Reset() { + *x = DepartmentLevelValue{} + mi := &file_organize_proto_msgTypes[32] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DepartmentLevelValue) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DepartmentLevelValue) ProtoMessage() {} + +func (x *DepartmentLevelValue) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[32] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DepartmentLevelValue.ProtoReflect.Descriptor instead. +func (*DepartmentLevelValue) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{32} +} + +func (x *DepartmentLevelValue) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *DepartmentLevelValue) GetValue() int64 { + if x != nil { + return x.Value + } + return 0 +} + +func (x *DepartmentLevelValue) GetChildren() []*DepartmentLevelValue { + if x != nil { + return x.Children + } + return nil +} + +type GetDepartmentLevelLabelsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDepartmentLevelLabelsRequest) Reset() { + *x = GetDepartmentLevelLabelsRequest{} + mi := &file_organize_proto_msgTypes[33] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDepartmentLevelLabelsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDepartmentLevelLabelsRequest) ProtoMessage() {} + +func (x *GetDepartmentLevelLabelsRequest) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[33] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetDepartmentLevelLabelsRequest.ProtoReflect.Descriptor instead. +func (*GetDepartmentLevelLabelsRequest) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{33} +} + +type GetDepartmentLevelLabelsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data []*DepartmentLevelValue `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDepartmentLevelLabelsResponse) Reset() { + *x = GetDepartmentLevelLabelsResponse{} + mi := &file_organize_proto_msgTypes[34] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDepartmentLevelLabelsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDepartmentLevelLabelsResponse) ProtoMessage() {} + +func (x *GetDepartmentLevelLabelsResponse) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[34] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetDepartmentLevelLabelsResponse.ProtoReflect.Descriptor instead. +func (*GetDepartmentLevelLabelsResponse) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{34} +} + +func (x *GetDepartmentLevelLabelsResponse) GetData() []*DepartmentLevelValue { + if x != nil { + return x.Data + } + return nil +} + type GetRoleLabelRequest struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields @@ -1962,7 +2274,7 @@ type GetRoleLabelRequest struct { func (x *GetRoleLabelRequest) Reset() { *x = GetRoleLabelRequest{} - mi := &file_organize_proto_msgTypes[29] + mi := &file_organize_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1974,7 +2286,7 @@ func (x *GetRoleLabelRequest) String() string { func (*GetRoleLabelRequest) ProtoMessage() {} func (x *GetRoleLabelRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[29] + mi := &file_organize_proto_msgTypes[35] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1987,7 +2299,7 @@ func (x *GetRoleLabelRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRoleLabelRequest.ProtoReflect.Descriptor instead. func (*GetRoleLabelRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{29} + return file_organize_proto_rawDescGZIP(), []int{35} } type GetRoleLabelResponse struct { @@ -1999,7 +2311,7 @@ type GetRoleLabelResponse struct { func (x *GetRoleLabelResponse) Reset() { *x = GetRoleLabelResponse{} - mi := &file_organize_proto_msgTypes[30] + mi := &file_organize_proto_msgTypes[36] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2011,7 +2323,7 @@ func (x *GetRoleLabelResponse) String() string { func (*GetRoleLabelResponse) ProtoMessage() {} func (x *GetRoleLabelResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[30] + mi := &file_organize_proto_msgTypes[36] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2024,7 +2336,7 @@ func (x *GetRoleLabelResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRoleLabelResponse.ProtoReflect.Descriptor instead. func (*GetRoleLabelResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{30} + return file_organize_proto_rawDescGZIP(), []int{36} } func (x *GetRoleLabelResponse) GetData() []*LabelValue { @@ -2043,7 +2355,7 @@ type GetRolePermissionRequest struct { func (x *GetRolePermissionRequest) Reset() { *x = GetRolePermissionRequest{} - mi := &file_organize_proto_msgTypes[31] + mi := &file_organize_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2055,7 +2367,7 @@ func (x *GetRolePermissionRequest) String() string { func (*GetRolePermissionRequest) ProtoMessage() {} func (x *GetRolePermissionRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[31] + mi := &file_organize_proto_msgTypes[37] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2068,7 +2380,7 @@ func (x *GetRolePermissionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRolePermissionRequest.ProtoReflect.Descriptor instead. func (*GetRolePermissionRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{31} + return file_organize_proto_rawDescGZIP(), []int{37} } func (x *GetRolePermissionRequest) GetRole() string { @@ -2088,7 +2400,7 @@ type GetRolePermissionResponse struct { func (x *GetRolePermissionResponse) Reset() { *x = GetRolePermissionResponse{} - mi := &file_organize_proto_msgTypes[32] + mi := &file_organize_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2100,7 +2412,7 @@ func (x *GetRolePermissionResponse) String() string { func (*GetRolePermissionResponse) ProtoMessage() {} func (x *GetRolePermissionResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[32] + mi := &file_organize_proto_msgTypes[38] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2113,7 +2425,7 @@ func (x *GetRolePermissionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRolePermissionResponse.ProtoReflect.Descriptor instead. func (*GetRolePermissionResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{32} + return file_organize_proto_rawDescGZIP(), []int{38} } func (x *GetRolePermissionResponse) GetRole() string { @@ -2140,7 +2452,7 @@ type SaveRolePermissionRequest struct { func (x *SaveRolePermissionRequest) Reset() { *x = SaveRolePermissionRequest{} - mi := &file_organize_proto_msgTypes[33] + mi := &file_organize_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2152,7 +2464,7 @@ func (x *SaveRolePermissionRequest) String() string { func (*SaveRolePermissionRequest) ProtoMessage() {} func (x *SaveRolePermissionRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[33] + mi := &file_organize_proto_msgTypes[39] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2165,7 +2477,7 @@ func (x *SaveRolePermissionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SaveRolePermissionRequest.ProtoReflect.Descriptor instead. func (*SaveRolePermissionRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{33} + return file_organize_proto_rawDescGZIP(), []int{39} } func (x *SaveRolePermissionRequest) GetRole() string { @@ -2191,7 +2503,7 @@ type SaveRolePermissionResponse struct { func (x *SaveRolePermissionResponse) Reset() { *x = SaveRolePermissionResponse{} - mi := &file_organize_proto_msgTypes[34] + mi := &file_organize_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2203,7 +2515,7 @@ func (x *SaveRolePermissionResponse) String() string { func (*SaveRolePermissionResponse) ProtoMessage() {} func (x *SaveRolePermissionResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[34] + mi := &file_organize_proto_msgTypes[40] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2216,7 +2528,7 @@ func (x *SaveRolePermissionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SaveRolePermissionResponse.ProtoReflect.Descriptor instead. func (*SaveRolePermissionResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{34} + return file_organize_proto_rawDescGZIP(), []int{40} } func (x *SaveRolePermissionResponse) GetRole() string { @@ -2226,6 +2538,146 @@ func (x *SaveRolePermissionResponse) GetRole() string { return "" } +type MenuLevelValue struct { + state protoimpl.MessageState `protogen:"open.v1"` + Label string `protobuf:"bytes,1,opt,name=label,proto3" json:"label,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + Children []*MenuLevelValue `protobuf:"bytes,4,rep,name=children,proto3" json:"children,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *MenuLevelValue) Reset() { + *x = MenuLevelValue{} + mi := &file_organize_proto_msgTypes[41] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *MenuLevelValue) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MenuLevelValue) ProtoMessage() {} + +func (x *MenuLevelValue) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[41] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MenuLevelValue.ProtoReflect.Descriptor instead. +func (*MenuLevelValue) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{41} +} + +func (x *MenuLevelValue) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *MenuLevelValue) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *MenuLevelValue) GetChildren() []*MenuLevelValue { + if x != nil { + return x.Children + } + return nil +} + +type GetMenuLevelLabelsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetMenuLevelLabelsRequest) Reset() { + *x = GetMenuLevelLabelsRequest{} + mi := &file_organize_proto_msgTypes[42] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetMenuLevelLabelsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetMenuLevelLabelsRequest) ProtoMessage() {} + +func (x *GetMenuLevelLabelsRequest) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[42] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetMenuLevelLabelsRequest.ProtoReflect.Descriptor instead. +func (*GetMenuLevelLabelsRequest) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{42} +} + +type GetMenuLevelLabelsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data []*MenuLevelValue `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetMenuLevelLabelsResponse) Reset() { + *x = GetMenuLevelLabelsResponse{} + mi := &file_organize_proto_msgTypes[43] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetMenuLevelLabelsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetMenuLevelLabelsResponse) ProtoMessage() {} + +func (x *GetMenuLevelLabelsResponse) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[43] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetMenuLevelLabelsResponse.ProtoReflect.Descriptor instead. +func (*GetMenuLevelLabelsResponse) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{43} +} + +func (x *GetMenuLevelLabelsResponse) GetData() []*MenuLevelValue { + if x != nil { + return x.Data + } + return nil +} + type LoginRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` @@ -2237,7 +2689,7 @@ type LoginRequest struct { func (x *LoginRequest) Reset() { *x = LoginRequest{} - mi := &file_organize_proto_msgTypes[35] + mi := &file_organize_proto_msgTypes[44] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2249,7 +2701,7 @@ func (x *LoginRequest) String() string { func (*LoginRequest) ProtoMessage() {} func (x *LoginRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[35] + mi := &file_organize_proto_msgTypes[44] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2262,7 +2714,7 @@ func (x *LoginRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. func (*LoginRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{35} + return file_organize_proto_rawDescGZIP(), []int{44} } func (x *LoginRequest) GetUsername() string { @@ -2298,7 +2750,7 @@ type LoginResponse struct { func (x *LoginResponse) Reset() { *x = LoginResponse{} - mi := &file_organize_proto_msgTypes[36] + mi := &file_organize_proto_msgTypes[45] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2310,7 +2762,7 @@ func (x *LoginResponse) String() string { func (*LoginResponse) ProtoMessage() {} func (x *LoginResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[36] + mi := &file_organize_proto_msgTypes[45] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2323,7 +2775,7 @@ func (x *LoginResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. func (*LoginResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{36} + return file_organize_proto_rawDescGZIP(), []int{45} } func (x *LoginResponse) GetUid() string { @@ -2363,7 +2815,7 @@ type LogoutRequest struct { func (x *LogoutRequest) Reset() { *x = LogoutRequest{} - mi := &file_organize_proto_msgTypes[37] + mi := &file_organize_proto_msgTypes[46] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2375,7 +2827,7 @@ func (x *LogoutRequest) String() string { func (*LogoutRequest) ProtoMessage() {} func (x *LogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[37] + mi := &file_organize_proto_msgTypes[46] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2388,7 +2840,7 @@ func (x *LogoutRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead. func (*LogoutRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{37} + return file_organize_proto_rawDescGZIP(), []int{46} } func (x *LogoutRequest) GetToken() string { @@ -2407,7 +2859,7 @@ type LogoutResponse struct { func (x *LogoutResponse) Reset() { *x = LogoutResponse{} - mi := &file_organize_proto_msgTypes[38] + mi := &file_organize_proto_msgTypes[47] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2419,7 +2871,7 @@ func (x *LogoutResponse) String() string { func (*LogoutResponse) ProtoMessage() {} func (x *LogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[38] + mi := &file_organize_proto_msgTypes[47] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2432,7 +2884,7 @@ func (x *LogoutResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LogoutResponse.ProtoReflect.Descriptor instead. func (*LogoutResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{38} + return file_organize_proto_rawDescGZIP(), []int{47} } func (x *LogoutResponse) GetUid() string { @@ -2452,7 +2904,7 @@ type SettingItem struct { func (x *SettingItem) Reset() { *x = SettingItem{} - mi := &file_organize_proto_msgTypes[39] + mi := &file_organize_proto_msgTypes[48] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2464,7 +2916,7 @@ func (x *SettingItem) String() string { func (*SettingItem) ProtoMessage() {} func (x *SettingItem) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[39] + mi := &file_organize_proto_msgTypes[48] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2477,7 +2929,7 @@ func (x *SettingItem) ProtoReflect() protoreflect.Message { // Deprecated: Use SettingItem.ProtoReflect.Descriptor instead. func (*SettingItem) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{39} + return file_organize_proto_rawDescGZIP(), []int{48} } func (x *SettingItem) GetName() string { @@ -2502,7 +2954,7 @@ type GetSettingRequest struct { func (x *GetSettingRequest) Reset() { *x = GetSettingRequest{} - mi := &file_organize_proto_msgTypes[40] + mi := &file_organize_proto_msgTypes[49] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2514,7 +2966,7 @@ func (x *GetSettingRequest) String() string { func (*GetSettingRequest) ProtoMessage() {} func (x *GetSettingRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[40] + mi := &file_organize_proto_msgTypes[49] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2527,7 +2979,7 @@ func (x *GetSettingRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetSettingRequest.ProtoReflect.Descriptor instead. func (*GetSettingRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{40} + return file_organize_proto_rawDescGZIP(), []int{49} } type GetSettingResponse struct { @@ -2539,7 +2991,7 @@ type GetSettingResponse struct { func (x *GetSettingResponse) Reset() { *x = GetSettingResponse{} - mi := &file_organize_proto_msgTypes[41] + mi := &file_organize_proto_msgTypes[50] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2551,7 +3003,7 @@ func (x *GetSettingResponse) String() string { func (*GetSettingResponse) ProtoMessage() {} func (x *GetSettingResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[41] + mi := &file_organize_proto_msgTypes[50] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2564,7 +3016,7 @@ func (x *GetSettingResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetSettingResponse.ProtoReflect.Descriptor instead. func (*GetSettingResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{41} + return file_organize_proto_rawDescGZIP(), []int{50} } func (x *GetSettingResponse) GetData() []*SettingItem { @@ -2578,7 +3030,7 @@ var File_organize_proto protoreflect.FileDescriptor const file_organize_proto_rawDesc = "" + "\n" + - "\x0eorganize.proto\x12\borganize\x1a\x0faeus/rest.proto\x1a\x17validate/validate.proto\x1a google/protobuf/descriptor.proto\x1a\x1cgoogle/api/annotations.proto\"\xc6\a\n" + + "\x0eorganize.proto\x12\borganize\x1a\x0faeus/rest.proto\x1a\x17validate/validate.proto\x1a google/protobuf/descriptor.proto\x1a\x1cgoogle/api/annotations.proto\"\xab\b\n" + "\x04Menu\x12*\n" + "\x02id\x18\x01 \x01(\x03B\x1a\xb2\xb9\x19\x16\n" + "\n" + @@ -2587,9 +3039,9 @@ const file_organize_proto_rawDesc = "" + "created_at\x18\x02 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f创建时间\x1a\vview;exportR\tcreatedAt\x12E\n" + "\n" + "updated_at\x18\x03 \x01(\x03B&\xb2\xb9\x19\"\n" + - "\x05index\x12\f更新时间\x1a\vview;exportR\tupdatedAt\x12J\n" + - "\x06parent\x18\x04 \x01(\tB2\xb2\xb9\x19.\n" + - "\rindex;size:60\x12\f父级菜单2\x0freadonly:updateR\x06parent\x12^\n" + + "\x05index\x12\f更新时间\x1a\vview;exportR\tupdatedAt\x12v\n" + + "\x06parent\x18\x04 \x01(\tB^\xb2\xb9\x19Z\n" + + "\rindex;size:60\x12\f父级菜单*\x04menu2\x0freadonly:updateB$type:dropdown;url:/menu/level-labelsR\x06parent\x12^\n" + "\x04name\x18\x05 \x01(\tBJ\xfaB\x04r\x02\x18<\xb2\xb9\x19?\n" + "\rindex;size:60\x12\f组件名称2\x0freadonly:update:\x0funique;requiredR\x04name\x12C\n" + "\x05label\x18\x06 \x01(\tB-\xfaB\x04r\x02\x18x\xb2\xb9\x19\"\n" + @@ -2604,7 +3056,8 @@ const file_organize_proto_rawDesc = "" + " \x01(\bB-\xb2\xb9\x19)\x12\f是否隐藏\x1a\x19create;update;view;exportR\x06hidden\x12E\n" + "\x06public\x18\v \x01(\bB-\xb2\xb9\x19)\x12\f是否公开\x1a\x19create;update;view;exportR\x06public\x12q\n" + "\vdescription\x18\f \x01(\tBO\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19C\n" + - "\tsize:1024\x12\f备注说明\x1a\x1ecreate;update;view;export;list*\btextareaR\vdescription:\v\xba\xb9\x19\a\n" + + "\tsize:1024\x12\f备注说明\x1a\x1ecreate;update;view;export;list*\btextareaR\vdescription\x127\n" + + "\bposition\x18\r \x01(\x03B\x1b\xb2\xb9\x19\x17\x12\x06排序\x1a\rcreate;updateR\bposition:\v\xba\xb9\x19\a\n" + "\x05menus\"\xbd\x03\n" + "\x04Role\x12*\n" + "\x02id\x18\x01 \x01(\x03B\x1a\xb2\xb9\x19\x16\n" + @@ -2621,19 +3074,24 @@ const file_organize_proto_rawDesc = "" + "\asize:60\x12\f角色标题R\x05label\x12l\n" + "\vdescription\x18\x06 \x01(\tBJ\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19>\n" + "\tsize:1024\x12\f备注说明\x1a\x19list;create;update;export*\btextareaR\vdescription:\v\xba\xb9\x19\a\n" + - "\x05roles\"\xa4\x02\n" + + "\x05roles\"\xb1\x03\n" + "\n" + "Permission\x12*\n" + "\x02id\x18\x01 \x01(\x03B\x1a\xb2\xb9\x19\x16\n" + "\n" + - "primaryKey\x12\b权限IDR\x02id\x12?\n" + - "\x04menu\x18\x02 \x01(\tB+\xb2\xb9\x19'\n" + - "\rindex;size:60\x12\f所属菜单:\brequiredR\x04menu\x12R\n" + + "primaryKey\x12\b权限IDR\x02id\x12>\n" + "\n" + - "permission\x18\x03 \x01(\tB2\xfaB\x04r\x02\x18<\xb2\xb9\x19'\n" + + "created_at\x18\x02 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f创建时间\x1a\vview;exportR\tcreatedAt\x12E\n" + + "\n" + + "updated_at\x18\x03 \x01(\x03B&\xb2\xb9\x19\"\n" + + "\x05index\x12\f更新时间\x1a\vview;exportR\tupdatedAt\x12E\n" + + "\x04menu\x18\x04 \x01(\tB1\xb2\xb9\x19-\n" + + "\rindex;size:60\x12\f所属菜单*\x04menu:\brequiredR\x04menu\x12R\n" + + "\n" + + "permission\x18\x05 \x01(\tB2\xfaB\x04r\x02\x18<\xb2\xb9\x19'\n" + "\rindex;size:60\x12\f权限名称:\brequiredR\n" + "permission\x12B\n" + - "\x05label\x18\x04 \x01(\tB,\xfaB\x04r\x02\x18<\xb2\xb9\x19!\n" + + "\x05label\x18\x06 \x01(\tB,\xfaB\x04r\x02\x18<\xb2\xb9\x19!\n" + "\asize:60\x12\f权限标题:\brequiredR\x05label:\x11\xba\xb9\x19\r\n" + "\vpermissions\"\xd1\x01\n" + "\x0eRolePermission\x12$\n" + @@ -2681,7 +3139,7 @@ const file_organize_proto_rawDesc = "" + "\x13size:20;default:man\x12\f用户性别\x1a\x1elist;create;update;view;export:\brequiredR\x1eman:男;woman:女;other:其他R\x06gender\x12l\n" + "\vdescription\x18\x0f \x01(\tBJ\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19>\n" + "\tsize:1024\x12\f备注说明\x1a\x19create;update;view;export*\btextareaR\vdescription:\v\xba\xb9\x19\a\n" + - "\x05users\"\xbe\x03\n" + + "\x05users\"\xea\x03\n" + "\n" + "Department\x12$\n" + "\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" + @@ -2691,9 +3149,9 @@ const file_organize_proto_rawDesc = "" + "created_at\x18\x02 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f创建时间\x1a\vview;exportR\tcreatedAt\x12E\n" + "\n" + "updated_at\x18\x03 \x01(\x03B&\xb2\xb9\x19\"\n" + - "\x05index\x12\f更新时间\x1a\vview;exportR\tupdatedAt\x12;\n" + - "\tparent_id\x18\x04 \x01(\x03B\x1e\xb2\xb9\x19\x1a\x12\f父级部门*\n" + - "departmentR\bparentId\x12@\n" + + "\x05index\x12\f更新时间\x1a\vview;exportR\tupdatedAt\x12g\n" + + "\tparent_id\x18\x04 \x01(\x03BJ\xb2\xb9\x19F\x12\f父级部门*\n" + + "departmentB*type:dropdown;url:/department/level-labelsR\bparentId\x12@\n" + "\x04name\x18\x05 \x01(\tB,\xfaB\x04r\x02\x18\x14\xb2\xb9\x19!\n" + "\asize:20\x12\f部门名称:\brequiredR\x04name\x12q\n" + "\vdescription\x18\x06 \x01(\tBO\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19C\n" + @@ -2816,10 +3274,25 @@ const file_organize_proto_rawDesc = "" + "\x04data\x18\x01 \x03(\v2\x14.organize.LabelValueR\x04data\"B\n" + "\x14DepartmentLabelValue\x12\x14\n" + "\x05label\x18\x01 \x01(\tR\x05label\x12\x14\n" + - "\x05value\x18\x02 \x01(\x03R\x05value\"\x1b\n" + + "\x05value\x18\x02 \x01(\x03R\x05value\"\x94\x01\n" + + "\x13DepartmentUserValue\x12\x14\n" + + "\x05label\x18\x01 \x01(\tR\x05label\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value\x12\x16\n" + + "\x06isuser\x18\x03 \x01(\bR\x06isuser\x129\n" + + "\bchildren\x18\x04 \x03(\v2\x1d.organize.DepartmentUserValueR\bchildren\"\x1b\n" + "\x19GetDepartmentLabelRequest\"P\n" + "\x1aGetDepartmentLabelResponse\x122\n" + - "\x04data\x18\x01 \x03(\v2\x1e.organize.DepartmentLabelValueR\x04data\"\x15\n" + + "\x04data\x18\x01 \x03(\v2\x1e.organize.DepartmentLabelValueR\x04data\"\x1a\n" + + "\x18GetDepartmentUserRequest\"N\n" + + "\x19GetDepartmentUserResponse\x121\n" + + "\x04data\x18\x01 \x03(\v2\x1d.organize.DepartmentUserValueR\x04data\"~\n" + + "\x14DepartmentLevelValue\x12\x14\n" + + "\x05label\x18\x01 \x01(\tR\x05label\x12\x14\n" + + "\x05value\x18\x02 \x01(\x03R\x05value\x12:\n" + + "\bchildren\x18\x04 \x03(\v2\x1e.organize.DepartmentLevelValueR\bchildren\"!\n" + + "\x1fGetDepartmentLevelLabelsRequest\"V\n" + + " GetDepartmentLevelLabelsResponse\x122\n" + + "\x04data\x18\x01 \x03(\v2\x1e.organize.DepartmentLevelValueR\x04data\"\x15\n" + "\x13GetRoleLabelRequest\"@\n" + "\x14GetRoleLabelResponse\x12(\n" + "\x04data\x18\x01 \x03(\v2\x14.organize.LabelValueR\x04data\".\n" + @@ -2832,7 +3305,14 @@ const file_organize_proto_rawDesc = "" + "\x04role\x18\x01 \x01(\tR\x04role\x12 \n" + "\vpermissions\x18\x02 \x03(\tR\vpermissions\"0\n" + "\x1aSaveRolePermissionResponse\x12\x12\n" + - "\x04role\x18\x01 \x01(\tR\x04role\"\\\n" + + "\x04role\x18\x01 \x01(\tR\x04role\"r\n" + + "\x0eMenuLevelValue\x12\x14\n" + + "\x05label\x18\x01 \x01(\tR\x05label\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value\x124\n" + + "\bchildren\x18\x04 \x03(\v2\x18.organize.MenuLevelValueR\bchildren\"\x1b\n" + + "\x19GetMenuLevelLabelsRequest\"J\n" + + "\x1aGetMenuLevelLabelsResponse\x12,\n" + + "\x04data\x18\x01 \x03(\v2\x18.organize.MenuLevelValueR\x04data\"\\\n" + "\fLoginRequest\x12\x1a\n" + "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + "\bpassword\x18\x02 \x01(\tR\bpassword\x12\x14\n" + @@ -2861,13 +3341,17 @@ const file_organize_proto_rawDesc = "" + "\x0eGetPermissions\x12\x1e.organize.GetPermissionRequest\x1a\x1f.organize.GetPermissionResponse\"\x19\x82\xd3\xe4\x93\x02\x13\x12\x11/user/permissions\x12d\n" + "\rGetUserLabels\x12\x1d.organize.GetUserLabelRequest\x1a\x1e.organize.GetUserLabelResponse\"\x14\x82\xd3\xe4\x93\x02\x0e\x12\f/user/labels\x12\\\n" + "\vGetUserTags\x12\x1b.organize.GetUserTagRequest\x1a\x1c.organize.GetUserTagResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + - "/user/tags2\x91\x01\n" + + "/user/tags2\xa1\x03\n" + "\x11DepartmentService\x12|\n" + - "\x13GetDepartmentLabels\x12#.organize.GetDepartmentLabelRequest\x1a$.organize.GetDepartmentLabelResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/department/labels2\xec\x02\n" + + "\x13GetDepartmentLabels\x12#.organize.GetDepartmentLabelRequest\x1a$.organize.GetDepartmentLabelResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/department/labels\x12x\n" + + "\x12GetDepartmentUsers\x12\".organize.GetDepartmentUserRequest\x1a#.organize.GetDepartmentUserResponse\"\x19\x82\xd3\xe4\x93\x02\x13\x12\x11/department/users\x12\x93\x01\n" + + "\x18GetDepartmentLevelLabels\x12).organize.GetDepartmentLevelLabelsRequest\x1a*.organize.GetDepartmentLevelLabelsResponse\" \x82\xd3\xe4\x93\x02\x1a\x12\x18/department/level-labels2\xec\x02\n" + "\vRoleService\x12d\n" + "\rGetRoleLabels\x12\x1d.organize.GetRoleLabelRequest\x1a\x1e.organize.GetRoleLabelResponse\"\x14\x82\xd3\xe4\x93\x02\x0e\x12\f/role/labels\x12x\n" + "\x12GetRolePermissions\x12\".organize.GetRolePermissionRequest\x1a#.organize.GetRolePermissionResponse\"\x19\x82\xd3\xe4\x93\x02\x13\x12\x11/role/permissions\x12}\n" + - "\x12SaveRolePermission\x12#.organize.SaveRolePermissionRequest\x1a$.organize.SaveRolePermissionResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\"\x11/role/permissions2\xbd\x01\n" + + "\x12SaveRolePermission\x12#.organize.SaveRolePermissionRequest\x1a$.organize.SaveRolePermissionResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\"\x11/role/permissions2\x8a\x01\n" + + "\vMenuService\x12{\n" + + "\x12GetMenuLevelLabels\x12#.organize.GetMenuLevelLabelsRequest\x1a$.organize.GetMenuLevelLabelsResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/menu/level-labels2\xbd\x01\n" + "\vAuthService\x12T\n" + "\x05Login\x12\x16.organize.LoginRequest\x1a\x17.organize.LoginResponse\"\x1a\x82\xd3\xe4\x93\x02\x14:\x01*\"\x0f/passport/login\x12X\n" + "\x06Logout\x12\x17.organize.LogoutRequest\x1a\x18.organize.LogoutResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/passport/logout2r\n" + @@ -2887,50 +3371,59 @@ func file_organize_proto_rawDescGZIP() []byte { return file_organize_proto_rawDescData } -var file_organize_proto_msgTypes = make([]protoimpl.MessageInfo, 42) +var file_organize_proto_msgTypes = make([]protoimpl.MessageInfo, 51) var file_organize_proto_goTypes = []any{ - (*Menu)(nil), // 0: organize.Menu - (*Role)(nil), // 1: organize.Role - (*Permission)(nil), // 2: organize.Permission - (*RolePermission)(nil), // 3: organize.RolePermission - (*User)(nil), // 4: organize.User - (*Department)(nil), // 5: organize.Department - (*Login)(nil), // 6: organize.Login - (*Setting)(nil), // 7: organize.Setting - (*Activity)(nil), // 8: organize.Activity - (*LabelValue)(nil), // 9: organize.LabelValue - (*PermissionItem)(nil), // 10: organize.PermissionItem - (*MenuItem)(nil), // 11: organize.MenuItem - (*GetMenuRequest)(nil), // 12: organize.GetMenuRequest - (*GetMenuResponse)(nil), // 13: organize.GetMenuResponse - (*GetProfileRequest)(nil), // 14: organize.GetProfileRequest - (*GetProfileResponse)(nil), // 15: organize.GetProfileResponse - (*ResetPasswordRequest)(nil), // 16: organize.ResetPasswordRequest - (*ResetPasswordResponse)(nil), // 17: organize.ResetPasswordResponse - (*UpdateProfileRequest)(nil), // 18: organize.UpdateProfileRequest - (*UpdateProfileResponse)(nil), // 19: organize.UpdateProfileResponse - (*GetPermissionRequest)(nil), // 20: organize.GetPermissionRequest - (*GetPermissionResponse)(nil), // 21: organize.GetPermissionResponse - (*GetUserLabelRequest)(nil), // 22: organize.GetUserLabelRequest - (*GetUserLabelResponse)(nil), // 23: organize.GetUserLabelResponse - (*GetUserTagRequest)(nil), // 24: organize.GetUserTagRequest - (*GetUserTagResponse)(nil), // 25: organize.GetUserTagResponse - (*DepartmentLabelValue)(nil), // 26: organize.DepartmentLabelValue - (*GetDepartmentLabelRequest)(nil), // 27: organize.GetDepartmentLabelRequest - (*GetDepartmentLabelResponse)(nil), // 28: organize.GetDepartmentLabelResponse - (*GetRoleLabelRequest)(nil), // 29: organize.GetRoleLabelRequest - (*GetRoleLabelResponse)(nil), // 30: organize.GetRoleLabelResponse - (*GetRolePermissionRequest)(nil), // 31: organize.GetRolePermissionRequest - (*GetRolePermissionResponse)(nil), // 32: organize.GetRolePermissionResponse - (*SaveRolePermissionRequest)(nil), // 33: organize.SaveRolePermissionRequest - (*SaveRolePermissionResponse)(nil), // 34: organize.SaveRolePermissionResponse - (*LoginRequest)(nil), // 35: organize.LoginRequest - (*LoginResponse)(nil), // 36: organize.LoginResponse - (*LogoutRequest)(nil), // 37: organize.LogoutRequest - (*LogoutResponse)(nil), // 38: organize.LogoutResponse - (*SettingItem)(nil), // 39: organize.SettingItem - (*GetSettingRequest)(nil), // 40: organize.GetSettingRequest - (*GetSettingResponse)(nil), // 41: organize.GetSettingResponse + (*Menu)(nil), // 0: organize.Menu + (*Role)(nil), // 1: organize.Role + (*Permission)(nil), // 2: organize.Permission + (*RolePermission)(nil), // 3: organize.RolePermission + (*User)(nil), // 4: organize.User + (*Department)(nil), // 5: organize.Department + (*Login)(nil), // 6: organize.Login + (*Setting)(nil), // 7: organize.Setting + (*Activity)(nil), // 8: organize.Activity + (*LabelValue)(nil), // 9: organize.LabelValue + (*PermissionItem)(nil), // 10: organize.PermissionItem + (*MenuItem)(nil), // 11: organize.MenuItem + (*GetMenuRequest)(nil), // 12: organize.GetMenuRequest + (*GetMenuResponse)(nil), // 13: organize.GetMenuResponse + (*GetProfileRequest)(nil), // 14: organize.GetProfileRequest + (*GetProfileResponse)(nil), // 15: organize.GetProfileResponse + (*ResetPasswordRequest)(nil), // 16: organize.ResetPasswordRequest + (*ResetPasswordResponse)(nil), // 17: organize.ResetPasswordResponse + (*UpdateProfileRequest)(nil), // 18: organize.UpdateProfileRequest + (*UpdateProfileResponse)(nil), // 19: organize.UpdateProfileResponse + (*GetPermissionRequest)(nil), // 20: organize.GetPermissionRequest + (*GetPermissionResponse)(nil), // 21: organize.GetPermissionResponse + (*GetUserLabelRequest)(nil), // 22: organize.GetUserLabelRequest + (*GetUserLabelResponse)(nil), // 23: organize.GetUserLabelResponse + (*GetUserTagRequest)(nil), // 24: organize.GetUserTagRequest + (*GetUserTagResponse)(nil), // 25: organize.GetUserTagResponse + (*DepartmentLabelValue)(nil), // 26: organize.DepartmentLabelValue + (*DepartmentUserValue)(nil), // 27: organize.DepartmentUserValue + (*GetDepartmentLabelRequest)(nil), // 28: organize.GetDepartmentLabelRequest + (*GetDepartmentLabelResponse)(nil), // 29: organize.GetDepartmentLabelResponse + (*GetDepartmentUserRequest)(nil), // 30: organize.GetDepartmentUserRequest + (*GetDepartmentUserResponse)(nil), // 31: organize.GetDepartmentUserResponse + (*DepartmentLevelValue)(nil), // 32: organize.DepartmentLevelValue + (*GetDepartmentLevelLabelsRequest)(nil), // 33: organize.GetDepartmentLevelLabelsRequest + (*GetDepartmentLevelLabelsResponse)(nil), // 34: organize.GetDepartmentLevelLabelsResponse + (*GetRoleLabelRequest)(nil), // 35: organize.GetRoleLabelRequest + (*GetRoleLabelResponse)(nil), // 36: organize.GetRoleLabelResponse + (*GetRolePermissionRequest)(nil), // 37: organize.GetRolePermissionRequest + (*GetRolePermissionResponse)(nil), // 38: organize.GetRolePermissionResponse + (*SaveRolePermissionRequest)(nil), // 39: organize.SaveRolePermissionRequest + (*SaveRolePermissionResponse)(nil), // 40: organize.SaveRolePermissionResponse + (*MenuLevelValue)(nil), // 41: organize.MenuLevelValue + (*GetMenuLevelLabelsRequest)(nil), // 42: organize.GetMenuLevelLabelsRequest + (*GetMenuLevelLabelsResponse)(nil), // 43: organize.GetMenuLevelLabelsResponse + (*LoginRequest)(nil), // 44: organize.LoginRequest + (*LoginResponse)(nil), // 45: organize.LoginResponse + (*LogoutRequest)(nil), // 46: organize.LogoutRequest + (*LogoutResponse)(nil), // 47: organize.LogoutResponse + (*SettingItem)(nil), // 48: organize.SettingItem + (*GetSettingRequest)(nil), // 49: organize.GetSettingRequest + (*GetSettingResponse)(nil), // 50: organize.GetSettingResponse } var file_organize_proto_depIdxs = []int32{ 10, // 0: organize.MenuItem.permissions:type_name -> organize.PermissionItem @@ -2938,42 +3431,54 @@ var file_organize_proto_depIdxs = []int32{ 11, // 2: organize.GetMenuResponse.data:type_name -> organize.MenuItem 9, // 3: organize.GetUserLabelResponse.data:type_name -> organize.LabelValue 9, // 4: organize.GetUserTagResponse.data:type_name -> organize.LabelValue - 26, // 5: organize.GetDepartmentLabelResponse.data:type_name -> organize.DepartmentLabelValue - 9, // 6: organize.GetRoleLabelResponse.data:type_name -> organize.LabelValue - 39, // 7: organize.GetSettingResponse.data:type_name -> organize.SettingItem - 12, // 8: organize.UserService.GetMenus:input_type -> organize.GetMenuRequest - 14, // 9: organize.UserService.GetProfile:input_type -> organize.GetProfileRequest - 18, // 10: organize.UserService.UpdateProfile:input_type -> organize.UpdateProfileRequest - 16, // 11: organize.UserService.ResetPassword:input_type -> organize.ResetPasswordRequest - 20, // 12: organize.UserService.GetPermissions:input_type -> organize.GetPermissionRequest - 22, // 13: organize.UserService.GetUserLabels:input_type -> organize.GetUserLabelRequest - 24, // 14: organize.UserService.GetUserTags:input_type -> organize.GetUserTagRequest - 27, // 15: organize.DepartmentService.GetDepartmentLabels:input_type -> organize.GetDepartmentLabelRequest - 29, // 16: organize.RoleService.GetRoleLabels:input_type -> organize.GetRoleLabelRequest - 31, // 17: organize.RoleService.GetRolePermissions:input_type -> organize.GetRolePermissionRequest - 33, // 18: organize.RoleService.SaveRolePermission:input_type -> organize.SaveRolePermissionRequest - 35, // 19: organize.AuthService.Login:input_type -> organize.LoginRequest - 37, // 20: organize.AuthService.Logout:input_type -> organize.LogoutRequest - 40, // 21: organize.SettingService.GetSetting:input_type -> organize.GetSettingRequest - 13, // 22: organize.UserService.GetMenus:output_type -> organize.GetMenuResponse - 15, // 23: organize.UserService.GetProfile:output_type -> organize.GetProfileResponse - 19, // 24: organize.UserService.UpdateProfile:output_type -> organize.UpdateProfileResponse - 17, // 25: organize.UserService.ResetPassword:output_type -> organize.ResetPasswordResponse - 21, // 26: organize.UserService.GetPermissions:output_type -> organize.GetPermissionResponse - 23, // 27: organize.UserService.GetUserLabels:output_type -> organize.GetUserLabelResponse - 25, // 28: organize.UserService.GetUserTags:output_type -> organize.GetUserTagResponse - 28, // 29: organize.DepartmentService.GetDepartmentLabels:output_type -> organize.GetDepartmentLabelResponse - 30, // 30: organize.RoleService.GetRoleLabels:output_type -> organize.GetRoleLabelResponse - 32, // 31: organize.RoleService.GetRolePermissions:output_type -> organize.GetRolePermissionResponse - 34, // 32: organize.RoleService.SaveRolePermission:output_type -> organize.SaveRolePermissionResponse - 36, // 33: organize.AuthService.Login:output_type -> organize.LoginResponse - 38, // 34: organize.AuthService.Logout:output_type -> organize.LogoutResponse - 41, // 35: organize.SettingService.GetSetting:output_type -> organize.GetSettingResponse - 22, // [22:36] is the sub-list for method output_type - 8, // [8:22] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 27, // 5: organize.DepartmentUserValue.children:type_name -> organize.DepartmentUserValue + 26, // 6: organize.GetDepartmentLabelResponse.data:type_name -> organize.DepartmentLabelValue + 27, // 7: organize.GetDepartmentUserResponse.data:type_name -> organize.DepartmentUserValue + 32, // 8: organize.DepartmentLevelValue.children:type_name -> organize.DepartmentLevelValue + 32, // 9: organize.GetDepartmentLevelLabelsResponse.data:type_name -> organize.DepartmentLevelValue + 9, // 10: organize.GetRoleLabelResponse.data:type_name -> organize.LabelValue + 41, // 11: organize.MenuLevelValue.children:type_name -> organize.MenuLevelValue + 41, // 12: organize.GetMenuLevelLabelsResponse.data:type_name -> organize.MenuLevelValue + 48, // 13: organize.GetSettingResponse.data:type_name -> organize.SettingItem + 12, // 14: organize.UserService.GetMenus:input_type -> organize.GetMenuRequest + 14, // 15: organize.UserService.GetProfile:input_type -> organize.GetProfileRequest + 18, // 16: organize.UserService.UpdateProfile:input_type -> organize.UpdateProfileRequest + 16, // 17: organize.UserService.ResetPassword:input_type -> organize.ResetPasswordRequest + 20, // 18: organize.UserService.GetPermissions:input_type -> organize.GetPermissionRequest + 22, // 19: organize.UserService.GetUserLabels:input_type -> organize.GetUserLabelRequest + 24, // 20: organize.UserService.GetUserTags:input_type -> organize.GetUserTagRequest + 28, // 21: organize.DepartmentService.GetDepartmentLabels:input_type -> organize.GetDepartmentLabelRequest + 30, // 22: organize.DepartmentService.GetDepartmentUsers:input_type -> organize.GetDepartmentUserRequest + 33, // 23: organize.DepartmentService.GetDepartmentLevelLabels:input_type -> organize.GetDepartmentLevelLabelsRequest + 35, // 24: organize.RoleService.GetRoleLabels:input_type -> organize.GetRoleLabelRequest + 37, // 25: organize.RoleService.GetRolePermissions:input_type -> organize.GetRolePermissionRequest + 39, // 26: organize.RoleService.SaveRolePermission:input_type -> organize.SaveRolePermissionRequest + 42, // 27: organize.MenuService.GetMenuLevelLabels:input_type -> organize.GetMenuLevelLabelsRequest + 44, // 28: organize.AuthService.Login:input_type -> organize.LoginRequest + 46, // 29: organize.AuthService.Logout:input_type -> organize.LogoutRequest + 49, // 30: organize.SettingService.GetSetting:input_type -> organize.GetSettingRequest + 13, // 31: organize.UserService.GetMenus:output_type -> organize.GetMenuResponse + 15, // 32: organize.UserService.GetProfile:output_type -> organize.GetProfileResponse + 19, // 33: organize.UserService.UpdateProfile:output_type -> organize.UpdateProfileResponse + 17, // 34: organize.UserService.ResetPassword:output_type -> organize.ResetPasswordResponse + 21, // 35: organize.UserService.GetPermissions:output_type -> organize.GetPermissionResponse + 23, // 36: organize.UserService.GetUserLabels:output_type -> organize.GetUserLabelResponse + 25, // 37: organize.UserService.GetUserTags:output_type -> organize.GetUserTagResponse + 29, // 38: organize.DepartmentService.GetDepartmentLabels:output_type -> organize.GetDepartmentLabelResponse + 31, // 39: organize.DepartmentService.GetDepartmentUsers:output_type -> organize.GetDepartmentUserResponse + 34, // 40: organize.DepartmentService.GetDepartmentLevelLabels:output_type -> organize.GetDepartmentLevelLabelsResponse + 36, // 41: organize.RoleService.GetRoleLabels:output_type -> organize.GetRoleLabelResponse + 38, // 42: organize.RoleService.GetRolePermissions:output_type -> organize.GetRolePermissionResponse + 40, // 43: organize.RoleService.SaveRolePermission:output_type -> organize.SaveRolePermissionResponse + 43, // 44: organize.MenuService.GetMenuLevelLabels:output_type -> organize.GetMenuLevelLabelsResponse + 45, // 45: organize.AuthService.Login:output_type -> organize.LoginResponse + 47, // 46: organize.AuthService.Logout:output_type -> organize.LogoutResponse + 50, // 47: organize.SettingService.GetSetting:output_type -> organize.GetSettingResponse + 31, // [31:48] is the sub-list for method output_type + 14, // [14:31] is the sub-list for method input_type + 14, // [14:14] is the sub-list for extension type_name + 14, // [14:14] is the sub-list for extension extendee + 0, // [0:14] is the sub-list for field type_name } func init() { file_organize_proto_init() } @@ -2987,9 +3492,9 @@ func file_organize_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_organize_proto_rawDesc), len(file_organize_proto_rawDesc)), NumEnums: 0, - NumMessages: 42, + NumMessages: 51, NumExtensions: 0, - NumServices: 5, + NumServices: 6, }, GoTypes: file_organize_proto_goTypes, DependencyIndexes: file_organize_proto_depIdxs, diff --git a/pb/organize.pb.validate.go b/pb/organize.pb.validate.go index 186e2e5..ca7dd84 100644 --- a/pb/organize.pb.validate.go +++ b/pb/organize.pb.validate.go @@ -134,6 +134,8 @@ func (m *Menu) validate(all bool) error { errors = append(errors, err) } + // no validation rules for Position + if len(errors) > 0 { return MenuMultiError(errors) } @@ -372,6 +374,10 @@ func (m *Permission) validate(all bool) error { // no validation rules for Id + // no validation rules for CreatedAt + + // no validation rules for UpdatedAt + // no validation rules for Menu if utf8.RuneCountInString(m.GetPermission()) > 60 { @@ -3372,6 +3378,148 @@ var _ interface { ErrorName() string } = DepartmentLabelValueValidationError{} +// Validate checks the field values on DepartmentUserValue with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DepartmentUserValue) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DepartmentUserValue with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DepartmentUserValueMultiError, or nil if none found. +func (m *DepartmentUserValue) ValidateAll() error { + return m.validate(true) +} + +func (m *DepartmentUserValue) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Label + + // no validation rules for Value + + // no validation rules for Isuser + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentUserValueValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentUserValueValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentUserValueValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return DepartmentUserValueMultiError(errors) + } + + return nil +} + +// DepartmentUserValueMultiError is an error wrapping multiple validation +// errors returned by DepartmentUserValue.ValidateAll() if the designated +// constraints aren't met. +type DepartmentUserValueMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DepartmentUserValueMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DepartmentUserValueMultiError) AllErrors() []error { return m } + +// DepartmentUserValueValidationError is the validation error returned by +// DepartmentUserValue.Validate if the designated constraints aren't met. +type DepartmentUserValueValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DepartmentUserValueValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DepartmentUserValueValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DepartmentUserValueValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DepartmentUserValueValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DepartmentUserValueValidationError) ErrorName() string { + return "DepartmentUserValueValidationError" +} + +// Error satisfies the builtin error interface +func (e DepartmentUserValueValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDepartmentUserValue.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DepartmentUserValueValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DepartmentUserValueValidationError{} + // Validate checks the field values on GetDepartmentLabelRequest with the rules // defined in the proto definition for this message. If any rules are // violated, the first error encountered is returned, or nil if there are no violations. @@ -3610,6 +3758,626 @@ var _ interface { ErrorName() string } = GetDepartmentLabelResponseValidationError{} +// Validate checks the field values on GetDepartmentUserRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *GetDepartmentUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetDepartmentUserRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetDepartmentUserRequestMultiError, or nil if none found. +func (m *GetDepartmentUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetDepartmentUserRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetDepartmentUserRequestMultiError(errors) + } + + return nil +} + +// GetDepartmentUserRequestMultiError is an error wrapping multiple validation +// errors returned by GetDepartmentUserRequest.ValidateAll() if the designated +// constraints aren't met. +type GetDepartmentUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetDepartmentUserRequestMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetDepartmentUserRequestMultiError) AllErrors() []error { return m } + +// GetDepartmentUserRequestValidationError is the validation error returned by +// GetDepartmentUserRequest.Validate if the designated constraints aren't met. +type GetDepartmentUserRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetDepartmentUserRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetDepartmentUserRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetDepartmentUserRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetDepartmentUserRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetDepartmentUserRequestValidationError) ErrorName() string { + return "GetDepartmentUserRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetDepartmentUserRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetDepartmentUserRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetDepartmentUserRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetDepartmentUserRequestValidationError{} + +// Validate checks the field values on GetDepartmentUserResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *GetDepartmentUserResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetDepartmentUserResponse with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetDepartmentUserResponseMultiError, or nil if none found. +func (m *GetDepartmentUserResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetDepartmentUserResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetData() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetDepartmentUserResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetDepartmentUserResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetDepartmentUserResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return GetDepartmentUserResponseMultiError(errors) + } + + return nil +} + +// GetDepartmentUserResponseMultiError is an error wrapping multiple validation +// errors returned by GetDepartmentUserResponse.ValidateAll() if the +// designated constraints aren't met. +type GetDepartmentUserResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetDepartmentUserResponseMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetDepartmentUserResponseMultiError) AllErrors() []error { return m } + +// GetDepartmentUserResponseValidationError is the validation error returned by +// GetDepartmentUserResponse.Validate if the designated constraints aren't met. +type GetDepartmentUserResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetDepartmentUserResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetDepartmentUserResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetDepartmentUserResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetDepartmentUserResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetDepartmentUserResponseValidationError) ErrorName() string { + return "GetDepartmentUserResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetDepartmentUserResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetDepartmentUserResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetDepartmentUserResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetDepartmentUserResponseValidationError{} + +// Validate checks the field values on DepartmentLevelValue with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DepartmentLevelValue) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DepartmentLevelValue with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DepartmentLevelValueMultiError, or nil if none found. +func (m *DepartmentLevelValue) ValidateAll() error { + return m.validate(true) +} + +func (m *DepartmentLevelValue) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Label + + // no validation rules for Value + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentLevelValueValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentLevelValueValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentLevelValueValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return DepartmentLevelValueMultiError(errors) + } + + return nil +} + +// DepartmentLevelValueMultiError is an error wrapping multiple validation +// errors returned by DepartmentLevelValue.ValidateAll() if the designated +// constraints aren't met. +type DepartmentLevelValueMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DepartmentLevelValueMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DepartmentLevelValueMultiError) AllErrors() []error { return m } + +// DepartmentLevelValueValidationError is the validation error returned by +// DepartmentLevelValue.Validate if the designated constraints aren't met. +type DepartmentLevelValueValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DepartmentLevelValueValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DepartmentLevelValueValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DepartmentLevelValueValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DepartmentLevelValueValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DepartmentLevelValueValidationError) ErrorName() string { + return "DepartmentLevelValueValidationError" +} + +// Error satisfies the builtin error interface +func (e DepartmentLevelValueValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDepartmentLevelValue.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DepartmentLevelValueValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DepartmentLevelValueValidationError{} + +// Validate checks the field values on GetDepartmentLevelLabelsRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *GetDepartmentLevelLabelsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetDepartmentLevelLabelsRequest with +// the rules defined in the proto definition for this message. If any rules +// are violated, the result is a list of violation errors wrapped in +// GetDepartmentLevelLabelsRequestMultiError, or nil if none found. +func (m *GetDepartmentLevelLabelsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetDepartmentLevelLabelsRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetDepartmentLevelLabelsRequestMultiError(errors) + } + + return nil +} + +// GetDepartmentLevelLabelsRequestMultiError is an error wrapping multiple +// validation errors returned by GetDepartmentLevelLabelsRequest.ValidateAll() +// if the designated constraints aren't met. +type GetDepartmentLevelLabelsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetDepartmentLevelLabelsRequestMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetDepartmentLevelLabelsRequestMultiError) AllErrors() []error { return m } + +// GetDepartmentLevelLabelsRequestValidationError is the validation error +// returned by GetDepartmentLevelLabelsRequest.Validate if the designated +// constraints aren't met. +type GetDepartmentLevelLabelsRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetDepartmentLevelLabelsRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetDepartmentLevelLabelsRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetDepartmentLevelLabelsRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetDepartmentLevelLabelsRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetDepartmentLevelLabelsRequestValidationError) ErrorName() string { + return "GetDepartmentLevelLabelsRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetDepartmentLevelLabelsRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetDepartmentLevelLabelsRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetDepartmentLevelLabelsRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetDepartmentLevelLabelsRequestValidationError{} + +// Validate checks the field values on GetDepartmentLevelLabelsResponse with +// the rules defined in the proto definition for this message. If any rules +// are violated, the first error encountered is returned, or nil if there are +// no violations. +func (m *GetDepartmentLevelLabelsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetDepartmentLevelLabelsResponse with +// the rules defined in the proto definition for this message. If any rules +// are violated, the result is a list of violation errors wrapped in +// GetDepartmentLevelLabelsResponseMultiError, or nil if none found. +func (m *GetDepartmentLevelLabelsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetDepartmentLevelLabelsResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetData() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetDepartmentLevelLabelsResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetDepartmentLevelLabelsResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetDepartmentLevelLabelsResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return GetDepartmentLevelLabelsResponseMultiError(errors) + } + + return nil +} + +// GetDepartmentLevelLabelsResponseMultiError is an error wrapping multiple +// validation errors returned by +// GetDepartmentLevelLabelsResponse.ValidateAll() if the designated +// constraints aren't met. +type GetDepartmentLevelLabelsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetDepartmentLevelLabelsResponseMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetDepartmentLevelLabelsResponseMultiError) AllErrors() []error { return m } + +// GetDepartmentLevelLabelsResponseValidationError is the validation error +// returned by GetDepartmentLevelLabelsResponse.Validate if the designated +// constraints aren't met. +type GetDepartmentLevelLabelsResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetDepartmentLevelLabelsResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetDepartmentLevelLabelsResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetDepartmentLevelLabelsResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetDepartmentLevelLabelsResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetDepartmentLevelLabelsResponseValidationError) ErrorName() string { + return "GetDepartmentLevelLabelsResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetDepartmentLevelLabelsResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetDepartmentLevelLabelsResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetDepartmentLevelLabelsResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetDepartmentLevelLabelsResponseValidationError{} + // Validate checks the field values on GetRoleLabelRequest with the rules // defined in the proto definition for this message. If any rules are // violated, the first error encountered is returned, or nil if there are no violations. @@ -4264,6 +5032,382 @@ var _ interface { ErrorName() string } = SaveRolePermissionResponseValidationError{} +// Validate checks the field values on MenuLevelValue with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *MenuLevelValue) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on MenuLevelValue with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in MenuLevelValueMultiError, +// or nil if none found. +func (m *MenuLevelValue) ValidateAll() error { + return m.validate(true) +} + +func (m *MenuLevelValue) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Label + + // no validation rules for Value + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuLevelValueValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuLevelValueValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuLevelValueValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return MenuLevelValueMultiError(errors) + } + + return nil +} + +// MenuLevelValueMultiError is an error wrapping multiple validation errors +// returned by MenuLevelValue.ValidateAll() if the designated constraints +// aren't met. +type MenuLevelValueMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m MenuLevelValueMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m MenuLevelValueMultiError) AllErrors() []error { return m } + +// MenuLevelValueValidationError is the validation error returned by +// MenuLevelValue.Validate if the designated constraints aren't met. +type MenuLevelValueValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e MenuLevelValueValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e MenuLevelValueValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e MenuLevelValueValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e MenuLevelValueValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e MenuLevelValueValidationError) ErrorName() string { return "MenuLevelValueValidationError" } + +// Error satisfies the builtin error interface +func (e MenuLevelValueValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sMenuLevelValue.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = MenuLevelValueValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = MenuLevelValueValidationError{} + +// Validate checks the field values on GetMenuLevelLabelsRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *GetMenuLevelLabelsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetMenuLevelLabelsRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetMenuLevelLabelsRequestMultiError, or nil if none found. +func (m *GetMenuLevelLabelsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetMenuLevelLabelsRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetMenuLevelLabelsRequestMultiError(errors) + } + + return nil +} + +// GetMenuLevelLabelsRequestMultiError is an error wrapping multiple validation +// errors returned by GetMenuLevelLabelsRequest.ValidateAll() if the +// designated constraints aren't met. +type GetMenuLevelLabelsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetMenuLevelLabelsRequestMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetMenuLevelLabelsRequestMultiError) AllErrors() []error { return m } + +// GetMenuLevelLabelsRequestValidationError is the validation error returned by +// GetMenuLevelLabelsRequest.Validate if the designated constraints aren't met. +type GetMenuLevelLabelsRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetMenuLevelLabelsRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetMenuLevelLabelsRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetMenuLevelLabelsRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetMenuLevelLabelsRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetMenuLevelLabelsRequestValidationError) ErrorName() string { + return "GetMenuLevelLabelsRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetMenuLevelLabelsRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetMenuLevelLabelsRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetMenuLevelLabelsRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetMenuLevelLabelsRequestValidationError{} + +// Validate checks the field values on GetMenuLevelLabelsResponse with the +// rules defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *GetMenuLevelLabelsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetMenuLevelLabelsResponse with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetMenuLevelLabelsResponseMultiError, or nil if none found. +func (m *GetMenuLevelLabelsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetMenuLevelLabelsResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetData() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetMenuLevelLabelsResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetMenuLevelLabelsResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetMenuLevelLabelsResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return GetMenuLevelLabelsResponseMultiError(errors) + } + + return nil +} + +// GetMenuLevelLabelsResponseMultiError is an error wrapping multiple +// validation errors returned by GetMenuLevelLabelsResponse.ValidateAll() if +// the designated constraints aren't met. +type GetMenuLevelLabelsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetMenuLevelLabelsResponseMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetMenuLevelLabelsResponseMultiError) AllErrors() []error { return m } + +// GetMenuLevelLabelsResponseValidationError is the validation error returned +// by GetMenuLevelLabelsResponse.Validate if the designated constraints aren't met. +type GetMenuLevelLabelsResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetMenuLevelLabelsResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetMenuLevelLabelsResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetMenuLevelLabelsResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetMenuLevelLabelsResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetMenuLevelLabelsResponseValidationError) ErrorName() string { + return "GetMenuLevelLabelsResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetMenuLevelLabelsResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetMenuLevelLabelsResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetMenuLevelLabelsResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetMenuLevelLabelsResponseValidationError{} + // Validate checks the field values on LoginRequest with the rules defined in // the proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. diff --git a/pb/organize.proto b/pb/organize.proto index 7ad699f..3b4b5b8 100644 --- a/pb/organize.proto +++ b/pb/organize.proto @@ -17,7 +17,7 @@ message Menu { int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment:"菜单ID"}]; int64 created_at = 2 [(aeus.field)={scenarios:"view;export",comment:"创建时间"}]; int64 updated_at = 3 [(aeus.field)={gorm:"index",scenarios:"view;export",comment:"更新时间"}]; - string parent = 4 [(aeus.field)={gorm:"index;size:60",props:"readonly:update",comment:"父级菜单"}]; + string parent = 4 [(aeus.field)={gorm:"index;size:60",props:"readonly:update",live:"type:dropdown;url:/menu/level-labels",format:"menu",comment:"父级菜单"}]; string name = 5 [(aeus.field)={gorm:"index;size:60",props:"readonly:update",rule:"unique;required",comment: "组件名称"},(validate.rules).string = {max_len: 60}]; string label = 6 [(aeus.field)={gorm:"size:120",rule:"required",comment: "菜单标题"},(validate.rules).string = {max_len: 120}]; string uri = 7 [(aeus.field)={gorm:"size:512",rule:"required",scenarios:"create;update;view;export",comment: "菜单链接"},(validate.rules).string = {max_len: 512}]; @@ -26,6 +26,7 @@ message Menu { bool hidden = 10 [(aeus.field)={scenarios:"create;update;view;export",comment:"是否隐藏"}]; bool public = 11 [(aeus.field)={scenarios:"create;update;view;export",comment:"是否公开"}]; string description = 12 [(aeus.field)={gorm:"size:1024",scenarios:"create;update;view;export;list",format:"textarea",comment: "备注说明"},(validate.rules).string = {max_len: 1024}]; + int64 position = 13 [(aeus.field)={comment:"排序",scenarios:"create;update"}]; } // Role 角色模型定义 @@ -47,9 +48,11 @@ message Permission { table: "permissions" }; int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment: "权限ID"}]; - string menu = 2 [(aeus.field)={gorm:"index;size:60",rule:"required",comment: "所属菜单"}]; - string permission = 3 [(aeus.field)={gorm:"index;size:60",rule:"required",comment: "权限名称"},(validate.rules).string = {max_len: 60}]; - string label = 4 [(aeus.field)={gorm:"size:60",rule:"required",comment: "权限标题"},(validate.rules).string = {max_len: 60}]; + int64 created_at = 2 [(aeus.field)={scenarios:"view;export",comment:"创建时间"}]; + int64 updated_at = 3 [(aeus.field)={gorm:"index",scenarios:"view;export",comment:"更新时间"}]; + string menu = 4 [(aeus.field)={gorm:"index;size:60",format:"menu",rule:"required",comment: "所属菜单"}]; + string permission = 5 [(aeus.field)={gorm:"index;size:60",rule:"required",comment: "权限名称"},(validate.rules).string = {max_len: 60}]; + string label = 6 [(aeus.field)={gorm:"size:60",rule:"required",comment: "权限标题"},(validate.rules).string = {max_len: 60}]; } // RolePermission 角色权限关联表 @@ -92,7 +95,7 @@ message Department { int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment:"ID"}]; int64 created_at = 2 [(aeus.field)={scenarios:"view;export",comment:"创建时间"}]; int64 updated_at = 3 [(aeus.field)={gorm:"index",scenarios:"view;export",comment:"更新时间"}]; - int64 parent_id = 4 [(aeus.field)={format:"department",comment:"父级部门"}]; + int64 parent_id = 4 [(aeus.field)={live:"type:dropdown;url:/department/level-labels",format:"department",comment:"父级部门"}]; string name = 5 [(aeus.field)={gorm:"size:20",rule:"required",comment: "部门名称"},(validate.rules).string = {max_len: 20}]; string description = 6 [(aeus.field)={gorm:"size:1024",scenarios:"create;update;view;export;list",format:"textarea",comment: "备注说明"},(validate.rules).string = {max_len: 1024}]; } @@ -289,6 +292,13 @@ message DepartmentLabelValue { int64 value = 2; } +message DepartmentUserValue { + string label = 1; + string value = 2; + bool isuser = 3; + repeated DepartmentUserValue children = 4; +} + message GetDepartmentLabelRequest { } @@ -296,6 +306,26 @@ message GetDepartmentLabelResponse { repeated DepartmentLabelValue data = 1; } +message GetDepartmentUserRequest { +} + +message GetDepartmentUserResponse { + repeated DepartmentUserValue data = 1; +} + +message DepartmentLevelValue { + string label = 1; + int64 value = 2; + repeated DepartmentLevelValue children = 4; +} + +message GetDepartmentLevelLabelsRequest { +} + +message GetDepartmentLevelLabelsResponse { + repeated DepartmentLevelValue data = 1; +} + service DepartmentService { // 获取部门标签 rpc GetDepartmentLabels(GetDepartmentLabelRequest) returns (GetDepartmentLabelResponse) { @@ -303,6 +333,16 @@ service DepartmentService { get: "/department/labels" }; } + rpc GetDepartmentUsers(GetDepartmentUserRequest) returns (GetDepartmentUserResponse) { + option (google.api.http) = { + get: "/department/users" + }; + } + rpc GetDepartmentLevelLabels(GetDepartmentLevelLabelsRequest) returns (GetDepartmentLevelLabelsResponse) { + option (google.api.http) = { + get: "/department/level-labels" + }; + } } message GetRoleLabelRequest { @@ -352,6 +392,27 @@ service RoleService { } } +message MenuLevelValue { + string label = 1; + string value = 2; + repeated MenuLevelValue children = 4; +} + +message GetMenuLevelLabelsRequest { +} + +message GetMenuLevelLabelsResponse { + repeated MenuLevelValue data = 1; +} + +service MenuService { + rpc GetMenuLevelLabels(GetMenuLevelLabelsRequest) returns (GetMenuLevelLabelsResponse) { + option (google.api.http) = { + get: "/menu/level-labels" + }; + } +} + message LoginRequest { string username = 1; diff --git a/pb/organize_grpc.pb.go b/pb/organize_grpc.pb.go index 7a55e19..90171b7 100644 --- a/pb/organize_grpc.pb.go +++ b/pb/organize_grpc.pb.go @@ -367,7 +367,9 @@ var UserService_ServiceDesc = grpc.ServiceDesc{ } const ( - DepartmentService_GetDepartmentLabels_FullMethodName = "/organize.DepartmentService/GetDepartmentLabels" + DepartmentService_GetDepartmentLabels_FullMethodName = "/organize.DepartmentService/GetDepartmentLabels" + DepartmentService_GetDepartmentUsers_FullMethodName = "/organize.DepartmentService/GetDepartmentUsers" + DepartmentService_GetDepartmentLevelLabels_FullMethodName = "/organize.DepartmentService/GetDepartmentLevelLabels" ) // DepartmentServiceClient is the client API for DepartmentService service. @@ -376,6 +378,8 @@ const ( type DepartmentServiceClient interface { // 获取部门标签 GetDepartmentLabels(ctx context.Context, in *GetDepartmentLabelRequest, opts ...grpc.CallOption) (*GetDepartmentLabelResponse, error) + GetDepartmentUsers(ctx context.Context, in *GetDepartmentUserRequest, opts ...grpc.CallOption) (*GetDepartmentUserResponse, error) + GetDepartmentLevelLabels(ctx context.Context, in *GetDepartmentLevelLabelsRequest, opts ...grpc.CallOption) (*GetDepartmentLevelLabelsResponse, error) } type departmentServiceClient struct { @@ -396,12 +400,34 @@ func (c *departmentServiceClient) GetDepartmentLabels(ctx context.Context, in *G return out, nil } +func (c *departmentServiceClient) GetDepartmentUsers(ctx context.Context, in *GetDepartmentUserRequest, opts ...grpc.CallOption) (*GetDepartmentUserResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetDepartmentUserResponse) + err := c.cc.Invoke(ctx, DepartmentService_GetDepartmentUsers_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *departmentServiceClient) GetDepartmentLevelLabels(ctx context.Context, in *GetDepartmentLevelLabelsRequest, opts ...grpc.CallOption) (*GetDepartmentLevelLabelsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetDepartmentLevelLabelsResponse) + err := c.cc.Invoke(ctx, DepartmentService_GetDepartmentLevelLabels_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // DepartmentServiceServer is the server API for DepartmentService service. // All implementations must embed UnimplementedDepartmentServiceServer // for forward compatibility. type DepartmentServiceServer interface { // 获取部门标签 GetDepartmentLabels(context.Context, *GetDepartmentLabelRequest) (*GetDepartmentLabelResponse, error) + GetDepartmentUsers(context.Context, *GetDepartmentUserRequest) (*GetDepartmentUserResponse, error) + GetDepartmentLevelLabels(context.Context, *GetDepartmentLevelLabelsRequest) (*GetDepartmentLevelLabelsResponse, error) mustEmbedUnimplementedDepartmentServiceServer() } @@ -415,6 +441,12 @@ type UnimplementedDepartmentServiceServer struct{} func (UnimplementedDepartmentServiceServer) GetDepartmentLabels(context.Context, *GetDepartmentLabelRequest) (*GetDepartmentLabelResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetDepartmentLabels not implemented") } +func (UnimplementedDepartmentServiceServer) GetDepartmentUsers(context.Context, *GetDepartmentUserRequest) (*GetDepartmentUserResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetDepartmentUsers not implemented") +} +func (UnimplementedDepartmentServiceServer) GetDepartmentLevelLabels(context.Context, *GetDepartmentLevelLabelsRequest) (*GetDepartmentLevelLabelsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetDepartmentLevelLabels not implemented") +} func (UnimplementedDepartmentServiceServer) mustEmbedUnimplementedDepartmentServiceServer() {} func (UnimplementedDepartmentServiceServer) testEmbeddedByValue() {} @@ -454,6 +486,42 @@ func _DepartmentService_GetDepartmentLabels_Handler(srv interface{}, ctx context return interceptor(ctx, in, info, handler) } +func _DepartmentService_GetDepartmentUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetDepartmentUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DepartmentServiceServer).GetDepartmentUsers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DepartmentService_GetDepartmentUsers_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DepartmentServiceServer).GetDepartmentUsers(ctx, req.(*GetDepartmentUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DepartmentService_GetDepartmentLevelLabels_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetDepartmentLevelLabelsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DepartmentServiceServer).GetDepartmentLevelLabels(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DepartmentService_GetDepartmentLevelLabels_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DepartmentServiceServer).GetDepartmentLevelLabels(ctx, req.(*GetDepartmentLevelLabelsRequest)) + } + return interceptor(ctx, in, info, handler) +} + // DepartmentService_ServiceDesc is the grpc.ServiceDesc for DepartmentService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -465,6 +533,14 @@ var DepartmentService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetDepartmentLabels", Handler: _DepartmentService_GetDepartmentLabels_Handler, }, + { + MethodName: "GetDepartmentUsers", + Handler: _DepartmentService_GetDepartmentUsers_Handler, + }, + { + MethodName: "GetDepartmentLevelLabels", + Handler: _DepartmentService_GetDepartmentLevelLabels_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "organize.proto", @@ -652,6 +728,108 @@ var RoleService_ServiceDesc = grpc.ServiceDesc{ Metadata: "organize.proto", } +const ( + MenuService_GetMenuLevelLabels_FullMethodName = "/organize.MenuService/GetMenuLevelLabels" +) + +// MenuServiceClient is the client API for MenuService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type MenuServiceClient interface { + GetMenuLevelLabels(ctx context.Context, in *GetMenuLevelLabelsRequest, opts ...grpc.CallOption) (*GetMenuLevelLabelsResponse, error) +} + +type menuServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewMenuServiceClient(cc grpc.ClientConnInterface) MenuServiceClient { + return &menuServiceClient{cc} +} + +func (c *menuServiceClient) GetMenuLevelLabels(ctx context.Context, in *GetMenuLevelLabelsRequest, opts ...grpc.CallOption) (*GetMenuLevelLabelsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetMenuLevelLabelsResponse) + err := c.cc.Invoke(ctx, MenuService_GetMenuLevelLabels_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MenuServiceServer is the server API for MenuService service. +// All implementations must embed UnimplementedMenuServiceServer +// for forward compatibility. +type MenuServiceServer interface { + GetMenuLevelLabels(context.Context, *GetMenuLevelLabelsRequest) (*GetMenuLevelLabelsResponse, error) + mustEmbedUnimplementedMenuServiceServer() +} + +// UnimplementedMenuServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedMenuServiceServer struct{} + +func (UnimplementedMenuServiceServer) GetMenuLevelLabels(context.Context, *GetMenuLevelLabelsRequest) (*GetMenuLevelLabelsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetMenuLevelLabels not implemented") +} +func (UnimplementedMenuServiceServer) mustEmbedUnimplementedMenuServiceServer() {} +func (UnimplementedMenuServiceServer) testEmbeddedByValue() {} + +// UnsafeMenuServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to MenuServiceServer will +// result in compilation errors. +type UnsafeMenuServiceServer interface { + mustEmbedUnimplementedMenuServiceServer() +} + +func RegisterMenuServiceServer(s grpc.ServiceRegistrar, srv MenuServiceServer) { + // If the following call pancis, it indicates UnimplementedMenuServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&MenuService_ServiceDesc, srv) +} + +func _MenuService_GetMenuLevelLabels_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetMenuLevelLabelsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MenuServiceServer).GetMenuLevelLabels(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: MenuService_GetMenuLevelLabels_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MenuServiceServer).GetMenuLevelLabels(ctx, req.(*GetMenuLevelLabelsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// MenuService_ServiceDesc is the grpc.ServiceDesc for MenuService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var MenuService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "organize.MenuService", + HandlerType: (*MenuServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetMenuLevelLabels", + Handler: _MenuService_GetMenuLevelLabels_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "organize.proto", +} + const ( AuthService_Login_FullMethodName = "/organize.AuthService/Login" AuthService_Logout_FullMethodName = "/organize.AuthService/Logout" diff --git a/pb/organize_http.pb.go b/pb/organize_http.pb.go index c35df26..06bfc9f 100644 --- a/pb/organize_http.pb.go +++ b/pb/organize_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-aeus. DO NOT EDIT. // source: organize.proto -// date: 2025-06-17 18:12:28 +// date: 2025-06-18 14:37:24 package pb @@ -28,6 +28,10 @@ type UserServiceHttpServer interface { type DepartmentServiceHttpServer interface { GetDepartmentLabels(context.Context, *GetDepartmentLabelRequest) (*GetDepartmentLabelResponse, error) + + GetDepartmentUsers(context.Context, *GetDepartmentUserRequest) (*GetDepartmentUserResponse, error) + + GetDepartmentLevelLabels(context.Context, *GetDepartmentLevelLabelsRequest) (*GetDepartmentLevelLabelsResponse, error) } type RoleServiceHttpServer interface { @@ -38,6 +42,10 @@ type RoleServiceHttpServer interface { SaveRolePermission(context.Context, *SaveRolePermissionRequest) (*SaveRolePermissionResponse, error) } +type MenuServiceHttpServer interface { + GetMenuLevelLabels(context.Context, *GetMenuLevelLabelsRequest) (*GetMenuLevelLabelsResponse, error) +} + type AuthServiceHttpServer interface { Login(context.Context, *LoginRequest) (*LoginResponse, error) @@ -212,6 +220,38 @@ func handleDepartmentServiceGetDepartmentLabels(s DepartmentServiceHttpServer) h } } +func handleDepartmentServiceGetDepartmentUsers(s DepartmentServiceHttpServer) http.HandleFunc { + return func(ctx *http.Context) (err error) { + req := &GetDepartmentUserRequest{} + + if res, err := s.GetDepartmentUsers(ctx.Context(), req); err != nil { + if er, ok := err.(*errors.Error); ok { + return ctx.Error(er.Code, er.Message) + } else { + return ctx.Error(errors.Unavailable, err.Error()) + } + } else { + return ctx.Success(res) + } + } +} + +func handleDepartmentServiceGetDepartmentLevelLabels(s DepartmentServiceHttpServer) http.HandleFunc { + return func(ctx *http.Context) (err error) { + req := &GetDepartmentLevelLabelsRequest{} + + if res, err := s.GetDepartmentLevelLabels(ctx.Context(), req); err != nil { + if er, ok := err.(*errors.Error); ok { + return ctx.Error(er.Code, er.Message) + } else { + return ctx.Error(errors.Unavailable, err.Error()) + } + } else { + return ctx.Success(res) + } + } +} + // 获取角色标签 func handleRoleServiceGetRoleLabels(s RoleServiceHttpServer) http.HandleFunc { @@ -272,6 +312,22 @@ func handleRoleServiceSaveRolePermission(s RoleServiceHttpServer) http.HandleFun } } +func handleMenuServiceGetMenuLevelLabels(s MenuServiceHttpServer) http.HandleFunc { + return func(ctx *http.Context) (err error) { + req := &GetMenuLevelLabelsRequest{} + + if res, err := s.GetMenuLevelLabels(ctx.Context(), req); err != nil { + if er, ok := err.(*errors.Error); ok { + return ctx.Error(er.Code, er.Message) + } else { + return ctx.Error(errors.Unavailable, err.Error()) + } + } else { + return ctx.Success(res) + } + } +} + func handleAuthServiceLogin(s AuthServiceHttpServer) http.HandleFunc { return func(ctx *http.Context) (err error) { req := &LoginRequest{} @@ -358,6 +414,12 @@ func RegisterDepartmentServiceRouter(hs *http.Server, s DepartmentServiceHttpSer // Register handle GetDepartmentLabels route hs.GET("/department/labels", handleDepartmentServiceGetDepartmentLabels(s)) + // Register handle GetDepartmentUsers route + hs.GET("/department/users", handleDepartmentServiceGetDepartmentUsers(s)) + + // Register handle GetDepartmentLevelLabels route + hs.GET("/department/level-labels", handleDepartmentServiceGetDepartmentLevelLabels(s)) + } func RegisterRoleServiceRouter(hs *http.Server, s RoleServiceHttpServer) { @@ -373,6 +435,13 @@ func RegisterRoleServiceRouter(hs *http.Server, s RoleServiceHttpServer) { } +func RegisterMenuServiceRouter(hs *http.Server, s MenuServiceHttpServer) { + + // Register handle GetMenuLevelLabels route + hs.GET("/menu/level-labels", handleMenuServiceGetMenuLevelLabels(s)) + +} + func RegisterAuthServiceRouter(hs *http.Server, s AuthServiceHttpServer) { // Register handle Login route diff --git a/pb/organize_model.pb.go b/pb/organize_model.pb.go index 63c3650..6eb24ad 100644 --- a/pb/organize_model.pb.go +++ b/pb/organize_model.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-aeus. DO NOT EDIT. // source: organize.proto -// date: 2025-06-17 18:12:28 +// date: 2025-06-18 14:37:24 package pb @@ -12,7 +12,7 @@ type MenuModel struct { Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"菜单ID"` CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"view;export"` UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index" comment:"更新时间" scenarios:"view;export"` - Parent string `json:"parent" yaml:"parent" xml:"parent" gorm:"index;size:60" comment:"父级菜单" props:"readonly:update"` + Parent string `json:"parent" yaml:"parent" xml:"parent" gorm:"index;size:60" comment:"父级菜单" format:"menu" props:"readonly:update" live:"type:dropdown;url:/menu/level-labels"` Name string `json:"name" yaml:"name" xml:"name" gorm:"index;size:60" comment:"组件名称" props:"readonly:update" rule:"unique;required"` Label string `json:"label" yaml:"label" xml:"label" gorm:"size:120" comment:"菜单标题" rule:"required"` Uri string `json:"uri" yaml:"uri" xml:"uri" gorm:"size:512" comment:"菜单链接" scenarios:"create;update;view;export" rule:"required"` @@ -21,6 +21,7 @@ type MenuModel struct { Hidden bool `json:"hidden" yaml:"hidden" xml:"hidden" comment:"是否隐藏" scenarios:"create;update;view;export"` Public bool `json:"public" yaml:"public" xml:"public" comment:"是否公开" scenarios:"create;update;view;export"` Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" scenarios:"create;update;view;export;list" format:"textarea"` + Position int64 `json:"position" yaml:"position" xml:"position" comment:"排序" scenarios:"create;update"` } func (m *MenuModel) TableName() string { @@ -40,6 +41,7 @@ func (m *MenuModel) FromValue(x *Menu) { m.Hidden = x.Hidden m.Public = x.Public m.Description = x.Description + m.Position = x.Position } func (m *MenuModel) ToValue() (x *Menu) { @@ -56,6 +58,7 @@ func (m *MenuModel) ToValue() (x *Menu) { x.Hidden = m.Hidden x.Public = m.Public x.Description = m.Description + x.Position = m.Position return x } @@ -76,7 +79,7 @@ func (m *MenuModel) Delete(db *gorm.DB) (err error) { } func (m *MenuModel) Find(db *gorm.DB, pk any) (err error) { - return db.Where("description=?", pk).First(m).Error + return db.Where("position=?", pk).First(m).Error } func (m *MenuModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { @@ -158,7 +161,9 @@ func NewRoleModel() *RoleModel { type PermissionModel struct { Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"权限ID"` - Menu string `json:"menu" yaml:"menu" xml:"menu" gorm:"index;size:60" comment:"所属菜单" rule:"required"` + CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"view;export"` + UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index" comment:"更新时间" scenarios:"view;export"` + Menu string `json:"menu" yaml:"menu" xml:"menu" gorm:"index;size:60" comment:"所属菜单" format:"menu" rule:"required"` Permission string `json:"permission" yaml:"permission" xml:"permission" gorm:"index;size:60" comment:"权限名称" rule:"required"` Label string `json:"label" yaml:"label" xml:"label" gorm:"size:60" comment:"权限标题" rule:"required"` } @@ -169,6 +174,8 @@ func (m *PermissionModel) TableName() string { func (m *PermissionModel) FromValue(x *Permission) { m.Id = x.Id + m.CreatedAt = x.CreatedAt + m.UpdatedAt = x.UpdatedAt m.Menu = x.Menu m.Permission = x.Permission m.Label = x.Label @@ -177,6 +184,8 @@ func (m *PermissionModel) FromValue(x *Permission) { func (m *PermissionModel) ToValue() (x *Permission) { x = &Permission{} x.Id = m.Id + x.CreatedAt = m.CreatedAt + x.UpdatedAt = m.UpdatedAt x.Menu = m.Menu x.Permission = m.Permission x.Label = m.Label @@ -367,7 +376,7 @@ type DepartmentModel struct { Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"ID"` CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"view;export"` UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index" comment:"更新时间" scenarios:"view;export"` - ParentId int64 `json:"parent_id" yaml:"parentId" xml:"parentId" comment:"父级部门" format:"department"` + ParentId int64 `json:"parent_id" yaml:"parentId" xml:"parentId" comment:"父级部门" format:"department" live:"type:dropdown;url:/department/level-labels"` Name string `json:"name" yaml:"name" xml:"name" gorm:"size:20" comment:"部门名称" rule:"required"` Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" scenarios:"create;update;view;export;list" format:"textarea"` } diff --git a/permission.go b/permission.go index dba60a2..f76a178 100644 --- a/permission.go +++ b/permission.go @@ -2,35 +2,19 @@ package aeusadmin import ( "context" - "fmt" "slices" - "time" - "git.nobla.cn/golang/aeus-admin/models" - "git.nobla.cn/golang/aeus-admin/pkg/dbcache" + "git.nobla.cn/golang/aeus-admin/internal/logic" "git.nobla.cn/golang/aeus/middleware/auth" "git.nobla.cn/golang/aeus/pkg/errors" "gorm.io/gorm" ) type PermissionChecker struct { - db *gorm.DB + db *gorm.DB + logic *logic.User } -func (p *PermissionChecker) getUserPermissions(ctx context.Context, uid string) (permissions []string, err error) { - permissions, err = dbcache.TryCache(ctx, fmt.Sprintf("user:permissions:%s", uid), func(tx *gorm.DB) ([]string, error) { - var ss []string - err = tx.Select("permission").Model(&models.RolePermission{}). - Joins("LEFT JOIN users on users.role = role_permissions.role"). - Where("users.uid = ?", uid). - Pluck("permission", &ss). - Error - return ss, err - }, dbcache.WithCacheDuration(time.Minute), dbcache.WithDB(p.db)) - return -} - - func (p *PermissionChecker) CheckPermission(ctx context.Context, permission string) (err error) { var ( uid string @@ -43,7 +27,7 @@ func (p *PermissionChecker) CheckPermission(ctx context.Context, permission stri return } } - if ps, err = p.getUserPermissions(ctx, uid); err != nil { + if ps, err = p.logic.GetPermissions(ctx, uid); err != nil { return } if !slices.Contains(ps, permission) { @@ -54,6 +38,7 @@ func (p *PermissionChecker) CheckPermission(ctx context.Context, permission stri func NewPermissionChecker(db *gorm.DB) *PermissionChecker { return &PermissionChecker{ - db: db, + db: db, + logic: logic.NewUserLogic(db), } } diff --git a/server.go b/server.go index 6fff36d..ac86670 100644 --- a/server.go +++ b/server.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "git.nobla.cn/golang/aeus-admin/defaults" + "git.nobla.cn/golang/aeus-admin/migrate" "git.nobla.cn/golang/aeus-admin/models" "git.nobla.cn/golang/aeus-admin/pkg/dbcache" adminTypes "git.nobla.cn/golang/aeus-admin/types" @@ -100,30 +100,11 @@ func checkModelMenu(db *gorm.DB, viewPath string, apiPrefix string, model *rest. func checkModelPermission(db *gorm.DB, menuName string, scene string, model *rest.Model, translate Translate) (permissionModel *models.Permission, err error) { permissionModel = &models.Permission{} permission := model.Permission(scene) - if err = db.Where("permission = ? AND menu = ?", permission, menuName).First(permissionModel).Error; err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - permissionModel.Menu = menuName - permissionModel.Label = scene - if translate != nil { - permissionModel.Label = translate.Permission(model, scene, permissionModel.Label) - } - permissionModel.Permission = permission - err = db.Create(permissionModel).Error - } - } - return -} - -func replaceModelPermission(db *gorm.DB, menuName string, permission string, label string) (permissionModel *models.Permission, err error) { - permissionModel = &models.Permission{} - if err = db.Where("permission = ? AND menu = ?", permission, menuName).First(permissionModel).Error; err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - permissionModel.Menu = menuName - permissionModel.Label = label - permissionModel.Permission = permission - err = db.Create(permissionModel).Error - } + label := scene + if translate != nil { + label = translate.Permission(model, scene, label) } + permissionModel, err = migrate.Permission(db, menuName, permission, label) return } @@ -148,7 +129,7 @@ func checkModel(opts *options, model *rest.Model) (err error) { modelValue := reflect.New(model.Value().Type()).Interface() if v, ok := modelValue.(adminTypes.PerrmissionModule); ok { for k, v := range v.ModelPermissions() { - if _, err = replaceModelPermission(tx, menuModel.Name, k, v); err != nil { + if _, err = migrate.Permission(tx, menuModel.Name, k, v); err != nil { tx.Rollback() return } @@ -287,7 +268,6 @@ func AutoMigrate(ctx context.Context, db *gorm.DB, model any, cbs ...Option) (er } func registerRESTRoute(domain string, db *gorm.DB, hs *http.Server) { - handleListSchemas := func(ctx *http.Context) (err error) { var ( schemas []*restTypes.Schema @@ -390,7 +370,7 @@ func Init(ctx context.Context, cbs ...Option) (err error) { registerRESTRoute(opts.domain, opts.db, opts.httpServer) } if !opts.disableDefault { - if err = defaults.Generate(opts.db); err != nil { + if err = migrate.Default(opts.db); err != nil { return } } @@ -398,5 +378,8 @@ func Init(ctx context.Context, cbs ...Option) (err error) { //启用操作记录 NewActivityRecorder(ctx, opts.db).Recoder() } + + //注册渲染器 + NewFormatter(opts.db).Register() return } diff --git a/service/auth.go b/service/auth.go index 05ee2a3..49352c2 100644 --- a/service/auth.go +++ b/service/auth.go @@ -1,7 +1,10 @@ package service import ( + "bytes" "context" + "encoding/json" + "net/http" "time" "git.nobla.cn/golang/aeus-admin/models" @@ -16,10 +19,23 @@ import ( type ( authOptions struct { - db *gorm.DB - secret []byte - method string - ttl int64 + db *gorm.DB + secret []byte + method string + ttl int64 + turnstileValidateUrl string + turnstileSiteKey string + } + + turnstileRequest struct { + Secret string `json:"secret"` + Response string `json:"response"` + } + turnstileResponse struct { + Success bool `json:"success"` + Hostname string `json:"hostname"` + ErrorCodes []string `json:"error-codes"` + Action string `json:"action"` } AuthOption func(o *authOptions) @@ -41,6 +57,16 @@ func WithAuthSecret(secret []byte) AuthOption { } } +func WithAuthTranslate(key, url string) AuthOption { + return func(o *authOptions) { + o.turnstileSiteKey = key + if url == "" { + url = "https://challenges.cloudflare.com/turnstile/v0/siteverify" + } + o.turnstileValidateUrl = url + } +} + func WithAuthMethod(method string) AuthOption { return func(o *authOptions) { o.method = method @@ -53,12 +79,56 @@ func WithAuthTTL(ttl int64) AuthOption { } } +func (s *AuthService) turnstileValidate(ctx context.Context, token string) (err error) { + var ( + buf []byte + req *http.Request + res *http.Response + ) + if s.opts.turnstileSiteKey == "" || s.opts.turnstileValidateUrl == "" { + return nil + } + payload := &turnstileRequest{ + Secret: s.opts.turnstileSiteKey, + Response: token, + } + if buf, err = json.Marshal(payload); err != nil { + return + } + if req, err = http.NewRequestWithContext(ctx, http.MethodPost, s.opts.turnstileValidateUrl, bytes.NewReader(buf)); err != nil { + return + } + req.Header.Set("Content-Type", "application/json") + if res, err = http.DefaultClient.Do(req); err != nil { + return + } + defer res.Body.Close() + if res.StatusCode != http.StatusOK { + return errors.Format(errors.Unavailable, "turnstile validate failed") + } + result := &turnstileResponse{} + if err = json.NewDecoder(res.Body).Decode(result); err != nil { + return + } + if !result.Success { + if len(result.ErrorCodes) == 0 { + err = errors.Format(errors.Unavailable, "turnstile validate failed") + } else { + err = errors.Format(errors.Unavailable, result.ErrorCodes[0]) + } + } + return +} + func (s *AuthService) Login(ctx context.Context, req *pb.LoginRequest) (res *pb.LoginResponse, err error) { model := &models.User{} tx := s.opts.db.WithContext(ctx) if err = req.Validate(); err != nil { return nil, errors.Format(errors.Invalid, err.Error()) } + if err = s.turnstileValidate(ctx, req.Token); err != nil { + return nil, errors.Format(errors.Invalid, err.Error()) + } if err = model.FindOne(tx, "uid=?", req.Username); err != nil { return nil, errors.ErrAccessDenied } diff --git a/service/department.go b/service/department.go index dc52f2b..badf7bd 100644 --- a/service/department.go +++ b/service/department.go @@ -3,10 +3,12 @@ package service import ( "context" "fmt" + "strconv" + "git.nobla.cn/golang/aeus-admin/internal/logic" "git.nobla.cn/golang/aeus-admin/models" "git.nobla.cn/golang/aeus-admin/pb" - "git.nobla.cn/golang/aeus-admin/pkg/dbcache" + "git.nobla.cn/golang/rest/types" "gorm.io/gorm" ) @@ -17,7 +19,9 @@ type ( DepartmentOption func(o *departmentOptions) DepartmentService struct { - opts *departmentOptions + opts *departmentOptions + logic *logic.Department + user *logic.User } ) @@ -29,24 +33,87 @@ func WithDepartmentDB(db *gorm.DB) DepartmentOption { func (s *DepartmentService) GetDepartmentLabels(ctx context.Context, req *pb.GetDepartmentLabelRequest) (res *pb.GetDepartmentLabelResponse, err error) { res = &pb.GetDepartmentLabelResponse{} - res.Data, err = dbcache.TryCache(ctx, fmt.Sprintf("department:labels"), func(tx *gorm.DB) ([]*pb.DepartmentLabelValue, error) { - values := make([]*models.Department, 0) - if err = tx.Find(&values).Error; err == nil { - items := make([]*pb.DepartmentLabelValue, 0, len(values)) - for _, v := range values { - items = append(items, &pb.DepartmentLabelValue{ - Label: v.Name, - Value: v.Id, - }) - } - return items, nil - } else { - return nil, err + var values []*types.TypeValue[int64] + if values, err = s.logic.GetLabels(ctx); err == nil { + res.Data = make([]*pb.DepartmentLabelValue, 0, len(values)) + for _, row := range values { + res.Data = append(res.Data, &pb.DepartmentLabelValue{ + Label: row.Label, + Value: row.Value, + }) } - }, - dbcache.WithDB(s.opts.db), - dbcache.WithDependency(dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM departments")), + } + return +} + +func (s *DepartmentService) recursiveDepartmentUser(parent int64, departments []*models.Department, users []*models.User) []*pb.DepartmentUserValue { + values := make([]*pb.DepartmentUserValue, 0, len(departments)) + for _, row := range departments { + if row.ParentId == parent { + item := &pb.DepartmentUserValue{ + Label: row.Name, + Value: strconv.FormatInt(row.Id, 10), + Children: make([]*pb.DepartmentUserValue, 0), + } + item.Children = append(item.Children, s.recursiveDepartmentUser(row.Id, departments, users)...) + for _, v := range users { + if v.DeptId == row.Id { + item.Children = append(item.Children, &pb.DepartmentUserValue{ + Label: fmt.Sprintf("%s(%s)", v.Username, v.Uid), + Value: v.Uid, + Isuser: true, + }) + } + } + values = append(values, item) + } + } + return values +} + +func (s *DepartmentService) recursiveDepartmentLevel(parent int64, departments []*models.Department) []*pb.DepartmentLevelValue { + values := make([]*pb.DepartmentLevelValue, 0, len(departments)) + for _, row := range departments { + if row.ParentId == parent { + item := &pb.DepartmentLevelValue{ + Label: row.Name, + Value: row.Id, + Children: make([]*pb.DepartmentLevelValue, 0), + } + item.Children = append(item.Children, s.recursiveDepartmentLevel(row.Id, departments)...) + values = append(values, item) + } + } + return values +} + +func (s *DepartmentService) GetDepartmentUsers(ctx context.Context, req *pb.GetDepartmentUserRequest) (res *pb.GetDepartmentUserResponse, err error) { + var ( + users []*models.User + departments []*models.Department ) + if departments, err = s.logic.GetDepartments(ctx); err != nil { + return + } + if users, err = s.user.GeUsers(ctx); err != nil { + return + } + res = &pb.GetDepartmentUserResponse{ + Data: s.recursiveDepartmentUser(0, departments, users), + } + return +} + +func (s *DepartmentService) GetDepartmentLevelLabels(ctx context.Context, req *pb.GetDepartmentLevelLabelsRequest) (res *pb.GetDepartmentLevelLabelsResponse, err error) { + var ( + departments []*models.Department + ) + if departments, err = s.logic.GetDepartments(ctx); err != nil { + return + } + res = &pb.GetDepartmentLevelLabelsResponse{ + Data: s.recursiveDepartmentLevel(0, departments), + } return } @@ -56,6 +123,8 @@ func NewDepartmentService(cbs ...DepartmentOption) *DepartmentService { cb(opts) } return &DepartmentService{ - opts: opts, + opts: opts, + user: logic.NewUserLogic(opts.db), + logic: logic.NewDepartmentLogic(opts.db), } } diff --git a/service/menu.go b/service/menu.go new file mode 100644 index 0000000..f29e690 --- /dev/null +++ b/service/menu.go @@ -0,0 +1,68 @@ +package service + +import ( + "context" + + "git.nobla.cn/golang/aeus-admin/internal/logic" + "git.nobla.cn/golang/aeus-admin/models" + "git.nobla.cn/golang/aeus-admin/pb" + "gorm.io/gorm" +) + +type ( + menuOptions struct { + db *gorm.DB + } + MenuOption func(o *menuOptions) + + MenuService struct { + opts *menuOptions + logic *logic.Menu + } +) + +func WithMenuDB(db *gorm.DB) MenuOption { + return func(o *menuOptions) { + o.db = db + } +} + +func (s *MenuService) recursiveMenuLevel(parent string, items []*models.Menu) []*pb.MenuLevelValue { + values := make([]*pb.MenuLevelValue, 0, len(items)) + for _, row := range items { + if row.Parent == parent { + item := &pb.MenuLevelValue{ + Label: row.Label, + Value: row.Name, + Children: make([]*pb.MenuLevelValue, 0), + } + item.Children = append(item.Children, s.recursiveMenuLevel(row.Name, items)...) + values = append(values, item) + } + } + return values +} + +func (s *MenuService) GetMenuLevelLabels(ctx context.Context, req *pb.GetMenuLevelLabelsRequest) (res *pb.GetMenuLevelLabelsResponse, err error) { + var ( + items []*models.Menu + ) + if items, err = s.logic.GetMenus(ctx); err != nil { + return + } + res = &pb.GetMenuLevelLabelsResponse{ + Data: s.recursiveMenuLevel("", items), + } + return +} + +func NewMenuService(cbs ...MenuOption) *MenuService { + opts := &menuOptions{} + for _, cb := range cbs { + cb(opts) + } + return &MenuService{ + opts: opts, + logic: logic.NewMenuLogic(opts.db), + } +} diff --git a/service/role.go b/service/role.go index 6319cc6..b5b3ec1 100644 --- a/service/role.go +++ b/service/role.go @@ -2,11 +2,11 @@ package service import ( "context" - "fmt" + "git.nobla.cn/golang/aeus-admin/internal/logic" "git.nobla.cn/golang/aeus-admin/models" "git.nobla.cn/golang/aeus-admin/pb" - "git.nobla.cn/golang/aeus-admin/pkg/dbcache" + "git.nobla.cn/golang/rest/types" "gorm.io/gorm" ) @@ -17,7 +17,8 @@ type ( RoleOption func(o *roleOptions) RoleService struct { - opts *roleOptions + opts *roleOptions + logic *logic.Role } ) @@ -29,24 +30,16 @@ func WithRoleDB(db *gorm.DB) RoleOption { func (s *RoleService) GetRoleLabels(ctx context.Context, req *pb.GetRoleLabelRequest) (res *pb.GetRoleLabelResponse, err error) { res = &pb.GetRoleLabelResponse{} - res.Data, err = dbcache.TryCache(ctx, fmt.Sprintf("role:labels"), func(tx *gorm.DB) ([]*pb.LabelValue, error) { - values := make([]*models.Role, 0) - if err = tx.Find(&values).Error; err == nil { - items := make([]*pb.LabelValue, 0, len(values)) - for _, v := range values { - items = append(items, &pb.LabelValue{ - Label: v.Label, - Value: v.Name, - }) - } - return items, nil - } else { - return nil, err + var values []*types.TypeValue[string] + if values, err = s.logic.GetLabels(ctx); err == nil { + res.Data = make([]*pb.LabelValue, 0, len(values)) + for _, row := range values { + res.Data = append(res.Data, &pb.LabelValue{ + Label: row.Label, + Value: row.Value, + }) } - }, - dbcache.WithDB(s.opts.db), - dbcache.WithDependency(dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM roles")), - ) + } return } @@ -89,6 +82,7 @@ func NewRoleService(cbs ...RoleOption) *RoleService { cb(opts) } return &RoleService{ - opts: opts, + opts: opts, + logic: logic.NewRoleLogic(opts.db), } } diff --git a/service/user.go b/service/user.go index 0e2e3f9..892dd84 100644 --- a/service/user.go +++ b/service/user.go @@ -3,13 +3,16 @@ package service import ( "context" "fmt" + "strconv" "time" + "git.nobla.cn/golang/aeus-admin/internal/logic" "git.nobla.cn/golang/aeus-admin/models" "git.nobla.cn/golang/aeus-admin/pb" "git.nobla.cn/golang/aeus-admin/pkg/dbcache" "git.nobla.cn/golang/aeus/middleware/auth" "git.nobla.cn/golang/aeus/pkg/errors" + "git.nobla.cn/golang/rest/types" "gorm.io/gorm" ) @@ -21,7 +24,11 @@ type ( UserOption func(o *userOptions) UserService struct { - opts *userOptions + user *logic.User + menu *logic.Menu + role *logic.Role + department *logic.Department + opts *userOptions } ) @@ -87,12 +94,6 @@ func (s *UserService) recursiveNestedMenu(ctx context.Context, parent string, pe return values } -func (s *UserService) getRolePermissions(db *gorm.DB, role string) (permissions []*models.Permission, err error) { - permissions = make([]*models.Permission, 0) - err = db.Where("permission IN (SELECT permission FROM role_permissions WHERE role = ?)", role).Find(&permissions).Error - return -} - func (s *UserService) GetMenus(ctx context.Context, req *pb.GetMenuRequest) (res *pb.GetMenuResponse, err error) { var ( uid string @@ -103,28 +104,28 @@ func (s *UserService) GetMenus(ctx context.Context, req *pb.GetMenuRequest) (res } res = &pb.GetMenuResponse{} res.Data, err = dbcache.TryCache(ctx, fmt.Sprintf("user:menu:%s:%v", uid, req.Permission), func(tx *gorm.DB) ([]*pb.MenuItem, error) { - userModel := &models.User{} + var ( + userModel *models.User + menus []*models.Menu + ) + userModel = &models.User{} if err = tx.Where("uid=?", uid).First(userModel).Error; err != nil { return nil, err } - items := make([]*models.Menu, 0) - if err = tx.Find(&items).Error; err != nil { + if menus, err = s.menu.GetMenus(ctx); err != nil { return nil, err } + roleName := userModel.Role if userModel.Admin { - permissions = make([]*models.Permission, 0) - if err = tx.Find(&permissions).Error; err != nil { - return nil, err - } - } else { - if permissions, err = s.getRolePermissions(tx, userModel.Role); err != nil { - return nil, err - } + roleName = "" } - return s.recursiveNestedMenu(ctx, "", req.Permission, items, permissions), nil + if permissions, err = s.role.GetPermissions(ctx, roleName); err != nil { + return nil, err + } + return s.recursiveNestedMenu(ctx, "", req.Permission, menus, permissions), nil }, dbcache.WithDB(s.opts.db), - dbcache.WithDependency(dbcache.NewSqlDependency("SELECT `updated_at` FROM users WHERE `uid`=?", uid)), + dbcache.WithCacheDuration(time.Second*10), ) return } @@ -145,7 +146,6 @@ func (s *UserService) GetProfile(ctx context.Context, req *pb.GetProfileRequest) }, dbcache.WithDB(s.opts.db), dbcache.WithDependency(dbcache.NewSqlDependency("SELECT `updated_at` FROM users WHERE `uid`=?", req.Uid)), - // dbcache.WithDepend("SELECT `updated_at` FROM users WHERE `uid`=?", req.Uid), ) return } @@ -213,39 +213,57 @@ func (s *UserService) GetPermissions(ctx context.Context, req *pb.GetPermissionR res = &pb.GetPermissionResponse{ Uid: req.Uid, } - res.Permissions, err = dbcache.TryCache(ctx, fmt.Sprintf("user:permissions:%s", req.Uid), func(tx *gorm.DB) ([]string, error) { - var ss []string - err = tx.Select("permission").Model(&models.RolePermission{}). - Joins("LEFT JOIN users on users.role = role_permissions.role"). - Where("users.uid = ?", req.Uid). - Pluck("permission", &ss). - Error - return ss, err - }, dbcache.WithCacheDuration(time.Minute), dbcache.WithDB(s.opts.db)) + res.Permissions, err = s.user.GetPermissions(ctx, req.Uid) return } func (s *UserService) GetUserLabels(ctx context.Context, req *pb.GetUserLabelRequest) (res *pb.GetUserLabelResponse, err error) { res = &pb.GetUserLabelResponse{} - res.Data, err = dbcache.TryCache(ctx, fmt.Sprintf("user:labels"), func(tx *gorm.DB) ([]*pb.LabelValue, error) { - values := make([]*models.User, 0) - if err = tx.Find(&values).Error; err == nil { - items := make([]*pb.LabelValue, 0, len(values)) - for _, v := range values { - items = append(items, &pb.LabelValue{ - Label: v.Username, - Value: v.Uid, + var values []*types.TypeValue[string] + if values, err = s.user.GetLabels(ctx); err == nil { + res.Data = make([]*pb.LabelValue, 0, len(values)) + for _, row := range values { + res.Data = append(res.Data, &pb.LabelValue{ + Label: row.Label, + Value: row.Value, + }) + } + } + return +} + +func (s *UserService) DepartmentUserNested(ctx context.Context) []*types.NestedValue[string] { + var ( + err error + users []*models.User + departments []*models.Department + ) + + if departments, err = s.department.GetDepartments(ctx); err != nil { + return nil + } + if users, err = s.user.GeUsers(ctx); err != nil { + return nil + } + depts := s.department.RecursiveDepartment(ctx, 0, 0, departments) + values := make([]*types.NestedValue[string], 0) + for _, dept := range depts { + v := &types.NestedValue[string]{ + Label: dept.Label, + Value: strconv.FormatInt(dept.Value, 10), + Children: make([]*types.NestedValue[string], 0), + } + for _, user := range users { + if strconv.FormatInt(user.DeptId, 10) == v.Value { + v.Children = append(v.Children, &types.NestedValue[string]{ + Label: fmt.Sprintf("%s(%s)", user.Username, user.Uid), + Value: user.Uid, }) } - return items, nil - } else { - return nil, err } - }, - dbcache.WithDB(s.opts.db), - dbcache.WithDependency(dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM users")), - ) - return + values = append(values, v) + } + return values } func (s *UserService) GetUserTags(ctx context.Context, req *pb.GetUserTagRequest) (res *pb.GetUserTagResponse, err error) { @@ -280,6 +298,10 @@ func NewUserService(cbs ...UserOption) *UserService { cb(opts) } return &UserService{ - opts: opts, + opts: opts, + user: logic.NewUserLogic(opts.db), + role: logic.NewRoleLogic(opts.db), + menu: logic.NewMenuLogic(opts.db), + department: logic.NewDepartmentLogic(opts.db), } }