From c40bf36de325407af0324092115b9b44f1d30614 Mon Sep 17 00:00:00 2001 From: Yavolte Date: Mon, 16 Jun 2025 11:37:57 +0800 Subject: [PATCH] update service --- cache.go | 93 ++ defaults/default.go | 69 +- i18n/zh.go | 3 + models/model.go | 64 +- models/model_test.go | 17 + pb/organize.pb.go | 1265 +++++++++++++++++++---- pb/organize.pb.validate.go | 1962 ++++++++++++++++++++++++++++++++++++ pb/organize.proto | 232 ++++- pb/organize_grpc.pb.go | 720 ++++++++++--- pb/organize_http.pb.go | 221 +++- pb/organize_model.pb.go | 154 ++- server.go | 229 ++++- service/department.go | 53 + service/menu.go | 113 --- service/profile.go | 113 --- service/role.go | 67 ++ service/setting.go | 45 + service/user.go | 244 +++++ template.go | 49 + types.go | 48 +- types/model.go | 19 + 21 files changed, 5068 insertions(+), 712 deletions(-) create mode 100644 cache.go create mode 100644 models/model_test.go create mode 100644 service/department.go delete mode 100644 service/menu.go delete mode 100644 service/profile.go create mode 100644 service/role.go create mode 100644 service/setting.go create mode 100644 service/user.go create mode 100644 template.go create mode 100644 types/model.go diff --git a/cache.go b/cache.go new file mode 100644 index 0000000..722c4e1 --- /dev/null +++ b/cache.go @@ -0,0 +1,93 @@ +package aeusadmin + +import ( + "context" + "time" + + "git.nobla.cn/golang/aeus/pkg/cache" + "gorm.io/gorm" +) + +type ( + CachingFunc func(tx *gorm.DB) (any, error) + + CacheOptions struct { + db *gorm.DB + cache cache.Cache + dependSQL string + dependArgs []any + cacheDuration time.Duration + } + + CacheOption func(o *CacheOptions) + + cacheEntry struct { + storeValue any + compareValue string + createdAt time.Time + lastChecked time.Time + } +) + +func WithDepend(s string, args ...any) CacheOption { + return func(o *CacheOptions) { + o.dependSQL = s + o.dependArgs = args + } +} +func TryCache(ctx context.Context, key string, f CachingFunc, cbs ...CacheOption) (value any, err error) { + var ( + hasDependValue bool + dependValue string + ) + opts := &CacheOptions{ + cacheDuration: time.Minute * 10, + } + for _, cb := range cbs { + cb(opts) + } + //从缓存加载数据 + if value, _, err = opts.cache.Get(ctx, key); err == nil { + entry := value.(*cacheEntry) + if opts.dependSQL == "" { + return entry.storeValue, nil + } + //如果频繁访问,不检查依赖 + if time.Since(entry.lastChecked) < time.Millisecond*500 { + return entry.storeValue, nil + } + //对比依赖值 + if err = opts.db.Raw(opts.dependSQL, opts.dependArgs...).Scan(&dependValue).Error; err == nil { + hasDependValue = true + if entry.compareValue == dependValue { + entry.lastChecked = time.Now() + return entry.storeValue, nil + } else { + opts.cache.Delete(ctx, key) + } + } + } + //从数据库加载数据 + if value, err = f(opts.db.WithContext(ctx)); err == nil { + if !hasDependValue { + if err = opts.db.WithContext(ctx).Raw(opts.dependSQL, opts.dependArgs...).Scan(&dependValue).Error; err == nil { + opts.cache.Put(ctx, key, &cacheEntry{ + compareValue: dependValue, + storeValue: value, + createdAt: time.Now(), + lastChecked: time.Now(), + }, opts.cacheDuration) + } + } else { + opts.cache.Put(ctx, key, &cacheEntry{ + compareValue: dependValue, + storeValue: value, + createdAt: time.Now(), + lastChecked: time.Now(), + }, opts.cacheDuration) + } + return value, nil + } else { + return nil, err + } +} diff --git a/defaults/default.go b/defaults/default.go index bc45535..c2cb03a 100644 --- a/defaults/default.go +++ b/defaults/default.go @@ -1,13 +1,17 @@ package defaults import ( + "errors" + "git.nobla.cn/golang/aeus-admin/models" "gorm.io/gorm" ) var ( - defaultRoles = []*models.Role{} - defaultUsers = []*models.User{} + defaultRoles = []*models.Role{} + defaultUsers = []*models.User{} + defaultMenus = []*models.Menu{} + defaultDepartments = []*models.Department{} ) func init() { @@ -19,20 +23,67 @@ func init() { adminUser := &models.User{} adminUser.Uid = "admin" - adminUser.Username = "admin" + adminUser.Username = "管理员" adminUser.Password = "admin" adminUser.Role = "admin" adminUser.Admin = true + adminUser.DeptId = 1 guestUser := &models.User{} - guestUser.Uid = "guest" - guestUser.Username = "guest" - guestUser.Password = "guest" + guestUser.Uid = "test" + guestUser.Username = "测试人员" + guestUser.Password = "test" guestUser.Role = "admin" + guestUser.DeptId = 1 defaultUsers = append(defaultUsers, adminUser, guestUser) + + dashboardMenu := &models.Menu{} + dashboardMenu.Icon = "org" + dashboardMenu.Label = "控制面板" + dashboardMenu.Name = "Dashboard" + dashboardMenu.Public = true + dashboardMenu.Uri = "/dashboard" + + orgMenu := &models.Menu{} + orgMenu.Icon = "org" + orgMenu.Label = "组织机构" + orgMenu.Name = "Organize" + orgMenu.Public = true + orgMenu.Uri = "/organize" + + settingMenu := &models.Menu{} + settingMenu.Icon = "connect" + settingMenu.Label = "系统设置" + settingMenu.Name = "System" + settingMenu.Public = true + settingMenu.Uri = "/system" + defaultMenus = append(defaultMenus, dashboardMenu, orgMenu, settingMenu) + + systemDepartment := &models.Department{} + systemDepartment.Name = "系统部门" + systemDepartment.Description = "" + defaultDepartments = append(defaultDepartments, systemDepartment) } -func Init(db *gorm.DB) (err error) { +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 Menu(db *gorm.DB) (err error) { + for _, row := range defaultMenus { + if err = MergeMenu(db, row); err != nil { + return + } + } + return +} + +func Data(db *gorm.DB) (err error) { var ( n int64 ) @@ -51,6 +102,10 @@ func Init(db *gorm.DB) (err error) { 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) } diff --git a/i18n/zh.go b/i18n/zh.go index 61513d0..07cc610 100644 --- a/i18n/zh.go +++ b/i18n/zh.go @@ -28,6 +28,9 @@ func (t *ZH) Menu(model *rest.Model, label string) string { if _, ok := model.Value().Interface().(models.RolePermission); ok { return "角色权限" } + if _, ok := model.Value().Interface().(models.Setting); ok { + return "系统设置" + } return label } diff --git a/models/model.go b/models/model.go index 5dd160e..cc8e258 100644 --- a/models/model.go +++ b/models/model.go @@ -1,6 +1,9 @@ package models -import "git.nobla.cn/golang/aeus-admin/pb" +import ( + "git.nobla.cn/golang/aeus-admin/pb" + "git.nobla.cn/golang/aeus-admin/types" +) type ( User struct { @@ -21,4 +24,63 @@ type ( RolePermission struct { pb.RolePermissionModel } + + Setting struct { + pb.SettingModel + } ) + +func (m *User) GetMenu() *types.Menu { + return &types.Menu{ + Name: "OrganizeUser", + Parent: "Organize", + } +} + +func (m *Menu) GetMenu() *types.Menu { + return &types.Menu{ + Name: "OrganizeMenu", + Parent: "Organize", + } +} + +func (m *Department) GetMenu() *types.Menu { + return &types.Menu{ + Name: "OrganizeDepartment", + Parent: "Organize", + } +} + +func (m *Role) GetMenu() *types.Menu { + return &types.Menu{ + Name: "OrganizeRole", + Parent: "Organize", + } +} + +func (m *Permission) GetMenu() *types.Menu { + return &types.Menu{ + Name: "OrganizePermission", + Parent: "Organize", + Hidden: true, + } +} + +func (m *RolePermission) GetMenu() *types.Menu { + return &types.Menu{ + Name: "OrganizeRolePermission", + Parent: "Organize", + Hidden: true, + } +} + +func (m *Setting) GetMenu() *types.Menu { + return &types.Menu{ + Name: "SystemSetting", + Parent: "System", + } +} + +func (m *Setting) ModuleName() string { + return "system" +} diff --git a/models/model_test.go b/models/model_test.go new file mode 100644 index 0000000..0a22101 --- /dev/null +++ b/models/model_test.go @@ -0,0 +1,17 @@ +package models + +import ( + "testing" + + "git.nobla.cn/golang/aeus-admin/types" +) + +func TestModel(t *testing.T) { + var m any + m = &User{} + if _, ok := m.(types.Model); ok { + t.Log("ok") + } else { + t.Error("error") + } +} diff --git a/pb/organize.pb.go b/pb/organize.pb.go index 240a4d2..252b06a 100644 --- a/pb/organize.pb.go +++ b/pb/organize.pb.go @@ -37,6 +37,7 @@ type Menu struct { Icon string `protobuf:"bytes,7,opt,name=icon,proto3" json:"icon,omitempty"` Hidden bool `protobuf:"varint,8,opt,name=hidden,proto3" json:"hidden,omitempty"` Public bool `protobuf:"varint,9,opt,name=public,proto3" json:"public,omitempty"` + Description string `protobuf:"bytes,10,opt,name=description,proto3" json:"description,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -134,6 +135,13 @@ func (x *Menu) GetPublic() bool { return false } +func (x *Menu) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + // Role 角色模型定义 type Role struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -567,6 +575,143 @@ func (x *Department) GetDescription() string { return "" } +// Setting 参数设置表 +type Setting struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,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"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + Value string `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"` + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Setting) Reset() { + *x = Setting{} + mi := &file_organize_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Setting) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Setting) ProtoMessage() {} + +func (x *Setting) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[6] + 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 Setting.ProtoReflect.Descriptor instead. +func (*Setting) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{6} +} + +func (x *Setting) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Setting) GetCreatedAt() int64 { + if x != nil { + return x.CreatedAt + } + return 0 +} + +func (x *Setting) GetUpdatedAt() int64 { + if x != nil { + return x.UpdatedAt + } + return 0 +} + +func (x *Setting) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Setting) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *Setting) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +type LabelValue 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"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LabelValue) Reset() { + *x = LabelValue{} + mi := &file_organize_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LabelValue) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LabelValue) ProtoMessage() {} + +func (x *LabelValue) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[7] + 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 LabelValue.ProtoReflect.Descriptor instead. +func (*LabelValue) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{7} +} + +func (x *LabelValue) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *LabelValue) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + type PermissionItem struct { state protoimpl.MessageState `protogen:"open.v1"` Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` @@ -577,7 +722,7 @@ type PermissionItem struct { func (x *PermissionItem) Reset() { *x = PermissionItem{} - mi := &file_organize_proto_msgTypes[6] + mi := &file_organize_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -589,7 +734,7 @@ func (x *PermissionItem) String() string { func (*PermissionItem) ProtoMessage() {} func (x *PermissionItem) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[6] + mi := &file_organize_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -602,7 +747,7 @@ func (x *PermissionItem) ProtoReflect() protoreflect.Message { // Deprecated: Use PermissionItem.ProtoReflect.Descriptor instead. func (*PermissionItem) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{6} + return file_organize_proto_rawDescGZIP(), []int{8} } func (x *PermissionItem) GetValue() string { @@ -628,15 +773,16 @@ type MenuItem struct { Hidden bool `protobuf:"varint,4,opt,name=hidden,proto3" json:"hidden,omitempty"` Public bool `protobuf:"varint,5,opt,name=public,proto3" json:"public,omitempty"` Route string `protobuf:"bytes,6,opt,name=route,proto3" json:"route,omitempty"` - Permissions []*PermissionItem `protobuf:"bytes,7,rep,name=permissions,proto3" json:"permissions,omitempty"` - Children []*MenuItem `protobuf:"bytes,8,rep,name=children,proto3" json:"children,omitempty"` + View string `protobuf:"bytes,7,opt,name=view,proto3" json:"view,omitempty"` + Permissions []*PermissionItem `protobuf:"bytes,8,rep,name=permissions,proto3" json:"permissions,omitempty"` + Children []*MenuItem `protobuf:"bytes,9,rep,name=children,proto3" json:"children,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *MenuItem) Reset() { *x = MenuItem{} - mi := &file_organize_proto_msgTypes[7] + mi := &file_organize_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -648,7 +794,7 @@ func (x *MenuItem) String() string { func (*MenuItem) ProtoMessage() {} func (x *MenuItem) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[7] + mi := &file_organize_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -661,7 +807,7 @@ func (x *MenuItem) ProtoReflect() protoreflect.Message { // Deprecated: Use MenuItem.ProtoReflect.Descriptor instead. func (*MenuItem) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{7} + return file_organize_proto_rawDescGZIP(), []int{9} } func (x *MenuItem) GetLabel() string { @@ -706,6 +852,13 @@ func (x *MenuItem) GetRoute() string { return "" } +func (x *MenuItem) GetView() string { + if x != nil { + return x.View + } + return "" +} + func (x *MenuItem) GetPermissions() []*PermissionItem { if x != nil { return x.Permissions @@ -730,7 +883,7 @@ type GetMenuRequest struct { func (x *GetMenuRequest) Reset() { *x = GetMenuRequest{} - mi := &file_organize_proto_msgTypes[8] + mi := &file_organize_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -742,7 +895,7 @@ func (x *GetMenuRequest) String() string { func (*GetMenuRequest) ProtoMessage() {} func (x *GetMenuRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[8] + mi := &file_organize_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -755,7 +908,7 @@ func (x *GetMenuRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetMenuRequest.ProtoReflect.Descriptor instead. func (*GetMenuRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{8} + return file_organize_proto_rawDescGZIP(), []int{10} } func (x *GetMenuRequest) GetPermission() bool { @@ -775,7 +928,7 @@ type GetMenuResponse struct { func (x *GetMenuResponse) Reset() { *x = GetMenuResponse{} - mi := &file_organize_proto_msgTypes[9] + mi := &file_organize_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -787,7 +940,7 @@ func (x *GetMenuResponse) String() string { func (*GetMenuResponse) ProtoMessage() {} func (x *GetMenuResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[9] + mi := &file_organize_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -800,7 +953,7 @@ func (x *GetMenuResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetMenuResponse.ProtoReflect.Descriptor instead. func (*GetMenuResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{9} + return file_organize_proto_rawDescGZIP(), []int{11} } func (x *GetMenuResponse) GetData() []*MenuItem { @@ -820,7 +973,7 @@ type GetProfileRequest struct { func (x *GetProfileRequest) Reset() { *x = GetProfileRequest{} - mi := &file_organize_proto_msgTypes[10] + mi := &file_organize_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -832,7 +985,7 @@ func (x *GetProfileRequest) String() string { func (*GetProfileRequest) ProtoMessage() {} func (x *GetProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[10] + mi := &file_organize_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -845,7 +998,7 @@ func (x *GetProfileRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetProfileRequest.ProtoReflect.Descriptor instead. func (*GetProfileRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{10} + return file_organize_proto_rawDescGZIP(), []int{12} } func (x *GetProfileRequest) GetUid() string { @@ -871,7 +1024,7 @@ type GetProfileResponse struct { func (x *GetProfileResponse) Reset() { *x = GetProfileResponse{} - mi := &file_organize_proto_msgTypes[11] + mi := &file_organize_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -883,7 +1036,7 @@ func (x *GetProfileResponse) String() string { func (*GetProfileResponse) ProtoMessage() {} func (x *GetProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[11] + mi := &file_organize_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -896,7 +1049,7 @@ func (x *GetProfileResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetProfileResponse.ProtoReflect.Descriptor instead. func (*GetProfileResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{11} + return file_organize_proto_rawDescGZIP(), []int{13} } func (x *GetProfileResponse) GetUid() string { @@ -959,7 +1112,7 @@ type ResetPasswordRequest struct { func (x *ResetPasswordRequest) Reset() { *x = ResetPasswordRequest{} - mi := &file_organize_proto_msgTypes[12] + mi := &file_organize_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -971,7 +1124,7 @@ func (x *ResetPasswordRequest) String() string { func (*ResetPasswordRequest) ProtoMessage() {} func (x *ResetPasswordRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[12] + mi := &file_organize_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -984,7 +1137,7 @@ func (x *ResetPasswordRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ResetPasswordRequest.ProtoReflect.Descriptor instead. func (*ResetPasswordRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{12} + return file_organize_proto_rawDescGZIP(), []int{14} } func (x *ResetPasswordRequest) GetUid() string { @@ -1017,7 +1170,7 @@ type ResetPasswordResponse struct { func (x *ResetPasswordResponse) Reset() { *x = ResetPasswordResponse{} - mi := &file_organize_proto_msgTypes[13] + mi := &file_organize_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1029,7 +1182,7 @@ func (x *ResetPasswordResponse) String() string { func (*ResetPasswordResponse) ProtoMessage() {} func (x *ResetPasswordResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[13] + mi := &file_organize_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1042,7 +1195,7 @@ func (x *ResetPasswordResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ResetPasswordResponse.ProtoReflect.Descriptor instead. func (*ResetPasswordResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{13} + return file_organize_proto_rawDescGZIP(), []int{15} } func (x *ResetPasswordResponse) GetUid() string { @@ -1065,7 +1218,7 @@ type UpdateProfileRequest struct { func (x *UpdateProfileRequest) Reset() { *x = UpdateProfileRequest{} - mi := &file_organize_proto_msgTypes[14] + mi := &file_organize_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1077,7 +1230,7 @@ func (x *UpdateProfileRequest) String() string { func (*UpdateProfileRequest) ProtoMessage() {} func (x *UpdateProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[14] + mi := &file_organize_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1090,7 +1243,7 @@ func (x *UpdateProfileRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateProfileRequest.ProtoReflect.Descriptor instead. func (*UpdateProfileRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{14} + return file_organize_proto_rawDescGZIP(), []int{16} } func (x *UpdateProfileRequest) GetUid() string { @@ -1137,7 +1290,7 @@ type UpdateProfileResponse struct { func (x *UpdateProfileResponse) Reset() { *x = UpdateProfileResponse{} - mi := &file_organize_proto_msgTypes[15] + mi := &file_organize_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1149,7 +1302,7 @@ func (x *UpdateProfileResponse) String() string { func (*UpdateProfileResponse) ProtoMessage() {} func (x *UpdateProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[15] + mi := &file_organize_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1162,7 +1315,7 @@ func (x *UpdateProfileResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateProfileResponse.ProtoReflect.Descriptor instead. func (*UpdateProfileResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{15} + return file_organize_proto_rawDescGZIP(), []int{17} } func (x *UpdateProfileResponse) GetUid() string { @@ -1172,6 +1325,518 @@ func (x *UpdateProfileResponse) GetUid() string { return "" } +type GetPermissionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPermissionRequest) Reset() { + *x = GetPermissionRequest{} + mi := &file_organize_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPermissionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPermissionRequest) ProtoMessage() {} + +func (x *GetPermissionRequest) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[18] + 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 GetPermissionRequest.ProtoReflect.Descriptor instead. +func (*GetPermissionRequest) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{18} +} + +func (x *GetPermissionRequest) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +type GetPermissionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid,omitempty"` + Permissions []string `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPermissionResponse) Reset() { + *x = GetPermissionResponse{} + mi := &file_organize_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPermissionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPermissionResponse) ProtoMessage() {} + +func (x *GetPermissionResponse) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[19] + 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 GetPermissionResponse.ProtoReflect.Descriptor instead. +func (*GetPermissionResponse) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{19} +} + +func (x *GetPermissionResponse) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *GetPermissionResponse) GetPermissions() []string { + if x != nil { + return x.Permissions + } + return nil +} + +type GetUserLabelRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUserLabelRequest) Reset() { + *x = GetUserLabelRequest{} + mi := &file_organize_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUserLabelRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserLabelRequest) ProtoMessage() {} + +func (x *GetUserLabelRequest) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[20] + 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 GetUserLabelRequest.ProtoReflect.Descriptor instead. +func (*GetUserLabelRequest) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{20} +} + +type GetUserLabelResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data []*LabelValue `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUserLabelResponse) Reset() { + *x = GetUserLabelResponse{} + mi := &file_organize_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUserLabelResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserLabelResponse) ProtoMessage() {} + +func (x *GetUserLabelResponse) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[21] + 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 GetUserLabelResponse.ProtoReflect.Descriptor instead. +func (*GetUserLabelResponse) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{21} +} + +func (x *GetUserLabelResponse) GetData() []*LabelValue { + if x != nil { + return x.Data + } + return nil +} + +type GetUserTagRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUserTagRequest) Reset() { + *x = GetUserTagRequest{} + mi := &file_organize_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUserTagRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserTagRequest) ProtoMessage() {} + +func (x *GetUserTagRequest) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[22] + 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 GetUserTagRequest.ProtoReflect.Descriptor instead. +func (*GetUserTagRequest) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{22} +} + +type GetUserTagResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data []*LabelValue `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUserTagResponse) Reset() { + *x = GetUserTagResponse{} + mi := &file_organize_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUserTagResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserTagResponse) ProtoMessage() {} + +func (x *GetUserTagResponse) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[23] + 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 GetUserTagResponse.ProtoReflect.Descriptor instead. +func (*GetUserTagResponse) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{23} +} + +func (x *GetUserTagResponse) GetData() []*LabelValue { + if x != nil { + return x.Data + } + return nil +} + +type GetDepartmentLabelRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDepartmentLabelRequest) Reset() { + *x = GetDepartmentLabelRequest{} + mi := &file_organize_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDepartmentLabelRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDepartmentLabelRequest) ProtoMessage() {} + +func (x *GetDepartmentLabelRequest) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[24] + 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 GetDepartmentLabelRequest.ProtoReflect.Descriptor instead. +func (*GetDepartmentLabelRequest) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{24} +} + +type GetDepartmentLabelResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data []*LabelValue `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDepartmentLabelResponse) Reset() { + *x = GetDepartmentLabelResponse{} + mi := &file_organize_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDepartmentLabelResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDepartmentLabelResponse) ProtoMessage() {} + +func (x *GetDepartmentLabelResponse) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[25] + 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 GetDepartmentLabelResponse.ProtoReflect.Descriptor instead. +func (*GetDepartmentLabelResponse) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{25} +} + +func (x *GetDepartmentLabelResponse) GetData() []*LabelValue { + if x != nil { + return x.Data + } + return nil +} + +type GetRoleLabelRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetRoleLabelRequest) Reset() { + *x = GetRoleLabelRequest{} + mi := &file_organize_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetRoleLabelRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRoleLabelRequest) ProtoMessage() {} + +func (x *GetRoleLabelRequest) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[26] + 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 GetRoleLabelRequest.ProtoReflect.Descriptor instead. +func (*GetRoleLabelRequest) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{26} +} + +type GetRoleLabelResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data []*LabelValue `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetRoleLabelResponse) Reset() { + *x = GetRoleLabelResponse{} + mi := &file_organize_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetRoleLabelResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRoleLabelResponse) ProtoMessage() {} + +func (x *GetRoleLabelResponse) 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 GetRoleLabelResponse.ProtoReflect.Descriptor instead. +func (*GetRoleLabelResponse) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{27} +} + +func (x *GetRoleLabelResponse) GetData() []*LabelValue { + if x != nil { + return x.Data + } + return nil +} + +type GetRolePermissionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetRolePermissionRequest) Reset() { + *x = GetRolePermissionRequest{} + mi := &file_organize_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetRolePermissionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRolePermissionRequest) ProtoMessage() {} + +func (x *GetRolePermissionRequest) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[28] + 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 GetRolePermissionRequest.ProtoReflect.Descriptor instead. +func (*GetRolePermissionRequest) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{28} +} + +func (x *GetRolePermissionRequest) GetRole() string { + if x != nil { + return x.Role + } + return "" +} + +type GetRolePermissionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + Permissions []string `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetRolePermissionResponse) Reset() { + *x = GetRolePermissionResponse{} + mi := &file_organize_proto_msgTypes[29] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetRolePermissionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRolePermissionResponse) ProtoMessage() {} + +func (x *GetRolePermissionResponse) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[29] + 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 GetRolePermissionResponse.ProtoReflect.Descriptor instead. +func (*GetRolePermissionResponse) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{29} +} + +func (x *GetRolePermissionResponse) GetRole() string { + if x != nil { + return x.Role + } + return "" +} + +func (x *GetRolePermissionResponse) GetPermissions() []string { + if x != nil { + return x.Permissions + } + return nil +} + type LoginRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` @@ -1183,7 +1848,7 @@ type LoginRequest struct { func (x *LoginRequest) Reset() { *x = LoginRequest{} - mi := &file_organize_proto_msgTypes[16] + mi := &file_organize_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1195,7 +1860,7 @@ func (x *LoginRequest) String() string { func (*LoginRequest) ProtoMessage() {} func (x *LoginRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[16] + mi := &file_organize_proto_msgTypes[30] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1208,7 +1873,7 @@ func (x *LoginRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. func (*LoginRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{16} + return file_organize_proto_rawDescGZIP(), []int{30} } func (x *LoginRequest) GetUsername() string { @@ -1244,7 +1909,7 @@ type LoginResponse struct { func (x *LoginResponse) Reset() { *x = LoginResponse{} - mi := &file_organize_proto_msgTypes[17] + mi := &file_organize_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1256,7 +1921,7 @@ func (x *LoginResponse) String() string { func (*LoginResponse) ProtoMessage() {} func (x *LoginResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[17] + mi := &file_organize_proto_msgTypes[31] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1269,7 +1934,7 @@ func (x *LoginResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. func (*LoginResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{17} + return file_organize_proto_rawDescGZIP(), []int{31} } func (x *LoginResponse) GetUid() string { @@ -1309,7 +1974,7 @@ type LogoutRequest struct { func (x *LogoutRequest) Reset() { *x = LogoutRequest{} - mi := &file_organize_proto_msgTypes[18] + mi := &file_organize_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1321,7 +1986,7 @@ func (x *LogoutRequest) String() string { func (*LogoutRequest) ProtoMessage() {} func (x *LogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[18] + mi := &file_organize_proto_msgTypes[32] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1334,7 +1999,7 @@ func (x *LogoutRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead. func (*LogoutRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{18} + return file_organize_proto_rawDescGZIP(), []int{32} } func (x *LogoutRequest) GetToken() string { @@ -1353,7 +2018,7 @@ type LogoutResponse struct { func (x *LogoutResponse) Reset() { *x = LogoutResponse{} - mi := &file_organize_proto_msgTypes[19] + mi := &file_organize_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1365,7 +2030,7 @@ func (x *LogoutResponse) String() string { func (*LogoutResponse) ProtoMessage() {} func (x *LogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[19] + mi := &file_organize_proto_msgTypes[33] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1378,7 +2043,7 @@ func (x *LogoutResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LogoutResponse.ProtoReflect.Descriptor instead. func (*LogoutResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{19} + return file_organize_proto_rawDescGZIP(), []int{33} } func (x *LogoutResponse) GetUid() string { @@ -1388,123 +2053,278 @@ func (x *LogoutResponse) GetUid() string { return "" } +type SettingItem struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SettingItem) Reset() { + *x = SettingItem{} + mi := &file_organize_proto_msgTypes[34] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SettingItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SettingItem) ProtoMessage() {} + +func (x *SettingItem) 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 SettingItem.ProtoReflect.Descriptor instead. +func (*SettingItem) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{34} +} + +func (x *SettingItem) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *SettingItem) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +type GetSettingRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSettingRequest) Reset() { + *x = GetSettingRequest{} + mi := &file_organize_proto_msgTypes[35] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSettingRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSettingRequest) ProtoMessage() {} + +func (x *GetSettingRequest) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[35] + 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 GetSettingRequest.ProtoReflect.Descriptor instead. +func (*GetSettingRequest) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{35} +} + +type GetSettingResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data []*SettingItem `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSettingResponse) Reset() { + *x = GetSettingResponse{} + mi := &file_organize_proto_msgTypes[36] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSettingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSettingResponse) ProtoMessage() {} + +func (x *GetSettingResponse) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[36] + 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 GetSettingResponse.ProtoReflect.Descriptor instead. +func (*GetSettingResponse) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{36} +} + +func (x *GetSettingResponse) GetData() []*SettingItem { + if x != nil { + return x.Data + } + return nil +} + 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\"\xe8\x02\n" + - "\x04Menu\x12 \n" + - "\x02id\x18\x01 \x01(\x03B\x10\xb2\xb9\x19\f\n" + + "\x0eorganize.proto\x12\borganize\x1a\x0faeus/rest.proto\x1a\x17validate/validate.proto\x1a google/protobuf/descriptor.proto\x1a\x1cgoogle/api/annotations.proto\"\x9d\x06\n" + + "\x04Menu\x12*\n" + + "\x02id\x18\x01 \x01(\x03B\x1a\xb2\xb9\x19\x16\n" + "\n" + - "primaryKeyR\x02id\x12\x1b\n" + - "\tparent_id\x18\x02 \x01(\x03R\bparentId\x12.\n" + - "\x04name\x18\x03 \x01(\tB\x1a\xfaB\x04r\x02\x18<\xb2\xb9\x19\x0f\n" + - "\rindex;size:60R\x04name\x12+\n" + - "\x05label\x18\x04 \x01(\tB\x15\xfaB\x04r\x02\x18x\xb2\xb9\x19\n" + + "primaryKey\x12\b菜单IDR\x02id\x12/\n" + + "\tparent_id\x18\x02 \x01(\x03B\x12\xb2\xb9\x19\x0e\x12\f父级菜单R\bparentId\x12W\n" + + "\x04name\x18\x03 \x01(\tBC\xfaB\x04r\x02\x18<\xb2\xb9\x198\n" + + "\rindex;size:60\x12\f组件名称2\x0freadonly:update:\brequiredR\x04name\x12C\n" + + "\x05label\x18\x04 \x01(\tB-\xfaB\x04r\x02\x18x\xb2\xb9\x19\"\n" + + "\bsize:120\x12\f菜单标题:\brequiredR\x05label\x12[\n" + + "\x03uri\x18\x05 \x01(\tBI\xfaB\x05r\x03\x18\x80\x04\xb2\xb9\x19=\n" + + "\bsize:512\x12\f菜单链接\x1a\x19create;update;view;export:\brequiredR\x03uri\x12\\\n" + + "\tview_path\x18\x06 \x01(\tB?\xfaB\x05r\x03\x18\x80\x04\xb2\xb9\x193\n" + + "\bsize:512\x12\f视图路径\x1a\x19create;update;view;exportR\bviewPath\x12Q\n" + + "\x04icon\x18\a \x01(\tB=\xfaB\x04r\x02\x18<\xb2\xb9\x192\n" + + "\asize:60\x12\f菜单图标\x1a\x19create;update;view;exportR\x04icon\x12E\n" + + "\x06hidden\x18\b \x01(\bB-\xb2\xb9\x19)\x12\f是否隐藏\x1a\x19create;update;view;exportR\x06hidden\x12E\n" + + "\x06public\x18\t \x01(\bB-\xb2\xb9\x19)\x12\f是否公开\x1a\x19create;update;view;exportR\x06public\x12q\n" + + "\vdescription\x18\n" + + " \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" + + "\x05menus\"\xb6\x02\n" + + "\x04Role\x12*\n" + + "\x02id\x18\x01 \x01(\x03B\x1a\xb2\xb9\x19\x16\n" + "\n" + - "\bsize:120R\x05label\x12(\n" + - "\x03uri\x18\x05 \x01(\tB\x16\xfaB\x05r\x03\x18\x80\x04\xb2\xb9\x19\n" + + "primaryKey\x12\b角色IDR\x02id\x12M\n" + + "\x04name\x18\x02 \x01(\tB9\xfaB\x04r\x02\x18<\xb2\xb9\x19.\n" + + "\rindex;size:60\x12\f角色名称2\x0freadonly:updateR\x04name\x128\n" + + "\x05label\x18\x03 \x01(\tB\"\xfaB\x04r\x02\x18<\xb2\xb9\x19\x17\n" + + "\asize:60\x12\f角色标题R\x05label\x12l\n" + + "\vdescription\x18\x04 \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\"\xa1\x02\n" + "\n" + - "\bsize:512R\x03uri\x123\n" + - "\tview_path\x18\x06 \x01(\tB\x16\xfaB\x05r\x03\x18\x80\x04\xb2\xb9\x19\n" + + "Permission\x12*\n" + + "\x02id\x18\x01 \x01(\x03B\x1a\xb2\xb9\x19\x16\n" + "\n" + - "\bsize:512R\bviewPath\x12(\n" + - "\x04icon\x18\a \x01(\tB\x14\xfaB\x04r\x02\x18<\xb2\xb9\x19\t\n" + - "\asize:60R\x04icon\x12\x16\n" + - "\x06hidden\x18\b \x01(\bR\x06hidden\x12\x16\n" + - "\x06public\x18\t \x01(\bR\x06public:\v\xba\xb9\x19\a\n" + - "\x05menus\"\xcc\x01\n" + - "\x04Role\x12 \n" + - "\x02id\x18\x01 \x01(\x03B\x10\xb2\xb9\x19\f\n" + + "primaryKey\x12\b权限IDR\x02id\x12<\n" + + "\amenu_id\x18\x02 \x01(\x03B#\xb2\xb9\x19\x1f\n" + + "\x05index\x12\f所属菜单:\brequiredR\x06menuId\x12R\n" + "\n" + - "primaryKeyR\x02id\x12.\n" + - "\x04name\x18\x02 \x01(\tB\x1a\xfaB\x04r\x02\x18<\xb2\xb9\x19\x0f\n" + - "\rindex;size:60R\x04name\x12*\n" + - "\x05label\x18\x03 \x01(\tB\x14\xfaB\x04r\x02\x18<\xb2\xb9\x19\t\n" + - "\asize:60R\x05label\x129\n" + - "\vdescription\x18\x04 \x01(\tB\x17\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19\v\n" + - "\tsize:1024R\vdescription:\v\xba\xb9\x19\a\n" + - "\x05roles\"\xcf\x01\n" + + "permission\x18\x03 \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" + + "\asize:60\x12\f权限标题:\brequiredR\x05label:\x11\xba\xb9\x19\r\n" + + "\vpermissions\"\xcf\x01\n" + + "\x0eRolePermission\x12$\n" + + "\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" + "\n" + - "Permission\x12 \n" + - "\x02id\x18\x01 \x01(\x03B\x10\xb2\xb9\x19\f\n" + + "primaryKey\x12\x02IDR\x02id\x12@\n" + + "\x04role\x18\x02 \x01(\tB,\xfaB\x04r\x02\x18<\xb2\xb9\x19!\n" + + "\asize:60\x12\f角色名称:\brequiredR\x04role\x12=\n" + + "\rpermission_id\x18\x03 \x01(\x03B\x18\xb2\xb9\x19\x14\x12\b权限ID:\brequiredR\fpermissionId:\x16\xba\xb9\x19\x12\n" + + "\x10role_permissions\"\xe8\b\n" + + "\x04User\x12$\n" + + "\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" + "\n" + - "primaryKeyR\x02id\x12$\n" + - "\amenu_id\x18\x02 \x01(\x03B\v\xb2\xb9\x19\a\n" + - "\x05indexR\x06menuId\x12:\n" + + "primaryKey\x12\x02IDR\x02id\x12>\n" + "\n" + - "permission\x18\x03 \x01(\tB\x1a\xfaB\x04r\x02\x18<\xb2\xb9\x19\x0f\n" + - "\rindex;size:60R\n" + - "permission\x12*\n" + - "\x05label\x18\x04 \x01(\tB\x14\xfaB\x04r\x02\x18<\xb2\xb9\x19\t\n" + - "\asize:60R\x05label:\x11\xba\xb9\x19\r\n" + - "\vpermissions\"\x99\x01\n" + - "\x0eRolePermission\x12 \n" + - "\x02id\x18\x01 \x01(\x03B\x10\xb2\xb9\x19\f\n" + + "created_at\x18\x02 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f创建时间\x1a\vview;exportR\tcreatedAt\x12>\n" + "\n" + - "primaryKeyR\x02id\x12(\n" + - "\x04role\x18\x02 \x01(\tB\x14\xfaB\x04r\x02\x18<\xb2\xb9\x19\t\n" + - "\asize:60R\x04role\x12#\n" + - "\rpermission_id\x18\x03 \x01(\x03R\fpermissionId:\x16\xba\xb9\x19\x12\n" + - "\x10role_permissions\"\xf6\x04\n" + - "\x04User\x12 \n" + - "\x02id\x18\x01 \x01(\x03B\x10\xb2\xb9\x19\f\n" + - "\n" + - "primaryKeyR\x02id\x12\x1d\n" + - "\n" + - "created_at\x18\x02 \x01(\x03R\tcreatedAt\x12\x1d\n" + - "\n" + - "updated_at\x18\x03 \x01(\x03R\tupdatedAt\x12.\n" + - "\x03uid\x18\x04 \x01(\tB\x1c\xfaB\x06r\x04\x10\x05\x18\x14\xb2\xb9\x19\x0f\n" + - "\rindex;size:20R\x03uid\x122\n" + - "\busername\x18\x05 \x01(\tB\x16\xfaB\x06r\x04\x10\x05\x18\x14\xb2\xb9\x19\t\n" + - "\asize:20R\busername\x12(\n" + - "\x04role\x18\x06 \x01(\tB\x14\xfaB\x04r\x02\x18<\xb2\xb9\x19\t\n" + - "\asize:60R\x04role\x12\x14\n" + - "\x05admin\x18\a \x01(\bR\x05admin\x121\n" + - "\adept_id\x18\b \x01(\x03B\x18\xb2\xb9\x19\x14\n" + - "\x12not null;default:0R\x06deptId\x12&\n" + - "\x03tag\x18\t \x01(\tB\x14\xfaB\x04r\x02\x18<\xb2\xb9\x19\t\n" + - "\asize:60R\x03tag\x120\n" + + "updated_at\x18\x03 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f更新时间\x1a\vview;exportR\tupdatedAt\x12x\n" + + "\x03uid\x18\x04 \x01(\tBf\xfaB\x06r\x04\x10\x05\x18\x14\xb2\xb9\x19Y\n" + + "\rindex;size:20\x12\f用户工号2\x0freadonly:update:)required;unique;regexp:^[a-zA-Z0-9]{3,8}$R\x03uid\x12J\n" + + "\busername\x18\x05 \x01(\tB.\xfaB\x06r\x04\x10\x05\x18\x14\xb2\xb9\x19!\n" + + "\asize:20\x12\f用户名称:\brequiredR\busername\x12F\n" + + "\x04role\x18\x06 \x01(\tB2\xfaB\x04r\x02\x18<\xb2\xb9\x19'\n" + + "\asize:60\x12\f所属角色*\x04role:\brequiredR\x04role\x12-\n" + + "\x05admin\x18\a \x01(\bB\x17\xb2\xb9\x19\x13\x12\t管理员\x1a\x06createR\x05admin\x12U\n" + + "\adept_id\x18\b \x01(\x03B<\xb2\xb9\x198\n" + + "\x12not null;default:0\x12\f所属部门*\n" + + "department:\brequiredR\x06deptId\x12H\n" + + "\x03tag\x18\t \x01(\tB6\xfaB\x04r\x02\x18<\xb2\xb9\x19+\n" + + "\asize:60\x12\f用户标签\x1a\x12list;create;updateR\x03tag\x12P\n" + "\bpassword\x18\n" + - " \x01(\tB\x14\xfaB\x04r\x02\x18<\xb2\xb9\x19\t\n" + - "\asize:60R\bpassword\x12*\n" + - "\x05email\x18\v \x01(\tB\x14\xfaB\x04r\x02\x18<\xb2\xb9\x19\t\n" + - "\asize:60R\x05email\x12/\n" + - "\x06avatar\x18\f \x01(\tB\x17\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19\v\n" + - "\tsize:1024R\x06avatar\x128\n" + - "\x06gender\x18\r \x01(\tB \xfaB\x04r\x02\x18\x14\xb2\xb9\x19\x15\n" + - "\x13size:20;default:manR\x06gender\x129\n" + - "\vdescription\x18\x0e \x01(\tB\x17\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19\v\n" + - "\tsize:1024R\vdescription:\v\xba\xb9\x19\a\n" + - "\x05users\"\x81\x02\n" + + " \x01(\tB4\xfaB\x04r\x02\x18<\xb2\xb9\x19)\n" + + "\asize:60\x12\f用户密码\x1a\x06create:\brequiredR\bpassword\x12X\n" + + "\x05email\x18\v \x01(\tBB\xfaB\x04r\x02\x18<\xb2\xb9\x197\n" + + "\asize:60\x12\f用户邮箱\x1a\x1ecreate;update;view;list;exportR\x05email\x12C\n" + + "\x06avatar\x18\f \x01(\tB+\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19\x1f\n" + + "\tsize:1024\x12\f用户头像\x1a\x04viewR\x06avatar\x12p\n" + + "\x06gender\x18\r \x01(\tBX\xfaB\x04r\x02\x18\x14\xb2\xb9\x19M\n" + + "\x13size:20;default:man\x12\f用户性别\x1a\x1elist;create;update;view;export:\brequiredR\x06gender\x12l\n" + + "\vdescription\x18\x0e \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\"\xb7\x03\n" + "\n" + - "Department\x12 \n" + - "\x02id\x18\x01 \x01(\x03B\x10\xb2\xb9\x19\f\n" + + "Department\x12$\n" + + "\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" + "\n" + - "primaryKeyR\x02id\x12\x1d\n" + + "primaryKey\x12\x02IDR\x02id\x12>\n" + "\n" + - "created_at\x18\x02 \x01(\x03R\tcreatedAt\x12\x1d\n" + + "created_at\x18\x02 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f创建时间\x1a\vview;exportR\tcreatedAt\x12>\n" + "\n" + - "updated_at\x18\x03 \x01(\x03R\tupdatedAt\x12\x1b\n" + - "\tparent_id\x18\x04 \x01(\x03R\bparentId\x12(\n" + - "\x04name\x18\x05 \x01(\tB\x14\xfaB\x04r\x02\x18\x14\xb2\xb9\x19\t\n" + - "\asize:20R\x04name\x129\n" + - "\vdescription\x18\x06 \x01(\tB\x17\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19\v\n" + - "\tsize:1024R\vdescription:\x11\xba\xb9\x19\r\n" + - "\vdepartments\"<\n" + + "updated_at\x18\x03 \x01(\x03B\x1f\xb2\xb9\x19\x1b\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" + + "\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" + + "\tsize:1024\x12\f备注说明\x1a\x1ecreate;update;view;export;list*\btextareaR\vdescription:\x11\xba\xb9\x19\r\n" + + "\vdepartments\"\xd8\x03\n" + + "\aSetting\x12$\n" + + "\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" + + "\n" + + "primaryKey\x12\x02IDR\x02id\x12E\n" + + "\n" + + "created_at\x18\x02 \x01(\x03B&\xb2\xb9\x19\"\x12\f创建时间\x1a\x12search;view;exportR\tcreatedAt\x12E\n" + + "\n" + + "updated_at\x18\x03 \x01(\x03B&\xb2\xb9\x19\"\x12\f更新时间\x1a\x12search;view;exportR\tupdatedAt\x12N\n" + + "\x04name\x18\x04 \x01(\tB:\xfaB\x04r\x02\x18\x14\xb2\xb9\x19/\n" + + "\asize:60\x12\t配置项2\x0freadonly:update:\brequiredR\x04name\x12K\n" + + "\x05value\x18\x05 \x01(\tB5\xfaB\x05r\x03\x18\x80\x04\xb2\xb9\x19)\n" + + "\bsize:512\x12\t配置值*\btextarea:\brequiredR\x05value\x12l\n" + + "\vdescription\x18\x06 \x01(\tBJ\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19>\n" + + "\tsize:1024\x12\f备注说明\x1a\x19create;update;view;export*\btextareaR\vdescription:\x0e\xba\xb9\x19\n" + + "\n" + + "\bsettings\"8\n" + + "\n" + + "LabelValue\x12\x14\n" + + "\x05label\x18\x01 \x01(\tR\x05label\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value\"<\n" + "\x0ePermissionItem\x12\x14\n" + "\x05value\x18\x01 \x01(\tR\x05value\x12\x14\n" + - "\x05label\x18\x02 \x01(\tR\x05label\"\xfa\x01\n" + + "\x05label\x18\x02 \x01(\tR\x05label\"\x8e\x02\n" + "\bMenuItem\x12\x14\n" + "\x05label\x18\x01 \x01(\tR\x05label\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\x12\x12\n" + "\x04icon\x18\x03 \x01(\tR\x04icon\x12\x16\n" + "\x06hidden\x18\x04 \x01(\bR\x06hidden\x12\x16\n" + "\x06public\x18\x05 \x01(\bR\x06public\x12\x14\n" + - "\x05route\x18\x06 \x01(\tR\x05route\x12:\n" + - "\vpermissions\x18\a \x03(\v2\x18.organize.PermissionItemR\vpermissions\x12.\n" + - "\bchildren\x18\b \x03(\v2\x12.organize.MenuItemR\bchildren\"0\n" + + "\x05route\x18\x06 \x01(\tR\x05route\x12\x12\n" + + "\x04view\x18\a \x01(\tR\x04view\x12:\n" + + "\vpermissions\x18\b \x03(\v2\x18.organize.PermissionItemR\vpermissions\x12.\n" + + "\bchildren\x18\t \x03(\v2\x12.organize.MenuItemR\bchildren\"0\n" + "\x0eGetMenuRequest\x12\x1e\n" + "\n" + "permission\x18\x01 \x01(\bR\n" + @@ -1534,7 +2354,29 @@ const file_organize_proto_rawDesc = "" + "\x06avatar\x18\x05 \x01(\tR\x06avatar\x12 \n" + "\vdescription\x18\a \x01(\tR\vdescription\")\n" + "\x15UpdateProfileResponse\x12\x10\n" + - "\x03uid\x18\x01 \x01(\tR\x03uid\"\\\n" + + "\x03uid\x18\x01 \x01(\tR\x03uid\"(\n" + + "\x14GetPermissionRequest\x12\x10\n" + + "\x03uid\x18\x01 \x01(\tR\x03uid\"K\n" + + "\x15GetPermissionResponse\x12\x10\n" + + "\x03uid\x18\x01 \x01(\tR\x03uid\x12 \n" + + "\vpermissions\x18\x02 \x03(\tR\vpermissions\"\x15\n" + + "\x13GetUserLabelRequest\"@\n" + + "\x14GetUserLabelResponse\x12(\n" + + "\x04data\x18\x01 \x03(\v2\x14.organize.LabelValueR\x04data\"\x13\n" + + "\x11GetUserTagRequest\">\n" + + "\x12GetUserTagResponse\x12(\n" + + "\x04data\x18\x01 \x03(\v2\x14.organize.LabelValueR\x04data\"\x1b\n" + + "\x19GetDepartmentLabelRequest\"F\n" + + "\x1aGetDepartmentLabelResponse\x12(\n" + + "\x04data\x18\x01 \x03(\v2\x14.organize.LabelValueR\x04data\"\x15\n" + + "\x13GetRoleLabelRequest\"@\n" + + "\x14GetRoleLabelResponse\x12(\n" + + "\x04data\x18\x01 \x03(\v2\x14.organize.LabelValueR\x04data\".\n" + + "\x18GetRolePermissionRequest\x12\x12\n" + + "\x04role\x18\x01 \x01(\tR\x04role\"Q\n" + + "\x19GetRolePermissionResponse\x12\x12\n" + + "\x04role\x18\x01 \x01(\tR\x04role\x12 \n" + + "\vpermissions\x18\x02 \x03(\tR\vpermissions\"\\\n" + "\fLoginRequest\x12\x1a\n" + "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + "\bpassword\x18\x02 \x01(\tR\bpassword\x12\x14\n" + @@ -1547,17 +2389,34 @@ const file_organize_proto_rawDesc = "" + "\rLogoutRequest\x12\x14\n" + "\x05token\x18\x01 \x01(\tR\x05token\"\"\n" + "\x0eLogoutResponse\x12\x10\n" + - "\x03uid\x18\x01 \x01(\tR\x03uid2a\n" + - "\vMenuService\x12R\n" + - "\bGetMenus\x12\x18.organize.GetMenuRequest\x1a\x19.organize.GetMenuResponse\"\x11\x82\xd3\xe4\x93\x02\v\x12\t/api/menu2\xcf\x02\n" + - "\x0eProfileService\x12^\n" + + "\x03uid\x18\x01 \x01(\tR\x03uid\"7\n" + + "\vSettingItem\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value\"\x13\n" + + "\x11GetSettingRequest\"?\n" + + "\x12GetSettingResponse\x12)\n" + + "\x04data\x18\x01 \x03(\v2\x15.organize.SettingItemR\x04data2\xd4\x05\n" + + "\vUserService\x12T\n" + + "\bGetMenus\x12\x18.organize.GetMenuRequest\x1a\x19.organize.GetMenuResponse\"\x13\x82\xd3\xe4\x93\x02\r\x12\v/user/menus\x12^\n" + "\n" + "GetProfile\x12\x1b.organize.GetProfileRequest\x1a\x1c.organize.GetProfileResponse\"\x15\x82\xd3\xe4\x93\x02\x0f\x12\r/user/profile\x12j\n" + "\rUpdateProfile\x12\x1e.organize.UpdateProfileRequest\x1a\x1f.organize.UpdateProfileResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x01*\x1a\r/user/profile\x12q\n" + - "\rResetPassword\x12\x1e.organize.ResetPasswordRequest\x1a\x1f.organize.ResetPasswordResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\"\x14/user/reset-password2\xbd\x01\n" + + "\rResetPassword\x12\x1e.organize.ResetPasswordRequest\x1a\x1f.organize.ResetPasswordResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\"\x14/user/reset-password\x12l\n" + + "\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" + + "\x11DepartmentService\x12|\n" + + "\x13GetDepartmentLabels\x12#.organize.GetDepartmentLabelRequest\x1a$.organize.GetDepartmentLabelResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/department/labels2\xed\x01\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/permissions2\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/logoutB&Z$git.nobla.cn/golang/aeis-admin/pb;pbb\x06proto3" + "\x06Logout\x12\x17.organize.LogoutRequest\x1a\x18.organize.LogoutResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/passport/logout2r\n" + + "\x0eSettingService\x12`\n" + + "\n" + + "GetSetting\x12\x1b.organize.GetSettingRequest\x1a\x1c.organize.GetSettingResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/system/settingB&Z$git.nobla.cn/golang/aeis-admin/pb;pbb\x06proto3" var ( file_organize_proto_rawDescOnce sync.Once @@ -1571,50 +2430,86 @@ func file_organize_proto_rawDescGZIP() []byte { return file_organize_proto_rawDescData } -var file_organize_proto_msgTypes = make([]protoimpl.MessageInfo, 20) +var file_organize_proto_msgTypes = make([]protoimpl.MessageInfo, 37) 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 - (*PermissionItem)(nil), // 6: organize.PermissionItem - (*MenuItem)(nil), // 7: organize.MenuItem - (*GetMenuRequest)(nil), // 8: organize.GetMenuRequest - (*GetMenuResponse)(nil), // 9: organize.GetMenuResponse - (*GetProfileRequest)(nil), // 10: organize.GetProfileRequest - (*GetProfileResponse)(nil), // 11: organize.GetProfileResponse - (*ResetPasswordRequest)(nil), // 12: organize.ResetPasswordRequest - (*ResetPasswordResponse)(nil), // 13: organize.ResetPasswordResponse - (*UpdateProfileRequest)(nil), // 14: organize.UpdateProfileRequest - (*UpdateProfileResponse)(nil), // 15: organize.UpdateProfileResponse - (*LoginRequest)(nil), // 16: organize.LoginRequest - (*LoginResponse)(nil), // 17: organize.LoginResponse - (*LogoutRequest)(nil), // 18: organize.LogoutRequest - (*LogoutResponse)(nil), // 19: organize.LogoutResponse + (*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 + (*Setting)(nil), // 6: organize.Setting + (*LabelValue)(nil), // 7: organize.LabelValue + (*PermissionItem)(nil), // 8: organize.PermissionItem + (*MenuItem)(nil), // 9: organize.MenuItem + (*GetMenuRequest)(nil), // 10: organize.GetMenuRequest + (*GetMenuResponse)(nil), // 11: organize.GetMenuResponse + (*GetProfileRequest)(nil), // 12: organize.GetProfileRequest + (*GetProfileResponse)(nil), // 13: organize.GetProfileResponse + (*ResetPasswordRequest)(nil), // 14: organize.ResetPasswordRequest + (*ResetPasswordResponse)(nil), // 15: organize.ResetPasswordResponse + (*UpdateProfileRequest)(nil), // 16: organize.UpdateProfileRequest + (*UpdateProfileResponse)(nil), // 17: organize.UpdateProfileResponse + (*GetPermissionRequest)(nil), // 18: organize.GetPermissionRequest + (*GetPermissionResponse)(nil), // 19: organize.GetPermissionResponse + (*GetUserLabelRequest)(nil), // 20: organize.GetUserLabelRequest + (*GetUserLabelResponse)(nil), // 21: organize.GetUserLabelResponse + (*GetUserTagRequest)(nil), // 22: organize.GetUserTagRequest + (*GetUserTagResponse)(nil), // 23: organize.GetUserTagResponse + (*GetDepartmentLabelRequest)(nil), // 24: organize.GetDepartmentLabelRequest + (*GetDepartmentLabelResponse)(nil), // 25: organize.GetDepartmentLabelResponse + (*GetRoleLabelRequest)(nil), // 26: organize.GetRoleLabelRequest + (*GetRoleLabelResponse)(nil), // 27: organize.GetRoleLabelResponse + (*GetRolePermissionRequest)(nil), // 28: organize.GetRolePermissionRequest + (*GetRolePermissionResponse)(nil), // 29: organize.GetRolePermissionResponse + (*LoginRequest)(nil), // 30: organize.LoginRequest + (*LoginResponse)(nil), // 31: organize.LoginResponse + (*LogoutRequest)(nil), // 32: organize.LogoutRequest + (*LogoutResponse)(nil), // 33: organize.LogoutResponse + (*SettingItem)(nil), // 34: organize.SettingItem + (*GetSettingRequest)(nil), // 35: organize.GetSettingRequest + (*GetSettingResponse)(nil), // 36: organize.GetSettingResponse } var file_organize_proto_depIdxs = []int32{ - 6, // 0: organize.MenuItem.permissions:type_name -> organize.PermissionItem - 7, // 1: organize.MenuItem.children:type_name -> organize.MenuItem - 7, // 2: organize.GetMenuResponse.data:type_name -> organize.MenuItem - 8, // 3: organize.MenuService.GetMenus:input_type -> organize.GetMenuRequest - 10, // 4: organize.ProfileService.GetProfile:input_type -> organize.GetProfileRequest - 14, // 5: organize.ProfileService.UpdateProfile:input_type -> organize.UpdateProfileRequest - 12, // 6: organize.ProfileService.ResetPassword:input_type -> organize.ResetPasswordRequest - 16, // 7: organize.AuthService.Login:input_type -> organize.LoginRequest - 18, // 8: organize.AuthService.Logout:input_type -> organize.LogoutRequest - 9, // 9: organize.MenuService.GetMenus:output_type -> organize.GetMenuResponse - 11, // 10: organize.ProfileService.GetProfile:output_type -> organize.GetProfileResponse - 15, // 11: organize.ProfileService.UpdateProfile:output_type -> organize.UpdateProfileResponse - 13, // 12: organize.ProfileService.ResetPassword:output_type -> organize.ResetPasswordResponse - 17, // 13: organize.AuthService.Login:output_type -> organize.LoginResponse - 19, // 14: organize.AuthService.Logout:output_type -> organize.LogoutResponse - 9, // [9:15] is the sub-list for method output_type - 3, // [3:9] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 8, // 0: organize.MenuItem.permissions:type_name -> organize.PermissionItem + 9, // 1: organize.MenuItem.children:type_name -> organize.MenuItem + 9, // 2: organize.GetMenuResponse.data:type_name -> organize.MenuItem + 7, // 3: organize.GetUserLabelResponse.data:type_name -> organize.LabelValue + 7, // 4: organize.GetUserTagResponse.data:type_name -> organize.LabelValue + 7, // 5: organize.GetDepartmentLabelResponse.data:type_name -> organize.LabelValue + 7, // 6: organize.GetRoleLabelResponse.data:type_name -> organize.LabelValue + 34, // 7: organize.GetSettingResponse.data:type_name -> organize.SettingItem + 10, // 8: organize.UserService.GetMenus:input_type -> organize.GetMenuRequest + 12, // 9: organize.UserService.GetProfile:input_type -> organize.GetProfileRequest + 16, // 10: organize.UserService.UpdateProfile:input_type -> organize.UpdateProfileRequest + 14, // 11: organize.UserService.ResetPassword:input_type -> organize.ResetPasswordRequest + 18, // 12: organize.UserService.GetPermissions:input_type -> organize.GetPermissionRequest + 20, // 13: organize.UserService.GetUserLabels:input_type -> organize.GetUserLabelRequest + 22, // 14: organize.UserService.GetUserTags:input_type -> organize.GetUserTagRequest + 24, // 15: organize.DepartmentService.GetDepartmentLabels:input_type -> organize.GetDepartmentLabelRequest + 26, // 16: organize.RoleService.GetRoleLabels:input_type -> organize.GetRoleLabelRequest + 28, // 17: organize.RoleService.GetRolePermissions:input_type -> organize.GetRolePermissionRequest + 30, // 18: organize.AuthService.Login:input_type -> organize.LoginRequest + 32, // 19: organize.AuthService.Logout:input_type -> organize.LogoutRequest + 35, // 20: organize.SettingService.GetSetting:input_type -> organize.GetSettingRequest + 11, // 21: organize.UserService.GetMenus:output_type -> organize.GetMenuResponse + 13, // 22: organize.UserService.GetProfile:output_type -> organize.GetProfileResponse + 17, // 23: organize.UserService.UpdateProfile:output_type -> organize.UpdateProfileResponse + 15, // 24: organize.UserService.ResetPassword:output_type -> organize.ResetPasswordResponse + 19, // 25: organize.UserService.GetPermissions:output_type -> organize.GetPermissionResponse + 21, // 26: organize.UserService.GetUserLabels:output_type -> organize.GetUserLabelResponse + 23, // 27: organize.UserService.GetUserTags:output_type -> organize.GetUserTagResponse + 25, // 28: organize.DepartmentService.GetDepartmentLabels:output_type -> organize.GetDepartmentLabelResponse + 27, // 29: organize.RoleService.GetRoleLabels:output_type -> organize.GetRoleLabelResponse + 29, // 30: organize.RoleService.GetRolePermissions:output_type -> organize.GetRolePermissionResponse + 31, // 31: organize.AuthService.Login:output_type -> organize.LoginResponse + 33, // 32: organize.AuthService.Logout:output_type -> organize.LogoutResponse + 36, // 33: organize.SettingService.GetSetting:output_type -> organize.GetSettingResponse + 21, // [21:34] is the sub-list for method output_type + 8, // [8:21] 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 } func init() { file_organize_proto_init() } @@ -1628,9 +2523,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: 20, + NumMessages: 37, NumExtensions: 0, - NumServices: 3, + NumServices: 5, }, 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 a58635a..92112d1 100644 --- a/pb/organize.pb.validate.go +++ b/pb/organize.pb.validate.go @@ -119,6 +119,17 @@ func (m *Menu) validate(all bool) error { // no validation rules for Public + if utf8.RuneCountInString(m.GetDescription()) > 1024 { + err := MenuValidationError{ + field: "Description", + reason: "value length must be at most 1024 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + if len(errors) > 0 { return MenuMultiError(errors) } @@ -905,6 +916,246 @@ var _ interface { ErrorName() string } = DepartmentValidationError{} +// Validate checks the field values on Setting 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 *Setting) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Setting 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 SettingMultiError, or nil if none found. +func (m *Setting) ValidateAll() error { + return m.validate(true) +} + +func (m *Setting) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for CreatedAt + + // no validation rules for UpdatedAt + + if utf8.RuneCountInString(m.GetName()) > 20 { + err := SettingValidationError{ + field: "Name", + reason: "value length must be at most 20 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetValue()) > 512 { + err := SettingValidationError{ + field: "Value", + reason: "value length must be at most 512 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetDescription()) > 1024 { + err := SettingValidationError{ + field: "Description", + reason: "value length must be at most 1024 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return SettingMultiError(errors) + } + + return nil +} + +// SettingMultiError is an error wrapping multiple validation errors returned +// by Setting.ValidateAll() if the designated constraints aren't met. +type SettingMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SettingMultiError) 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 SettingMultiError) AllErrors() []error { return m } + +// SettingValidationError is the validation error returned by Setting.Validate +// if the designated constraints aren't met. +type SettingValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SettingValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SettingValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SettingValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SettingValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SettingValidationError) ErrorName() string { return "SettingValidationError" } + +// Error satisfies the builtin error interface +func (e SettingValidationError) 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 %sSetting.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SettingValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SettingValidationError{} + +// Validate checks the field values on LabelValue 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 *LabelValue) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on LabelValue 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 LabelValueMultiError, or +// nil if none found. +func (m *LabelValue) ValidateAll() error { + return m.validate(true) +} + +func (m *LabelValue) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Label + + // no validation rules for Value + + if len(errors) > 0 { + return LabelValueMultiError(errors) + } + + return nil +} + +// LabelValueMultiError is an error wrapping multiple validation errors +// returned by LabelValue.ValidateAll() if the designated constraints aren't met. +type LabelValueMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m LabelValueMultiError) 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 LabelValueMultiError) AllErrors() []error { return m } + +// LabelValueValidationError is the validation error returned by +// LabelValue.Validate if the designated constraints aren't met. +type LabelValueValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e LabelValueValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e LabelValueValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e LabelValueValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e LabelValueValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e LabelValueValidationError) ErrorName() string { return "LabelValueValidationError" } + +// Error satisfies the builtin error interface +func (e LabelValueValidationError) 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 %sLabelValue.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = LabelValueValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = LabelValueValidationError{} + // Validate checks the field values on PermissionItem 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. @@ -1043,6 +1294,8 @@ func (m *MenuItem) validate(all bool) error { // no validation rules for Route + // no validation rules for View + for idx, item := range m.GetPermissions() { _, _ = idx, item @@ -2072,6 +2325,1374 @@ var _ interface { ErrorName() string } = UpdateProfileResponseValidationError{} +// Validate checks the field values on GetPermissionRequest 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 *GetPermissionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPermissionRequest 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 +// GetPermissionRequestMultiError, or nil if none found. +func (m *GetPermissionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPermissionRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Uid + + if len(errors) > 0 { + return GetPermissionRequestMultiError(errors) + } + + return nil +} + +// GetPermissionRequestMultiError is an error wrapping multiple validation +// errors returned by GetPermissionRequest.ValidateAll() if the designated +// constraints aren't met. +type GetPermissionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPermissionRequestMultiError) 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 GetPermissionRequestMultiError) AllErrors() []error { return m } + +// GetPermissionRequestValidationError is the validation error returned by +// GetPermissionRequest.Validate if the designated constraints aren't met. +type GetPermissionRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPermissionRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPermissionRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPermissionRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPermissionRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPermissionRequestValidationError) ErrorName() string { + return "GetPermissionRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPermissionRequestValidationError) 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 %sGetPermissionRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPermissionRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPermissionRequestValidationError{} + +// Validate checks the field values on GetPermissionResponse 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 *GetPermissionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPermissionResponse 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 +// GetPermissionResponseMultiError, or nil if none found. +func (m *GetPermissionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPermissionResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Uid + + if len(errors) > 0 { + return GetPermissionResponseMultiError(errors) + } + + return nil +} + +// GetPermissionResponseMultiError is an error wrapping multiple validation +// errors returned by GetPermissionResponse.ValidateAll() if the designated +// constraints aren't met. +type GetPermissionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPermissionResponseMultiError) 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 GetPermissionResponseMultiError) AllErrors() []error { return m } + +// GetPermissionResponseValidationError is the validation error returned by +// GetPermissionResponse.Validate if the designated constraints aren't met. +type GetPermissionResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPermissionResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPermissionResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPermissionResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPermissionResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPermissionResponseValidationError) ErrorName() string { + return "GetPermissionResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPermissionResponseValidationError) 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 %sGetPermissionResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPermissionResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPermissionResponseValidationError{} + +// Validate checks the field values on GetUserLabelRequest 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 *GetUserLabelRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserLabelRequest 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 +// GetUserLabelRequestMultiError, or nil if none found. +func (m *GetUserLabelRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserLabelRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetUserLabelRequestMultiError(errors) + } + + return nil +} + +// GetUserLabelRequestMultiError is an error wrapping multiple validation +// errors returned by GetUserLabelRequest.ValidateAll() if the designated +// constraints aren't met. +type GetUserLabelRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserLabelRequestMultiError) 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 GetUserLabelRequestMultiError) AllErrors() []error { return m } + +// GetUserLabelRequestValidationError is the validation error returned by +// GetUserLabelRequest.Validate if the designated constraints aren't met. +type GetUserLabelRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUserLabelRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUserLabelRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUserLabelRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUserLabelRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUserLabelRequestValidationError) ErrorName() string { + return "GetUserLabelRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetUserLabelRequestValidationError) 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 %sGetUserLabelRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUserLabelRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUserLabelRequestValidationError{} + +// Validate checks the field values on GetUserLabelResponse 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 *GetUserLabelResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserLabelResponse 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 +// GetUserLabelResponseMultiError, or nil if none found. +func (m *GetUserLabelResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserLabelResponse) 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, GetUserLabelResponseValidationError{ + 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, GetUserLabelResponseValidationError{ + 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 GetUserLabelResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return GetUserLabelResponseMultiError(errors) + } + + return nil +} + +// GetUserLabelResponseMultiError is an error wrapping multiple validation +// errors returned by GetUserLabelResponse.ValidateAll() if the designated +// constraints aren't met. +type GetUserLabelResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserLabelResponseMultiError) 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 GetUserLabelResponseMultiError) AllErrors() []error { return m } + +// GetUserLabelResponseValidationError is the validation error returned by +// GetUserLabelResponse.Validate if the designated constraints aren't met. +type GetUserLabelResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUserLabelResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUserLabelResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUserLabelResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUserLabelResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUserLabelResponseValidationError) ErrorName() string { + return "GetUserLabelResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetUserLabelResponseValidationError) 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 %sGetUserLabelResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUserLabelResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUserLabelResponseValidationError{} + +// Validate checks the field values on GetUserTagRequest 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 *GetUserTagRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserTagRequest 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 +// GetUserTagRequestMultiError, or nil if none found. +func (m *GetUserTagRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserTagRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetUserTagRequestMultiError(errors) + } + + return nil +} + +// GetUserTagRequestMultiError is an error wrapping multiple validation errors +// returned by GetUserTagRequest.ValidateAll() if the designated constraints +// aren't met. +type GetUserTagRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserTagRequestMultiError) 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 GetUserTagRequestMultiError) AllErrors() []error { return m } + +// GetUserTagRequestValidationError is the validation error returned by +// GetUserTagRequest.Validate if the designated constraints aren't met. +type GetUserTagRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUserTagRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUserTagRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUserTagRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUserTagRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUserTagRequestValidationError) ErrorName() string { + return "GetUserTagRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetUserTagRequestValidationError) 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 %sGetUserTagRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUserTagRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUserTagRequestValidationError{} + +// Validate checks the field values on GetUserTagResponse 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 *GetUserTagResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserTagResponse 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 +// GetUserTagResponseMultiError, or nil if none found. +func (m *GetUserTagResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserTagResponse) 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, GetUserTagResponseValidationError{ + 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, GetUserTagResponseValidationError{ + 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 GetUserTagResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return GetUserTagResponseMultiError(errors) + } + + return nil +} + +// GetUserTagResponseMultiError is an error wrapping multiple validation errors +// returned by GetUserTagResponse.ValidateAll() if the designated constraints +// aren't met. +type GetUserTagResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserTagResponseMultiError) 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 GetUserTagResponseMultiError) AllErrors() []error { return m } + +// GetUserTagResponseValidationError is the validation error returned by +// GetUserTagResponse.Validate if the designated constraints aren't met. +type GetUserTagResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUserTagResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUserTagResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUserTagResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUserTagResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUserTagResponseValidationError) ErrorName() string { + return "GetUserTagResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetUserTagResponseValidationError) 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 %sGetUserTagResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUserTagResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUserTagResponseValidationError{} + +// 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. +func (m *GetDepartmentLabelRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetDepartmentLabelRequest 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 +// GetDepartmentLabelRequestMultiError, or nil if none found. +func (m *GetDepartmentLabelRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetDepartmentLabelRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetDepartmentLabelRequestMultiError(errors) + } + + return nil +} + +// GetDepartmentLabelRequestMultiError is an error wrapping multiple validation +// errors returned by GetDepartmentLabelRequest.ValidateAll() if the +// designated constraints aren't met. +type GetDepartmentLabelRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetDepartmentLabelRequestMultiError) 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 GetDepartmentLabelRequestMultiError) AllErrors() []error { return m } + +// GetDepartmentLabelRequestValidationError is the validation error returned by +// GetDepartmentLabelRequest.Validate if the designated constraints aren't met. +type GetDepartmentLabelRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetDepartmentLabelRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetDepartmentLabelRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetDepartmentLabelRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetDepartmentLabelRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetDepartmentLabelRequestValidationError) ErrorName() string { + return "GetDepartmentLabelRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetDepartmentLabelRequestValidationError) 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 %sGetDepartmentLabelRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetDepartmentLabelRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetDepartmentLabelRequestValidationError{} + +// Validate checks the field values on GetDepartmentLabelResponse 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 *GetDepartmentLabelResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetDepartmentLabelResponse 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 +// GetDepartmentLabelResponseMultiError, or nil if none found. +func (m *GetDepartmentLabelResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetDepartmentLabelResponse) 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, GetDepartmentLabelResponseValidationError{ + 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, GetDepartmentLabelResponseValidationError{ + 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 GetDepartmentLabelResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return GetDepartmentLabelResponseMultiError(errors) + } + + return nil +} + +// GetDepartmentLabelResponseMultiError is an error wrapping multiple +// validation errors returned by GetDepartmentLabelResponse.ValidateAll() if +// the designated constraints aren't met. +type GetDepartmentLabelResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetDepartmentLabelResponseMultiError) 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 GetDepartmentLabelResponseMultiError) AllErrors() []error { return m } + +// GetDepartmentLabelResponseValidationError is the validation error returned +// by GetDepartmentLabelResponse.Validate if the designated constraints aren't met. +type GetDepartmentLabelResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetDepartmentLabelResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetDepartmentLabelResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetDepartmentLabelResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetDepartmentLabelResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetDepartmentLabelResponseValidationError) ErrorName() string { + return "GetDepartmentLabelResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetDepartmentLabelResponseValidationError) 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 %sGetDepartmentLabelResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetDepartmentLabelResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetDepartmentLabelResponseValidationError{} + +// 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. +func (m *GetRoleLabelRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetRoleLabelRequest 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 +// GetRoleLabelRequestMultiError, or nil if none found. +func (m *GetRoleLabelRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetRoleLabelRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetRoleLabelRequestMultiError(errors) + } + + return nil +} + +// GetRoleLabelRequestMultiError is an error wrapping multiple validation +// errors returned by GetRoleLabelRequest.ValidateAll() if the designated +// constraints aren't met. +type GetRoleLabelRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetRoleLabelRequestMultiError) 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 GetRoleLabelRequestMultiError) AllErrors() []error { return m } + +// GetRoleLabelRequestValidationError is the validation error returned by +// GetRoleLabelRequest.Validate if the designated constraints aren't met. +type GetRoleLabelRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetRoleLabelRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetRoleLabelRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetRoleLabelRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetRoleLabelRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetRoleLabelRequestValidationError) ErrorName() string { + return "GetRoleLabelRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetRoleLabelRequestValidationError) 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 %sGetRoleLabelRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetRoleLabelRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetRoleLabelRequestValidationError{} + +// Validate checks the field values on GetRoleLabelResponse 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 *GetRoleLabelResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetRoleLabelResponse 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 +// GetRoleLabelResponseMultiError, or nil if none found. +func (m *GetRoleLabelResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetRoleLabelResponse) 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, GetRoleLabelResponseValidationError{ + 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, GetRoleLabelResponseValidationError{ + 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 GetRoleLabelResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return GetRoleLabelResponseMultiError(errors) + } + + return nil +} + +// GetRoleLabelResponseMultiError is an error wrapping multiple validation +// errors returned by GetRoleLabelResponse.ValidateAll() if the designated +// constraints aren't met. +type GetRoleLabelResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetRoleLabelResponseMultiError) 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 GetRoleLabelResponseMultiError) AllErrors() []error { return m } + +// GetRoleLabelResponseValidationError is the validation error returned by +// GetRoleLabelResponse.Validate if the designated constraints aren't met. +type GetRoleLabelResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetRoleLabelResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetRoleLabelResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetRoleLabelResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetRoleLabelResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetRoleLabelResponseValidationError) ErrorName() string { + return "GetRoleLabelResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetRoleLabelResponseValidationError) 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 %sGetRoleLabelResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetRoleLabelResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetRoleLabelResponseValidationError{} + +// Validate checks the field values on GetRolePermissionRequest 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 *GetRolePermissionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetRolePermissionRequest 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 +// GetRolePermissionRequestMultiError, or nil if none found. +func (m *GetRolePermissionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetRolePermissionRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Role + + if len(errors) > 0 { + return GetRolePermissionRequestMultiError(errors) + } + + return nil +} + +// GetRolePermissionRequestMultiError is an error wrapping multiple validation +// errors returned by GetRolePermissionRequest.ValidateAll() if the designated +// constraints aren't met. +type GetRolePermissionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetRolePermissionRequestMultiError) 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 GetRolePermissionRequestMultiError) AllErrors() []error { return m } + +// GetRolePermissionRequestValidationError is the validation error returned by +// GetRolePermissionRequest.Validate if the designated constraints aren't met. +type GetRolePermissionRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetRolePermissionRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetRolePermissionRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetRolePermissionRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetRolePermissionRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetRolePermissionRequestValidationError) ErrorName() string { + return "GetRolePermissionRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetRolePermissionRequestValidationError) 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 %sGetRolePermissionRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetRolePermissionRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetRolePermissionRequestValidationError{} + +// Validate checks the field values on GetRolePermissionResponse 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 *GetRolePermissionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetRolePermissionResponse 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 +// GetRolePermissionResponseMultiError, or nil if none found. +func (m *GetRolePermissionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetRolePermissionResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Role + + if len(errors) > 0 { + return GetRolePermissionResponseMultiError(errors) + } + + return nil +} + +// GetRolePermissionResponseMultiError is an error wrapping multiple validation +// errors returned by GetRolePermissionResponse.ValidateAll() if the +// designated constraints aren't met. +type GetRolePermissionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetRolePermissionResponseMultiError) 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 GetRolePermissionResponseMultiError) AllErrors() []error { return m } + +// GetRolePermissionResponseValidationError is the validation error returned by +// GetRolePermissionResponse.Validate if the designated constraints aren't met. +type GetRolePermissionResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetRolePermissionResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetRolePermissionResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetRolePermissionResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetRolePermissionResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetRolePermissionResponseValidationError) ErrorName() string { + return "GetRolePermissionResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetRolePermissionResponseValidationError) 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 %sGetRolePermissionResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetRolePermissionResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetRolePermissionResponseValidationError{} + // 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. @@ -2488,3 +4109,344 @@ var _ interface { Cause() error ErrorName() string } = LogoutResponseValidationError{} + +// Validate checks the field values on SettingItem 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 *SettingItem) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SettingItem 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 SettingItemMultiError, or +// nil if none found. +func (m *SettingItem) ValidateAll() error { + return m.validate(true) +} + +func (m *SettingItem) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Name + + // no validation rules for Value + + if len(errors) > 0 { + return SettingItemMultiError(errors) + } + + return nil +} + +// SettingItemMultiError is an error wrapping multiple validation errors +// returned by SettingItem.ValidateAll() if the designated constraints aren't met. +type SettingItemMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SettingItemMultiError) 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 SettingItemMultiError) AllErrors() []error { return m } + +// SettingItemValidationError is the validation error returned by +// SettingItem.Validate if the designated constraints aren't met. +type SettingItemValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SettingItemValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SettingItemValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SettingItemValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SettingItemValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SettingItemValidationError) ErrorName() string { return "SettingItemValidationError" } + +// Error satisfies the builtin error interface +func (e SettingItemValidationError) 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 %sSettingItem.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SettingItemValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SettingItemValidationError{} + +// Validate checks the field values on GetSettingRequest 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 *GetSettingRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetSettingRequest 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 +// GetSettingRequestMultiError, or nil if none found. +func (m *GetSettingRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetSettingRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetSettingRequestMultiError(errors) + } + + return nil +} + +// GetSettingRequestMultiError is an error wrapping multiple validation errors +// returned by GetSettingRequest.ValidateAll() if the designated constraints +// aren't met. +type GetSettingRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetSettingRequestMultiError) 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 GetSettingRequestMultiError) AllErrors() []error { return m } + +// GetSettingRequestValidationError is the validation error returned by +// GetSettingRequest.Validate if the designated constraints aren't met. +type GetSettingRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetSettingRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetSettingRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetSettingRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetSettingRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetSettingRequestValidationError) ErrorName() string { + return "GetSettingRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetSettingRequestValidationError) 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 %sGetSettingRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetSettingRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetSettingRequestValidationError{} + +// Validate checks the field values on GetSettingResponse 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 *GetSettingResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetSettingResponse 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 +// GetSettingResponseMultiError, or nil if none found. +func (m *GetSettingResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetSettingResponse) 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, GetSettingResponseValidationError{ + 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, GetSettingResponseValidationError{ + 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 GetSettingResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return GetSettingResponseMultiError(errors) + } + + return nil +} + +// GetSettingResponseMultiError is an error wrapping multiple validation errors +// returned by GetSettingResponse.ValidateAll() if the designated constraints +// aren't met. +type GetSettingResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetSettingResponseMultiError) 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 GetSettingResponseMultiError) AllErrors() []error { return m } + +// GetSettingResponseValidationError is the validation error returned by +// GetSettingResponse.Validate if the designated constraints aren't met. +type GetSettingResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetSettingResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetSettingResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetSettingResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetSettingResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetSettingResponseValidationError) ErrorName() string { + return "GetSettingResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetSettingResponseValidationError) 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 %sGetSettingResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetSettingResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetSettingResponseValidationError{} diff --git a/pb/organize.proto b/pb/organize.proto index 3885e98..7b58e23 100644 --- a/pb/organize.proto +++ b/pb/organize.proto @@ -14,15 +14,16 @@ message Menu { option (aeus.rest) = { table: "menus" }; - int64 id = 1 [(aeus.field) = {gorm:"primaryKey"}]; - int64 parent_id = 2; - string name = 3 [(aeus.field)={gorm:"index;size:60"},(validate.rules).string = {max_len: 60}]; - string label = 4 [(aeus.field)={gorm:"size:120"},(validate.rules).string = {max_len: 120}]; - string uri = 5 [(aeus.field)={gorm:"size:512"},(validate.rules).string = {max_len: 512}]; - string view_path = 6 [(aeus.field)={gorm:"size:512"},(validate.rules).string = {max_len: 512}]; - string icon = 7 [(aeus.field)={gorm:"size:60"},(validate.rules).string = {max_len: 60}]; - bool hidden = 8; - bool public = 9; + int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment:"菜单ID"}]; + int64 parent_id = 2 [(aeus.field)={comment:"父级菜单"}]; + string name = 3 [(aeus.field)={gorm:"index;size:60",props:"readonly:update",rule:"required",comment: "组件名称"},(validate.rules).string = {max_len: 60}]; + string label = 4 [(aeus.field)={gorm:"size:120",rule:"required",comment: "菜单标题"},(validate.rules).string = {max_len: 120}]; + string uri = 5 [(aeus.field)={gorm:"size:512",rule:"required",scenarios:"create;update;view;export",comment: "菜单链接"},(validate.rules).string = {max_len: 512}]; + string view_path = 6 [(aeus.field)={gorm:"size:512",scenarios:"create;update;view;export",comment: "视图路径"},(validate.rules).string = {max_len: 512}]; + string icon = 7 [(aeus.field)={gorm:"size:60",scenarios:"create;update;view;export",comment: "菜单图标"},(validate.rules).string = {max_len: 60}]; + bool hidden = 8 [(aeus.field)={scenarios:"create;update;view;export",comment:"是否隐藏"}]; + bool public = 9 [(aeus.field)={scenarios:"create;update;view;export",comment:"是否公开"}]; + string description = 10 [(aeus.field)={gorm:"size:1024",scenarios:"create;update;view;export;list",format:"textarea",comment: "备注说明"},(validate.rules).string = {max_len: 1024}]; } // Role 角色模型定义 @@ -30,10 +31,10 @@ message Role { option (aeus.rest) = { table: "roles" }; - int64 id = 1 [(aeus.field) = {gorm:"primaryKey"}]; - string name = 2 [(aeus.field)={gorm:"index;size:60"},(validate.rules).string = {max_len: 60}]; - string label = 3 [(aeus.field)={gorm:"size:60"},(validate.rules).string = {max_len: 60}]; - string description = 4 [(aeus.field)={gorm:"size:1024"},(validate.rules).string = {max_len: 1024}]; + int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment: "角色ID"}]; + string name = 2 [(aeus.field)={gorm:"index;size:60",props:"readonly:update",comment: "角色名称"},(validate.rules).string = {max_len: 60}]; + string label = 3 [(aeus.field)={gorm:"size:60",comment: "角色标题"},(validate.rules).string = {max_len: 60}]; + string description = 4 [(aeus.field)={gorm:"size:1024",scenarios:"list;create;update;export",format:"textarea",comment: "备注说明"},(validate.rules).string = {max_len: 1024}]; } // Permission 权限模型定义 @@ -41,10 +42,10 @@ message Permission { option (aeus.rest) = { table: "permissions" }; - int64 id = 1 [(aeus.field) = {gorm:"primaryKey"}]; - int64 menu_id = 2 [(aeus.field)={gorm:"index"}]; - string permission = 3 [(aeus.field)={gorm:"index;size:60"},(validate.rules).string = {max_len: 60}]; - string label = 4 [(aeus.field)={gorm:"size:60"},(validate.rules).string = {max_len: 60}]; + int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment: "权限ID"}]; + int64 menu_id = 2 [(aeus.field)={gorm:"index",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}]; } // RolePermission 角色权限关联表 @@ -52,9 +53,9 @@ message RolePermission { option (aeus.rest) = { table: "role_permissions" }; - int64 id = 1 [(aeus.field) = {gorm:"primaryKey"}]; - string role = 2 [(aeus.field)={gorm:"size:60"},(validate.rules).string = {max_len: 60}]; - int64 permission_id = 3; + int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment: "ID"}]; + string role = 2 [(aeus.field)={gorm:"size:60",rule:"required",comment: "角色名称"},(validate.rules).string = {max_len: 60}]; + int64 permission_id = 3 [(aeus.field)={rule:"required",comment: "权限ID"}]; } // User 用户模型定义 @@ -62,20 +63,20 @@ message User { option (aeus.rest) = { table: "users" }; - int64 id = 1 [(aeus.field) = {gorm:"primaryKey"}]; - int64 created_at = 2; - int64 updated_at = 3; - string uid = 4 [(aeus.field) = {gorm:"index;size:20"},(validate.rules).string = {min_len: 5, max_len: 20}]; - string username = 5 [(aeus.field)={gorm:"size:20"},(validate.rules).string = {min_len: 5, max_len: 20}]; - string role = 6 [(aeus.field)={gorm:"size:60"},(validate.rules).string = {max_len: 60}]; - bool admin = 7; - int64 dept_id = 8 [(aeus.field) = {gorm:"not null;default:0"}]; - string tag = 9 [ (aeus.field)={gorm:"size:60"},(validate.rules).string = {max_len: 60}]; - string password = 10 [(aeus.field)={gorm:"size:60"},(validate.rules).string = {max_len: 60}]; - string email = 11 [(aeus.field)={gorm:"size:60"},(validate.rules).string = {max_len: 60}]; - string avatar = 12 [(aeus.field)={gorm:"size:1024"},(validate.rules).string = {max_len: 1024}]; - string gender = 13 [(aeus.field)={gorm:"size:20;default:man"},(validate.rules).string = {max_len: 20}]; - string description = 14 [(aeus.field)={gorm:"size:1024"},(validate.rules).string = {max_len: 1024}]; + 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)={scenarios:"view;export",comment:"更新时间"}]; + string uid = 4 [(aeus.field) = {gorm:"index;size:20",rule:"required;unique;regexp:^[a-zA-Z0-9]{3,8}$",props:"readonly:update",comment: "用户工号"},(validate.rules).string = {min_len: 5, max_len: 20}]; + string username = 5 [(aeus.field)={gorm:"size:20",rule:"required",comment: "用户名称"},(validate.rules).string = {min_len: 5, max_len: 20}]; + string role = 6 [(aeus.field)={gorm:"size:60",rule:"required",format:"role",comment: "所属角色"},(validate.rules).string = {max_len: 60}]; + bool admin = 7 [(aeus.field)={scenarios:"create",comment:"管理员"}]; + int64 dept_id = 8 [(aeus.field) = {gorm:"not null;default:0",rule:"required",format:"department",comment: "所属部门"}]; + string tag = 9 [ (aeus.field)={gorm:"size:60",scenarios:"list;create;update",comment: "用户标签"},(validate.rules).string = {max_len: 60}]; + string password = 10 [(aeus.field)={gorm:"size:60",rule:"required",scenarios:"create",comment: "用户密码"},(validate.rules).string = {max_len: 60}]; + string email = 11 [(aeus.field)={gorm:"size:60",scenarios:"create;update;view;list;export",comment: "用户邮箱"},(validate.rules).string = {max_len: 60}]; + string avatar = 12 [(aeus.field)={gorm:"size:1024",scenarios:"view",comment: "用户头像"},(validate.rules).string = {max_len: 1024}]; + string gender = 13 [(aeus.field)={gorm:"size:20;default:man",rule:"required",scenarios:"list;create;update;view;export",comment: "用户性别"},(validate.rules).string = {max_len: 20}]; + string description = 14 [(aeus.field)={gorm:"size:1024",format:"textarea",scenarios:"create;update;view;export",comment: "备注说明"},(validate.rules).string = {max_len: 1024}]; } // Department 部门模型定义 @@ -83,14 +84,32 @@ message Department { option (aeus.rest) = { table: "departments" }; - int64 id = 1 [(aeus.field) = {gorm:"primaryKey"}]; - int64 created_at = 2; - int64 updated_at = 3; - int64 parent_id = 4; - string name = 5 [(aeus.field)={gorm:"size:20"},(validate.rules).string = {max_len: 20}]; - string description = 6 [(aeus.field)={gorm:"size:1024"},(validate.rules).string = {max_len: 1024}]; + 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)={scenarios:"view;export",comment:"更新时间"}]; + int64 parent_id = 4 [(aeus.field)={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}]; } +// Setting 参数设置表 +message Setting { + option (aeus.rest) = { + table: "settings" + }; + int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment:"ID"}]; + int64 created_at = 2 [(aeus.field)={scenarios:"search;view;export",comment:"创建时间"}]; + int64 updated_at = 3 [(aeus.field)={scenarios:"search;view;export",comment:"更新时间"}]; + string name = 4 [(aeus.field)={gorm:"size:60",rule:"required",props:"readonly:update",comment: "配置项"},(validate.rules).string = {max_len: 20}]; + string value = 5 [(aeus.field)={gorm:"size:512",rule:"required",format:"textarea",comment: "配置值"},(validate.rules).string = {max_len: 512}]; + string description = 6 [(aeus.field)={gorm:"size:1024",format:"textarea",scenarios:"create;update;view;export",comment: "备注说明"},(validate.rules).string = {max_len: 1024}]; +} + + +message LabelValue { + string label = 1; + string value = 2; +} message PermissionItem { string value = 1; @@ -105,8 +124,9 @@ message MenuItem { bool hidden = 4; bool public = 5; string route = 6; - repeated PermissionItem permissions = 7; - repeated MenuItem children = 8; + string view = 7; + repeated PermissionItem permissions = 8; + repeated MenuItem children = 9; } // 获取菜单的请求 @@ -119,15 +139,6 @@ message GetMenuResponse { repeated MenuItem data = 1; } -// 菜单服务 -service MenuService { - rpc GetMenus(GetMenuRequest) returns (GetMenuResponse) { - option (google.api.http) = { - get: "/api/menu" - }; - } -} - // 获取用户信息 message GetProfileRequest { @@ -167,25 +178,123 @@ message UpdateProfileResponse { string uid = 1; } +message GetPermissionRequest { + string uid = 1; +} + +message GetPermissionResponse { + string uid = 1; + repeated string permissions = 2; +} + +message GetUserLabelRequest { +} + +message GetUserLabelResponse { + repeated LabelValue data = 1; +} + +message GetUserTagRequest { +} + +message GetUserTagResponse { + repeated LabelValue data = 1; +} + // 用户服务 -service ProfileService { +service UserService { + // 获取用户菜单 + rpc GetMenus(GetMenuRequest) returns (GetMenuResponse) { + option (google.api.http) = { + get: "/user/menus" + }; + } + // 获取用户信息 rpc GetProfile(GetProfileRequest) returns (GetProfileResponse) { option (google.api.http) = { get: "/user/profile" }; } + // 更新用户信息 rpc UpdateProfile(UpdateProfileRequest) returns (UpdateProfileResponse) { option (google.api.http) = { put: "/user/profile" body: "*" }; } + // 重置用户密码 rpc ResetPassword(ResetPasswordRequest) returns (ResetPasswordResponse) { option (google.api.http) = { post: "/user/reset-password" body: "*" }; } + // 获取用户权限 + rpc GetPermissions(GetPermissionRequest) returns (GetPermissionResponse) { + option (google.api.http) = { + get: "/user/permissions" + }; + } + // 获取用户标签 + rpc GetUserLabels(GetUserLabelRequest) returns (GetUserLabelResponse) { + option (google.api.http) = { + get: "/user/labels" + }; + } + // 获取用户标签 + rpc GetUserTags(GetUserTagRequest) returns (GetUserTagResponse) { + option (google.api.http) = { + get: "/user/tags" + }; + } +} + + +message GetDepartmentLabelRequest { +} + +message GetDepartmentLabelResponse { + repeated LabelValue data = 1; +} + +service DepartmentService { + // 获取部门标签 + rpc GetDepartmentLabels(GetDepartmentLabelRequest) returns (GetDepartmentLabelResponse) { + option (google.api.http) = { + get: "/department/labels" + }; + } +} + +message GetRoleLabelRequest { +} + +message GetRoleLabelResponse { + repeated LabelValue data = 1; +} + +message GetRolePermissionRequest { + string role = 1; +} + +message GetRolePermissionResponse { + string role = 1; + repeated string permissions = 2; +} + +service RoleService { + // 获取角色标签 + rpc GetRoleLabels(GetRoleLabelRequest) returns (GetRoleLabelResponse) { + option (google.api.http) = { + get: "/role/labels" + }; + } + // 获取角色权限 + rpc GetRolePermissions(GetRolePermissionRequest) returns (GetRolePermissionResponse) { + option (google.api.http) = { + get: "/role/permissions" + }; + } } @@ -224,4 +333,23 @@ service AuthService { body: "*" }; } +} + +message SettingItem { + string name = 1; + string value = 2; +} + +message GetSettingRequest{} + +message GetSettingResponse{ + repeated SettingItem data = 1; +} + +service SettingService { + rpc GetSetting(GetSettingRequest) returns (GetSettingResponse) { + option (google.api.http) = { + get: "/system/setting" + }; + } } \ No newline at end of file diff --git a/pb/organize_grpc.pb.go b/pb/organize_grpc.pb.go index d0db9f6..743f7eb 100644 --- a/pb/organize_grpc.pb.go +++ b/pb/organize_grpc.pb.go @@ -19,105 +19,347 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - MenuService_GetMenus_FullMethodName = "/organize.MenuService/GetMenus" + UserService_GetMenus_FullMethodName = "/organize.UserService/GetMenus" + UserService_GetProfile_FullMethodName = "/organize.UserService/GetProfile" + UserService_UpdateProfile_FullMethodName = "/organize.UserService/UpdateProfile" + UserService_ResetPassword_FullMethodName = "/organize.UserService/ResetPassword" + UserService_GetPermissions_FullMethodName = "/organize.UserService/GetPermissions" + UserService_GetUserLabels_FullMethodName = "/organize.UserService/GetUserLabels" + UserService_GetUserTags_FullMethodName = "/organize.UserService/GetUserTags" ) -// MenuServiceClient is the client API for MenuService service. +// UserServiceClient is the client API for UserService 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 { +// 用户服务 +type UserServiceClient interface { + // 获取用户菜单 GetMenus(ctx context.Context, in *GetMenuRequest, opts ...grpc.CallOption) (*GetMenuResponse, error) + // 获取用户信息 + GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*GetProfileResponse, error) + // 更新用户信息 + UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...grpc.CallOption) (*UpdateProfileResponse, error) + // 重置用户密码 + ResetPassword(ctx context.Context, in *ResetPasswordRequest, opts ...grpc.CallOption) (*ResetPasswordResponse, error) + // 获取用户权限 + GetPermissions(ctx context.Context, in *GetPermissionRequest, opts ...grpc.CallOption) (*GetPermissionResponse, error) + // 获取用户标签 + GetUserLabels(ctx context.Context, in *GetUserLabelRequest, opts ...grpc.CallOption) (*GetUserLabelResponse, error) + // 获取用户标签 + GetUserTags(ctx context.Context, in *GetUserTagRequest, opts ...grpc.CallOption) (*GetUserTagResponse, error) } -type menuServiceClient struct { +type userServiceClient struct { cc grpc.ClientConnInterface } -func NewMenuServiceClient(cc grpc.ClientConnInterface) MenuServiceClient { - return &menuServiceClient{cc} +func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient { + return &userServiceClient{cc} } -func (c *menuServiceClient) GetMenus(ctx context.Context, in *GetMenuRequest, opts ...grpc.CallOption) (*GetMenuResponse, error) { +func (c *userServiceClient) GetMenus(ctx context.Context, in *GetMenuRequest, opts ...grpc.CallOption) (*GetMenuResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetMenuResponse) - err := c.cc.Invoke(ctx, MenuService_GetMenus_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, UserService_GetMenus_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 { - GetMenus(context.Context, *GetMenuRequest) (*GetMenuResponse, error) - mustEmbedUnimplementedMenuServiceServer() +func (c *userServiceClient) GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*GetProfileResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetProfileResponse) + err := c.cc.Invoke(ctx, UserService_GetProfile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil } -// UnimplementedMenuServiceServer must be embedded to have +func (c *userServiceClient) UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...grpc.CallOption) (*UpdateProfileResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateProfileResponse) + err := c.cc.Invoke(ctx, UserService_UpdateProfile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) ResetPassword(ctx context.Context, in *ResetPasswordRequest, opts ...grpc.CallOption) (*ResetPasswordResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ResetPasswordResponse) + err := c.cc.Invoke(ctx, UserService_ResetPassword_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) GetPermissions(ctx context.Context, in *GetPermissionRequest, opts ...grpc.CallOption) (*GetPermissionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetPermissionResponse) + err := c.cc.Invoke(ctx, UserService_GetPermissions_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) GetUserLabels(ctx context.Context, in *GetUserLabelRequest, opts ...grpc.CallOption) (*GetUserLabelResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetUserLabelResponse) + err := c.cc.Invoke(ctx, UserService_GetUserLabels_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) GetUserTags(ctx context.Context, in *GetUserTagRequest, opts ...grpc.CallOption) (*GetUserTagResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetUserTagResponse) + err := c.cc.Invoke(ctx, UserService_GetUserTags_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// UserServiceServer is the server API for UserService service. +// All implementations must embed UnimplementedUserServiceServer +// for forward compatibility. +// +// 用户服务 +type UserServiceServer interface { + // 获取用户菜单 + GetMenus(context.Context, *GetMenuRequest) (*GetMenuResponse, error) + // 获取用户信息 + GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) + // 更新用户信息 + UpdateProfile(context.Context, *UpdateProfileRequest) (*UpdateProfileResponse, error) + // 重置用户密码 + ResetPassword(context.Context, *ResetPasswordRequest) (*ResetPasswordResponse, error) + // 获取用户权限 + GetPermissions(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) + // 获取用户标签 + GetUserLabels(context.Context, *GetUserLabelRequest) (*GetUserLabelResponse, error) + // 获取用户标签 + GetUserTags(context.Context, *GetUserTagRequest) (*GetUserTagResponse, error) + mustEmbedUnimplementedUserServiceServer() +} + +// UnimplementedUserServiceServer 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{} +type UnimplementedUserServiceServer struct{} -func (UnimplementedMenuServiceServer) GetMenus(context.Context, *GetMenuRequest) (*GetMenuResponse, error) { +func (UnimplementedUserServiceServer) GetMenus(context.Context, *GetMenuRequest) (*GetMenuResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetMenus not implemented") } -func (UnimplementedMenuServiceServer) mustEmbedUnimplementedMenuServiceServer() {} -func (UnimplementedMenuServiceServer) testEmbeddedByValue() {} +func (UnimplementedUserServiceServer) GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProfile not implemented") +} +func (UnimplementedUserServiceServer) UpdateProfile(context.Context, *UpdateProfileRequest) (*UpdateProfileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateProfile not implemented") +} +func (UnimplementedUserServiceServer) ResetPassword(context.Context, *ResetPasswordRequest) (*ResetPasswordResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ResetPassword not implemented") +} +func (UnimplementedUserServiceServer) GetPermissions(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPermissions not implemented") +} +func (UnimplementedUserServiceServer) GetUserLabels(context.Context, *GetUserLabelRequest) (*GetUserLabelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetUserLabels not implemented") +} +func (UnimplementedUserServiceServer) GetUserTags(context.Context, *GetUserTagRequest) (*GetUserTagResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetUserTags not implemented") +} +func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {} +func (UnimplementedUserServiceServer) 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 +// UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to UserServiceServer will // result in compilation errors. -type UnsafeMenuServiceServer interface { - mustEmbedUnimplementedMenuServiceServer() +type UnsafeUserServiceServer interface { + mustEmbedUnimplementedUserServiceServer() } -func RegisterMenuServiceServer(s grpc.ServiceRegistrar, srv MenuServiceServer) { - // If the following call pancis, it indicates UnimplementedMenuServiceServer was +func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) { + // If the following call pancis, it indicates UnimplementedUserServiceServer 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) + s.RegisterService(&UserService_ServiceDesc, srv) } -func _MenuService_GetMenus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _UserService_GetMenus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetMenuRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MenuServiceServer).GetMenus(ctx, in) + return srv.(UserServiceServer).GetMenus(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: MenuService_GetMenus_FullMethodName, + FullMethod: UserService_GetMenus_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MenuServiceServer).GetMenus(ctx, req.(*GetMenuRequest)) + return srv.(UserServiceServer).GetMenus(ctx, req.(*GetMenuRequest)) } return interceptor(ctx, in, info, handler) } -// MenuService_ServiceDesc is the grpc.ServiceDesc for MenuService service. +func _UserService_GetProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).GetProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_GetProfile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).GetProfile(ctx, req.(*GetProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_UpdateProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).UpdateProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_UpdateProfile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).UpdateProfile(ctx, req.(*UpdateProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_ResetPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ResetPasswordRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).ResetPassword(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_ResetPassword_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).ResetPassword(ctx, req.(*ResetPasswordRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_GetPermissions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPermissionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).GetPermissions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_GetPermissions_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).GetPermissions(ctx, req.(*GetPermissionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_GetUserLabels_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUserLabelRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).GetUserLabels(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_GetUserLabels_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).GetUserLabels(ctx, req.(*GetUserLabelRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_GetUserTags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUserTagRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).GetUserTags(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_GetUserTags_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).GetUserTags(ctx, req.(*GetUserTagRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// UserService_ServiceDesc is the grpc.ServiceDesc for UserService 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), +var UserService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "organize.UserService", + HandlerType: (*UserServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "GetMenus", - Handler: _MenuService_GetMenus_Handler, + Handler: _UserService_GetMenus_Handler, + }, + { + MethodName: "GetProfile", + Handler: _UserService_GetProfile_Handler, + }, + { + MethodName: "UpdateProfile", + Handler: _UserService_UpdateProfile_Handler, + }, + { + MethodName: "ResetPassword", + Handler: _UserService_ResetPassword_Handler, + }, + { + MethodName: "GetPermissions", + Handler: _UserService_GetPermissions_Handler, + }, + { + MethodName: "GetUserLabels", + Handler: _UserService_GetUserLabels_Handler, + }, + { + MethodName: "GetUserTags", + Handler: _UserService_GetUserTags_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -125,181 +367,247 @@ var MenuService_ServiceDesc = grpc.ServiceDesc{ } const ( - ProfileService_GetProfile_FullMethodName = "/organize.ProfileService/GetProfile" - ProfileService_UpdateProfile_FullMethodName = "/organize.ProfileService/UpdateProfile" - ProfileService_ResetPassword_FullMethodName = "/organize.ProfileService/ResetPassword" + DepartmentService_GetDepartmentLabels_FullMethodName = "/organize.DepartmentService/GetDepartmentLabels" ) -// ProfileServiceClient is the client API for ProfileService service. +// DepartmentServiceClient is the client API for DepartmentService 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 ProfileServiceClient interface { - GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*GetProfileResponse, error) - UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...grpc.CallOption) (*UpdateProfileResponse, error) - ResetPassword(ctx context.Context, in *ResetPasswordRequest, opts ...grpc.CallOption) (*ResetPasswordResponse, error) +type DepartmentServiceClient interface { + // 获取部门标签 + GetDepartmentLabels(ctx context.Context, in *GetDepartmentLabelRequest, opts ...grpc.CallOption) (*GetDepartmentLabelResponse, error) } -type profileServiceClient struct { +type departmentServiceClient struct { cc grpc.ClientConnInterface } -func NewProfileServiceClient(cc grpc.ClientConnInterface) ProfileServiceClient { - return &profileServiceClient{cc} +func NewDepartmentServiceClient(cc grpc.ClientConnInterface) DepartmentServiceClient { + return &departmentServiceClient{cc} } -func (c *profileServiceClient) GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*GetProfileResponse, error) { +func (c *departmentServiceClient) GetDepartmentLabels(ctx context.Context, in *GetDepartmentLabelRequest, opts ...grpc.CallOption) (*GetDepartmentLabelResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetProfileResponse) - err := c.cc.Invoke(ctx, ProfileService_GetProfile_FullMethodName, in, out, cOpts...) + out := new(GetDepartmentLabelResponse) + err := c.cc.Invoke(ctx, DepartmentService_GetDepartmentLabels_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *profileServiceClient) UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...grpc.CallOption) (*UpdateProfileResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdateProfileResponse) - err := c.cc.Invoke(ctx, ProfileService_UpdateProfile_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *profileServiceClient) ResetPassword(ctx context.Context, in *ResetPasswordRequest, opts ...grpc.CallOption) (*ResetPasswordResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ResetPasswordResponse) - err := c.cc.Invoke(ctx, ProfileService_ResetPassword_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ProfileServiceServer is the server API for ProfileService service. -// All implementations must embed UnimplementedProfileServiceServer +// DepartmentServiceServer is the server API for DepartmentService service. +// All implementations must embed UnimplementedDepartmentServiceServer // for forward compatibility. -// -// 用户服务 -type ProfileServiceServer interface { - GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) - UpdateProfile(context.Context, *UpdateProfileRequest) (*UpdateProfileResponse, error) - ResetPassword(context.Context, *ResetPasswordRequest) (*ResetPasswordResponse, error) - mustEmbedUnimplementedProfileServiceServer() +type DepartmentServiceServer interface { + // 获取部门标签 + GetDepartmentLabels(context.Context, *GetDepartmentLabelRequest) (*GetDepartmentLabelResponse, error) + mustEmbedUnimplementedDepartmentServiceServer() } -// UnimplementedProfileServiceServer must be embedded to have +// UnimplementedDepartmentServiceServer 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 UnimplementedProfileServiceServer struct{} +type UnimplementedDepartmentServiceServer struct{} -func (UnimplementedProfileServiceServer) GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetProfile not implemented") +func (UnimplementedDepartmentServiceServer) GetDepartmentLabels(context.Context, *GetDepartmentLabelRequest) (*GetDepartmentLabelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetDepartmentLabels not implemented") } -func (UnimplementedProfileServiceServer) UpdateProfile(context.Context, *UpdateProfileRequest) (*UpdateProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateProfile not implemented") -} -func (UnimplementedProfileServiceServer) ResetPassword(context.Context, *ResetPasswordRequest) (*ResetPasswordResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ResetPassword not implemented") -} -func (UnimplementedProfileServiceServer) mustEmbedUnimplementedProfileServiceServer() {} -func (UnimplementedProfileServiceServer) testEmbeddedByValue() {} +func (UnimplementedDepartmentServiceServer) mustEmbedUnimplementedDepartmentServiceServer() {} +func (UnimplementedDepartmentServiceServer) testEmbeddedByValue() {} -// UnsafeProfileServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ProfileServiceServer will +// UnsafeDepartmentServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to DepartmentServiceServer will // result in compilation errors. -type UnsafeProfileServiceServer interface { - mustEmbedUnimplementedProfileServiceServer() +type UnsafeDepartmentServiceServer interface { + mustEmbedUnimplementedDepartmentServiceServer() } -func RegisterProfileServiceServer(s grpc.ServiceRegistrar, srv ProfileServiceServer) { - // If the following call pancis, it indicates UnimplementedProfileServiceServer was +func RegisterDepartmentServiceServer(s grpc.ServiceRegistrar, srv DepartmentServiceServer) { + // If the following call pancis, it indicates UnimplementedDepartmentServiceServer 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(&ProfileService_ServiceDesc, srv) + s.RegisterService(&DepartmentService_ServiceDesc, srv) } -func _ProfileService_GetProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetProfileRequest) +func _DepartmentService_GetDepartmentLabels_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetDepartmentLabelRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ProfileServiceServer).GetProfile(ctx, in) + return srv.(DepartmentServiceServer).GetDepartmentLabels(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: ProfileService_GetProfile_FullMethodName, + FullMethod: DepartmentService_GetDepartmentLabels_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProfileServiceServer).GetProfile(ctx, req.(*GetProfileRequest)) + return srv.(DepartmentServiceServer).GetDepartmentLabels(ctx, req.(*GetDepartmentLabelRequest)) } return interceptor(ctx, in, info, handler) } -func _ProfileService_UpdateProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateProfileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProfileServiceServer).UpdateProfile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ProfileService_UpdateProfile_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProfileServiceServer).UpdateProfile(ctx, req.(*UpdateProfileRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _ProfileService_ResetPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ResetPasswordRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProfileServiceServer).ResetPassword(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ProfileService_ResetPassword_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProfileServiceServer).ResetPassword(ctx, req.(*ResetPasswordRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// ProfileService_ServiceDesc is the grpc.ServiceDesc for ProfileService service. +// 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) -var ProfileService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "organize.ProfileService", - HandlerType: (*ProfileServiceServer)(nil), +var DepartmentService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "organize.DepartmentService", + HandlerType: (*DepartmentServiceServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "GetProfile", - Handler: _ProfileService_GetProfile_Handler, + MethodName: "GetDepartmentLabels", + Handler: _DepartmentService_GetDepartmentLabels_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "organize.proto", +} + +const ( + RoleService_GetRoleLabels_FullMethodName = "/organize.RoleService/GetRoleLabels" + RoleService_GetRolePermissions_FullMethodName = "/organize.RoleService/GetRolePermissions" +) + +// RoleServiceClient is the client API for RoleService 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 RoleServiceClient interface { + // 获取角色标签 + GetRoleLabels(ctx context.Context, in *GetRoleLabelRequest, opts ...grpc.CallOption) (*GetRoleLabelResponse, error) + // 获取角色权限 + GetRolePermissions(ctx context.Context, in *GetRolePermissionRequest, opts ...grpc.CallOption) (*GetRolePermissionResponse, error) +} + +type roleServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewRoleServiceClient(cc grpc.ClientConnInterface) RoleServiceClient { + return &roleServiceClient{cc} +} + +func (c *roleServiceClient) GetRoleLabels(ctx context.Context, in *GetRoleLabelRequest, opts ...grpc.CallOption) (*GetRoleLabelResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetRoleLabelResponse) + err := c.cc.Invoke(ctx, RoleService_GetRoleLabels_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *roleServiceClient) GetRolePermissions(ctx context.Context, in *GetRolePermissionRequest, opts ...grpc.CallOption) (*GetRolePermissionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetRolePermissionResponse) + err := c.cc.Invoke(ctx, RoleService_GetRolePermissions_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// RoleServiceServer is the server API for RoleService service. +// All implementations must embed UnimplementedRoleServiceServer +// for forward compatibility. +type RoleServiceServer interface { + // 获取角色标签 + GetRoleLabels(context.Context, *GetRoleLabelRequest) (*GetRoleLabelResponse, error) + // 获取角色权限 + GetRolePermissions(context.Context, *GetRolePermissionRequest) (*GetRolePermissionResponse, error) + mustEmbedUnimplementedRoleServiceServer() +} + +// UnimplementedRoleServiceServer 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 UnimplementedRoleServiceServer struct{} + +func (UnimplementedRoleServiceServer) GetRoleLabels(context.Context, *GetRoleLabelRequest) (*GetRoleLabelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetRoleLabels not implemented") +} +func (UnimplementedRoleServiceServer) GetRolePermissions(context.Context, *GetRolePermissionRequest) (*GetRolePermissionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetRolePermissions not implemented") +} +func (UnimplementedRoleServiceServer) mustEmbedUnimplementedRoleServiceServer() {} +func (UnimplementedRoleServiceServer) testEmbeddedByValue() {} + +// UnsafeRoleServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to RoleServiceServer will +// result in compilation errors. +type UnsafeRoleServiceServer interface { + mustEmbedUnimplementedRoleServiceServer() +} + +func RegisterRoleServiceServer(s grpc.ServiceRegistrar, srv RoleServiceServer) { + // If the following call pancis, it indicates UnimplementedRoleServiceServer 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(&RoleService_ServiceDesc, srv) +} + +func _RoleService_GetRoleLabels_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRoleLabelRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RoleServiceServer).GetRoleLabels(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RoleService_GetRoleLabels_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RoleServiceServer).GetRoleLabels(ctx, req.(*GetRoleLabelRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _RoleService_GetRolePermissions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRolePermissionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RoleServiceServer).GetRolePermissions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RoleService_GetRolePermissions_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RoleServiceServer).GetRolePermissions(ctx, req.(*GetRolePermissionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// RoleService_ServiceDesc is the grpc.ServiceDesc for RoleService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var RoleService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "organize.RoleService", + HandlerType: (*RoleServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetRoleLabels", + Handler: _RoleService_GetRoleLabels_Handler, }, { - MethodName: "UpdateProfile", - Handler: _ProfileService_UpdateProfile_Handler, - }, - { - MethodName: "ResetPassword", - Handler: _ProfileService_ResetPassword_Handler, + MethodName: "GetRolePermissions", + Handler: _RoleService_GetRolePermissions_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -449,3 +757,105 @@ var AuthService_ServiceDesc = grpc.ServiceDesc{ Streams: []grpc.StreamDesc{}, Metadata: "organize.proto", } + +const ( + SettingService_GetSetting_FullMethodName = "/organize.SettingService/GetSetting" +) + +// SettingServiceClient is the client API for SettingService 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 SettingServiceClient interface { + GetSetting(ctx context.Context, in *GetSettingRequest, opts ...grpc.CallOption) (*GetSettingResponse, error) +} + +type settingServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewSettingServiceClient(cc grpc.ClientConnInterface) SettingServiceClient { + return &settingServiceClient{cc} +} + +func (c *settingServiceClient) GetSetting(ctx context.Context, in *GetSettingRequest, opts ...grpc.CallOption) (*GetSettingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetSettingResponse) + err := c.cc.Invoke(ctx, SettingService_GetSetting_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// SettingServiceServer is the server API for SettingService service. +// All implementations must embed UnimplementedSettingServiceServer +// for forward compatibility. +type SettingServiceServer interface { + GetSetting(context.Context, *GetSettingRequest) (*GetSettingResponse, error) + mustEmbedUnimplementedSettingServiceServer() +} + +// UnimplementedSettingServiceServer 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 UnimplementedSettingServiceServer struct{} + +func (UnimplementedSettingServiceServer) GetSetting(context.Context, *GetSettingRequest) (*GetSettingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetSetting not implemented") +} +func (UnimplementedSettingServiceServer) mustEmbedUnimplementedSettingServiceServer() {} +func (UnimplementedSettingServiceServer) testEmbeddedByValue() {} + +// UnsafeSettingServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to SettingServiceServer will +// result in compilation errors. +type UnsafeSettingServiceServer interface { + mustEmbedUnimplementedSettingServiceServer() +} + +func RegisterSettingServiceServer(s grpc.ServiceRegistrar, srv SettingServiceServer) { + // If the following call pancis, it indicates UnimplementedSettingServiceServer 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(&SettingService_ServiceDesc, srv) +} + +func _SettingService_GetSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetSettingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SettingServiceServer).GetSetting(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SettingService_GetSetting_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SettingServiceServer).GetSetting(ctx, req.(*GetSettingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// SettingService_ServiceDesc is the grpc.ServiceDesc for SettingService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var SettingService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "organize.SettingService", + HandlerType: (*SettingServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetSetting", + Handler: _SettingService_GetSetting_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "organize.proto", +} diff --git a/pb/organize_http.pb.go b/pb/organize_http.pb.go index de4b6dc..4312532 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-13 11:10:07 +// date: 2025-06-16 11:37:44 package pb @@ -10,16 +10,30 @@ import ( "git.nobla.cn/golang/aeus/pkg/errors" ) -type MenuServiceHttpServer interface { +type UserServiceHttpServer interface { GetMenus(context.Context, *GetMenuRequest) (*GetMenuResponse, error) -} -type ProfileServiceHttpServer interface { GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) UpdateProfile(context.Context, *UpdateProfileRequest) (*UpdateProfileResponse, error) ResetPassword(context.Context, *ResetPasswordRequest) (*ResetPasswordResponse, error) + + GetPermissions(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) + + GetUserLabels(context.Context, *GetUserLabelRequest) (*GetUserLabelResponse, error) + + GetUserTags(context.Context, *GetUserTagRequest) (*GetUserTagResponse, error) +} + +type DepartmentServiceHttpServer interface { + GetDepartmentLabels(context.Context, *GetDepartmentLabelRequest) (*GetDepartmentLabelResponse, error) +} + +type RoleServiceHttpServer interface { + GetRoleLabels(context.Context, *GetRoleLabelRequest) (*GetRoleLabelResponse, error) + + GetRolePermissions(context.Context, *GetRolePermissionRequest) (*GetRolePermissionResponse, error) } type AuthServiceHttpServer interface { @@ -28,7 +42,13 @@ type AuthServiceHttpServer interface { Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) } -func handleMenuServiceGetMenus(s MenuServiceHttpServer) http.HandleFunc { +type SettingServiceHttpServer interface { + GetSetting(context.Context, *GetSettingRequest) (*GetSettingResponse, error) +} + +// 获取用户菜单 + +func handleUserServiceGetMenus(s UserServiceHttpServer) http.HandleFunc { return func(ctx *http.Context) (err error) { req := &GetMenuRequest{} @@ -48,7 +68,9 @@ func handleMenuServiceGetMenus(s MenuServiceHttpServer) http.HandleFunc { } } -func handleProfileServiceGetProfile(s ProfileServiceHttpServer) http.HandleFunc { +// 获取用户信息 + +func handleUserServiceGetProfile(s UserServiceHttpServer) http.HandleFunc { return func(ctx *http.Context) (err error) { req := &GetProfileRequest{} @@ -68,7 +90,9 @@ func handleProfileServiceGetProfile(s ProfileServiceHttpServer) http.HandleFunc } } -func handleProfileServiceUpdateProfile(s ProfileServiceHttpServer) http.HandleFunc { +// 更新用户信息 + +func handleUserServiceUpdateProfile(s UserServiceHttpServer) http.HandleFunc { return func(ctx *http.Context) (err error) { req := &UpdateProfileRequest{} @@ -88,7 +112,9 @@ func handleProfileServiceUpdateProfile(s ProfileServiceHttpServer) http.HandleFu } } -func handleProfileServiceResetPassword(s ProfileServiceHttpServer) http.HandleFunc { +// 重置用户密码 + +func handleUserServiceResetPassword(s UserServiceHttpServer) http.HandleFunc { return func(ctx *http.Context) (err error) { req := &ResetPasswordRequest{} @@ -108,6 +134,122 @@ func handleProfileServiceResetPassword(s ProfileServiceHttpServer) http.HandleFu } } +// 获取用户权限 + +func handleUserServiceGetPermissions(s UserServiceHttpServer) http.HandleFunc { + return func(ctx *http.Context) (err error) { + req := &GetPermissionRequest{} + + if err := ctx.Bind(req); err != nil { + return ctx.Error(errors.Invalid, err.Error()) + } + + if res, err := s.GetPermissions(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 handleUserServiceGetUserLabels(s UserServiceHttpServer) http.HandleFunc { + return func(ctx *http.Context) (err error) { + req := &GetUserLabelRequest{} + + if res, err := s.GetUserLabels(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 handleUserServiceGetUserTags(s UserServiceHttpServer) http.HandleFunc { + return func(ctx *http.Context) (err error) { + req := &GetUserTagRequest{} + + if res, err := s.GetUserTags(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 handleDepartmentServiceGetDepartmentLabels(s DepartmentServiceHttpServer) http.HandleFunc { + return func(ctx *http.Context) (err error) { + req := &GetDepartmentLabelRequest{} + + if res, err := s.GetDepartmentLabels(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 { + return func(ctx *http.Context) (err error) { + req := &GetRoleLabelRequest{} + + if res, err := s.GetRoleLabels(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 handleRoleServiceGetRolePermissions(s RoleServiceHttpServer) http.HandleFunc { + return func(ctx *http.Context) (err error) { + req := &GetRolePermissionRequest{} + + if err := ctx.Bind(req); err != nil { + return ctx.Error(errors.Invalid, err.Error()) + } + + if res, err := s.GetRolePermissions(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{} @@ -148,23 +290,61 @@ func handleAuthServiceLogout(s AuthServiceHttpServer) http.HandleFunc { } } -func RegisterMenuServiceRouter(hs *http.Server, s MenuServiceHttpServer) { +func handleSettingServiceGetSetting(s SettingServiceHttpServer) http.HandleFunc { + return func(ctx *http.Context) (err error) { + req := &GetSettingRequest{} + + if res, err := s.GetSetting(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 RegisterUserServiceRouter(hs *http.Server, s UserServiceHttpServer) { // Register handle GetMenus route - hs.GET("/api/menu", handleMenuServiceGetMenus(s)) + hs.GET("/user/menus", handleUserServiceGetMenus(s)) + + // Register handle GetProfile route + hs.GET("/user/profile", handleUserServiceGetProfile(s)) + + // Register handle UpdateProfile route + hs.PUT("/user/profile", handleUserServiceUpdateProfile(s)) + + // Register handle ResetPassword route + hs.POST("/user/reset-password", handleUserServiceResetPassword(s)) + + // Register handle GetPermissions route + hs.GET("/user/permissions", handleUserServiceGetPermissions(s)) + + // Register handle GetUserLabels route + hs.GET("/user/labels", handleUserServiceGetUserLabels(s)) + + // Register handle GetUserTags route + hs.GET("/user/tags", handleUserServiceGetUserTags(s)) } -func RegisterProfileServiceRouter(hs *http.Server, s ProfileServiceHttpServer) { +func RegisterDepartmentServiceRouter(hs *http.Server, s DepartmentServiceHttpServer) { - // Register handle GetProfile route - hs.GET("/user/profile", handleProfileServiceGetProfile(s)) + // Register handle GetDepartmentLabels route + hs.GET("/department/labels", handleDepartmentServiceGetDepartmentLabels(s)) - // Register handle UpdateProfile route - hs.PUT("/user/profile", handleProfileServiceUpdateProfile(s)) +} - // Register handle ResetPassword route - hs.POST("/user/reset-password", handleProfileServiceResetPassword(s)) +func RegisterRoleServiceRouter(hs *http.Server, s RoleServiceHttpServer) { + + // Register handle GetRoleLabels route + hs.GET("/role/labels", handleRoleServiceGetRoleLabels(s)) + + // Register handle GetRolePermissions route + hs.GET("/role/permissions", handleRoleServiceGetRolePermissions(s)) } @@ -177,3 +357,10 @@ func RegisterAuthServiceRouter(hs *http.Server, s AuthServiceHttpServer) { hs.POST("/passport/logout", handleAuthServiceLogout(s)) } + +func RegisterSettingServiceRouter(hs *http.Server, s SettingServiceHttpServer) { + + // Register handle GetSetting route + hs.GET("/system/setting", handleSettingServiceGetSetting(s)) + +} diff --git a/pb/organize_model.pb.go b/pb/organize_model.pb.go index 08e7ab4..cc47ad4 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-13 11:10:07 +// date: 2025-06-16 11:37:44 package pb @@ -9,15 +9,16 @@ import ( ) type MenuModel struct { - Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey"` - ParentId int64 `json:"parent_id" yaml:"parentId" xml:"parentId" gorm:"column:parent_id"` - Name string `json:"name" yaml:"name" xml:"name" gorm:"index;size:60"` - Label string `json:"label" yaml:"label" xml:"label" gorm:"size:120"` - Uri string `json:"uri" yaml:"uri" xml:"uri" gorm:"size:512"` - ViewPath string `json:"view_path" yaml:"viewPath" xml:"viewPath" gorm:"size:512"` - Icon string `json:"icon" yaml:"icon" xml:"icon" gorm:"size:60"` - Hidden bool `json:"hidden" yaml:"hidden" xml:"hidden" gorm:"column:hidden"` - Public bool `json:"public" yaml:"public" xml:"public" gorm:"column:public"` + Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"菜单ID"` + ParentId int64 `json:"parent_id" yaml:"parentId" xml:"parentId" comment:"父级菜单"` + Name string `json:"name" yaml:"name" xml:"name" gorm:"index;size:60" comment:"组件名称" props:"readonly:update" rule:"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"` + ViewPath string `json:"view_path" yaml:"viewPath" xml:"viewPath" gorm:"size:512" comment:"视图路径" scenarios:"create;update;view;export"` + Icon string `json:"icon" yaml:"icon" xml:"icon" gorm:"size:60" comment:"菜单图标" scenarios:"create;update;view;export"` + 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:"备注说明" format:"textarea" scenarios:"create;update;view;export;list"` } func (m *MenuModel) TableName() string { @@ -34,6 +35,7 @@ func (m *MenuModel) FromValue(x *Menu) { m.Icon = x.Icon m.Hidden = x.Hidden m.Public = x.Public + m.Description = x.Description } func (m *MenuModel) ToValue() (x *Menu) { @@ -47,6 +49,7 @@ func (m *MenuModel) ToValue() (x *Menu) { x.Icon = m.Icon x.Hidden = m.Hidden x.Public = m.Public + x.Description = m.Description return x } @@ -67,7 +70,7 @@ func (m *MenuModel) Delete(db *gorm.DB) (err error) { } func (m *MenuModel) Find(db *gorm.DB, pk any) (err error) { - return db.Where("icon=?", pk).First(m).Error + return db.Where("description=?", pk).First(m).Error } func (m *MenuModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { @@ -83,10 +86,10 @@ func NewMenuModel() *MenuModel { } type RoleModel struct { - Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey"` - Name string `json:"name" yaml:"name" xml:"name" gorm:"index;size:60"` - Label string `json:"label" yaml:"label" xml:"label" gorm:"size:60"` - Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024"` + Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"角色ID"` + Name string `json:"name" yaml:"name" xml:"name" gorm:"index;size:60" comment:"角色名称" props:"readonly:update"` + Label string `json:"label" yaml:"label" xml:"label" gorm:"size:60" comment:"角色标题"` + Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" format:"textarea" scenarios:"list;create;update;export"` } func (m *RoleModel) TableName() string { @@ -142,10 +145,10 @@ func NewRoleModel() *RoleModel { } type PermissionModel struct { - Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey"` - MenuId int64 `json:"menu_id" yaml:"menuId" xml:"menuId" gorm:"index"` - Permission string `json:"permission" yaml:"permission" xml:"permission" gorm:"index;size:60"` - Label string `json:"label" yaml:"label" xml:"label" gorm:"size:60"` + Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"权限ID"` + MenuId int64 `json:"menu_id" yaml:"menuId" xml:"menuId" gorm:"index" comment:"所属菜单" 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"` } func (m *PermissionModel) TableName() string { @@ -201,9 +204,9 @@ func NewPermissionModel() *PermissionModel { } type RolePermissionModel struct { - Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey"` - Role string `json:"role" yaml:"role" xml:"role" gorm:"size:60"` - PermissionId int64 `json:"permission_id" yaml:"permissionId" xml:"permissionId" gorm:"column:permission_id"` + Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"ID"` + Role string `json:"role" yaml:"role" xml:"role" gorm:"size:60" comment:"角色名称" rule:"required"` + PermissionId int64 `json:"permission_id" yaml:"permissionId" xml:"permissionId" comment:"权限ID" rule:"required"` } func (m *RolePermissionModel) TableName() string { @@ -241,7 +244,7 @@ func (m *RolePermissionModel) Delete(db *gorm.DB) (err error) { } func (m *RolePermissionModel) Find(db *gorm.DB, pk any) (err error) { - return db.Where("role=?", pk).First(m).Error + return db.Where("permission_id=?", pk).First(m).Error } func (m *RolePermissionModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { @@ -257,20 +260,20 @@ func NewRolePermissionModel() *RolePermissionModel { } type UserModel struct { - Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey"` - CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" gorm:"column:created_at"` - UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"column:updated_at"` - Uid string `json:"uid" yaml:"uid" xml:"uid" gorm:"index;size:20"` - Username string `json:"username" yaml:"username" xml:"username" gorm:"size:20"` - Role string `json:"role" yaml:"role" xml:"role" gorm:"size:60"` - Admin bool `json:"admin" yaml:"admin" xml:"admin" gorm:"column:admin"` - DeptId int64 `json:"dept_id" yaml:"deptId" xml:"deptId" gorm:"not null;default:0"` - Tag string `json:"tag" yaml:"tag" xml:"tag" gorm:"size:60"` - Password string `json:"password" yaml:"password" xml:"password" gorm:"size:60"` - Email string `json:"email" yaml:"email" xml:"email" gorm:"size:60"` - Avatar string `json:"avatar" yaml:"avatar" xml:"avatar" gorm:"size:1024"` - Gender string `json:"gender" yaml:"gender" xml:"gender" gorm:"size:20;default:man"` - Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024"` + 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" comment:"更新时间" scenarios:"view;export"` + Uid string `json:"uid" yaml:"uid" xml:"uid" gorm:"index;size:20" comment:"用户工号" props:"readonly:update" rule:"required;unique;regexp:^[a-zA-Z0-9]{3,8}$"` + Username string `json:"username" yaml:"username" xml:"username" gorm:"size:20" comment:"用户名称" rule:"required"` + Role string `json:"role" yaml:"role" xml:"role" gorm:"size:60" comment:"所属角色" format:"role" rule:"required"` + Admin bool `json:"admin" yaml:"admin" xml:"admin" comment:"管理员" scenarios:"create"` + DeptId int64 `json:"dept_id" yaml:"deptId" xml:"deptId" gorm:"not null;default:0" comment:"所属部门" format:"department" rule:"required"` + Tag string `json:"tag" yaml:"tag" xml:"tag" gorm:"size:60" comment:"用户标签" scenarios:"list;create;update"` + Password string `json:"password" yaml:"password" xml:"password" gorm:"size:60" comment:"用户密码" scenarios:"create" rule:"required"` + Email string `json:"email" yaml:"email" xml:"email" gorm:"size:60" comment:"用户邮箱" scenarios:"create;update;view;list;export"` + Avatar string `json:"avatar" yaml:"avatar" xml:"avatar" gorm:"size:1024" comment:"用户头像" scenarios:"view"` + Gender string `json:"gender" yaml:"gender" xml:"gender" gorm:"size:20;default:man" comment:"用户性别" scenarios:"list;create;update;view;export" rule:"required"` + Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" format:"textarea" scenarios:"create;update;view;export"` } func (m *UserModel) TableName() string { @@ -346,12 +349,12 @@ func NewUserModel() *UserModel { } type DepartmentModel struct { - Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey"` - CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" gorm:"column:created_at"` - UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"column:updated_at"` - ParentId int64 `json:"parent_id" yaml:"parentId" xml:"parentId" gorm:"column:parent_id"` - Name string `json:"name" yaml:"name" xml:"name" gorm:"size:20"` - Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024"` + 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" comment:"更新时间" scenarios:"view;export"` + ParentId int64 `json:"parent_id" yaml:"parentId" xml:"parentId" comment:"父级部门" format:"department"` + 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:"备注说明" format:"textarea" scenarios:"create;update;view;export;list"` } func (m *DepartmentModel) TableName() string { @@ -409,3 +412,68 @@ func (m *DepartmentModel) FindAll(db *gorm.DB, query any, args ...any) (err erro func NewDepartmentModel() *DepartmentModel { return &DepartmentModel{} } + +type SettingModel struct { + Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"ID"` + CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"search;view;export"` + UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" comment:"更新时间" scenarios:"search;view;export"` + Name string `json:"name" yaml:"name" xml:"name" gorm:"size:60" comment:"配置项" props:"readonly:update" rule:"required"` + Value string `json:"value" yaml:"value" xml:"value" gorm:"size:512" comment:"配置值" format:"textarea" rule:"required"` + Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" format:"textarea" scenarios:"create;update;view;export"` +} + +func (m *SettingModel) TableName() string { + return "settings" +} + +func (m *SettingModel) FromValue(x *Setting) { + m.Id = x.Id + m.CreatedAt = x.CreatedAt + m.UpdatedAt = x.UpdatedAt + m.Name = x.Name + m.Value = x.Value + m.Description = x.Description +} + +func (m *SettingModel) ToValue() (x *Setting) { + x = &Setting{} + x.Id = m.Id + x.CreatedAt = m.CreatedAt + x.UpdatedAt = m.UpdatedAt + x.Name = m.Name + x.Value = m.Value + x.Description = m.Description + return x +} + +func (m *SettingModel) Create(db *gorm.DB) (err error) { + return db.Create(m).Error +} + +func (m *SettingModel) UpdateColumn(db *gorm.DB, column string, value any) (err error) { + return db.Model(m).UpdateColumn(column, value).Error +} + +func (m *SettingModel) Save(db *gorm.DB) (err error) { + return db.Save(m).Error +} + +func (m *SettingModel) Delete(db *gorm.DB) (err error) { + return db.Delete(m).Error +} + +func (m *SettingModel) Find(db *gorm.DB, pk any) (err error) { + return db.Where("description=?", pk).First(m).Error +} + +func (m *SettingModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { + return db.Where(query, args...).First(m).Error +} + +func (m *SettingModel) FindAll(db *gorm.DB, query any, args ...any) (err error) { + return db.Where(query, args...).Find(m).Error +} + +func NewSettingModel() *SettingModel { + return &SettingModel{} +} diff --git a/server.go b/server.go index fa72b97..b981d31 100644 --- a/server.go +++ b/server.go @@ -2,44 +2,92 @@ package aeusadmin import ( "context" + "html/template" + "os" "path" + "reflect" + "strconv" + "strings" "git.nobla.cn/golang/aeus-admin/defaults" "git.nobla.cn/golang/aeus-admin/models" + adminTypes "git.nobla.cn/golang/aeus-admin/types" "git.nobla.cn/golang/aeus/pkg/errors" + "git.nobla.cn/golang/aeus/pkg/pool" + "git.nobla.cn/golang/aeus/transport/http" "git.nobla.cn/golang/rest" "git.nobla.cn/golang/rest/inflector" "git.nobla.cn/golang/rest/types" + restTypes "git.nobla.cn/golang/rest/types" "gorm.io/gorm" ) // getModels 获取预定义的模型列表 func getModels() []any { return []any{ - &models.User{}, - &models.Role{}, - &models.Menu{}, &models.Department{}, + &models.Role{}, + &models.User{}, + &models.Menu{}, &models.Permission{}, &models.RolePermission{}, + &models.Setting{}, } } // checkModelMenu 检查模型菜单 -func checkModelMenu(db *gorm.DB, viewPath string, model *rest.Model, translate Translate) (value *models.Menu, err error) { - menuName := inflector.Camelize(model.Naming().ModuleName) + inflector.Camelize(model.Naming().Singular) - value = &models.Menu{} - if err = db.Where("name = ?", menuName).First(value).Error; err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - value.Name = menuName - value.ParentId = 0 - value.ViewPath = path.Join(viewPath, model.ModuleName(), model.Naming().Singular, "Index.vue") - value.Label = inflector.Camel2words(model.Naming().Pluralize) - if translate != nil { - value.Label = translate.Menu(model, value.Label) +func checkModelMenu(db *gorm.DB, viewPath string, apiPrefix string, model *rest.Model, translate Translate) (value *models.Menu, err error) { + refVal := reflect.New(model.Value().Type()).Interface() + if v, ok := refVal.(adminTypes.MenuModel); ok { + row := v.GetMenu() + value = &models.Menu{} + if row.Name == "" { + row.Name = inflector.Camelize(model.Naming().ModuleName) + inflector.Camelize(model.Naming().Singular) + } + if err = db.Where("name = ?", row.Name).First(value).Error; err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + if row.Parent != "" { + parentModel := &models.Menu{} + if err = parentModel.FindOne(db, "name = ?", row.Parent); err == nil { + value.ParentId = parentModel.Id + } + } + value.Name = row.Name + value.Hidden = row.Hidden + value.Icon = row.Icon + value.Label = row.Label + value.Uri = row.Uri + value.ViewPath = row.ViewPath + if value.Label == "" { + value.Label = inflector.Camel2words(model.Naming().Pluralize) + if translate != nil { + value.Label = translate.Menu(model, value.Label) + } + } + if value.Uri == "" { + value.Uri = strings.TrimPrefix(model.Uri(types.ScenarioList), apiPrefix) + } + if value.ViewPath == "" { + value.ViewPath = path.Join(viewPath, model.ModuleName(), model.Naming().Singular, "Index.vue") + } + err = db.Create(value).Error + } + } + } else { + menuName := inflector.Camelize(model.Naming().ModuleName) + inflector.Camelize(model.Naming().Singular) + value = &models.Menu{} + if err = db.Where("name = ?", menuName).First(value).Error; err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + value.Name = menuName + value.ParentId = 0 + value.Label = inflector.Camel2words(model.Naming().Pluralize) + if translate != nil { + value.Label = translate.Menu(model, value.Label) + } + value.Uri = strings.TrimPrefix(model.Uri(types.ScenarioList), apiPrefix) + value.ViewPath = path.Join(viewPath, model.ModuleName(), model.Naming().Singular, "Index.vue") + err = db.Create(value).Error } - value.Uri = model.Uri(types.ScenarioList) - err = db.Create(value).Error } } return @@ -69,7 +117,7 @@ func checkModel(opts *options, model *rest.Model) (err error) { menuModel *models.Menu ) tx := opts.db.Begin() - if menuModel, err = checkModelMenu(tx, opts.viewPath, model, opts.translate); err != nil { + if menuModel, err = checkModelMenu(tx, opts.viewPrefix, opts.apiPrefix, model, opts.translate); err != nil { tx.Rollback() return } @@ -85,6 +133,44 @@ func checkModel(opts *options, model *rest.Model) (err error) { return } +// generateVueFile 生成Vue文件 +func generateVueFile(prefix string, apiPrefix string, mv *rest.Model) (err error) { + filename := path.Join(prefix, mv.Naming().ModuleName, mv.Naming().Singular, "Index.vue") + if _, err = os.Stat(filename); err == nil { + return + } + dirname := path.Dir(filename) + if _, err = os.Stat(dirname); err != nil { + if err = os.MkdirAll(dirname, os.ModePerm); err != nil { + return + } + } + var ( + temp *template.Template + ) + if temp, err = template.New("vue").Parse(vueTemplate); err != nil { + return + } + permissions := make(map[string]string) + for _, s := range defaultScenarios { + if mv.HasScenario(s) { + permissions[s] = mv.Permission(s) + } + } + data := &vueTemplateData{ + ModuleName: mv.ModuleName(), + TableName: mv.TableName(), + Permissions: permissions, + ApiPrefix: strings.TrimPrefix(apiPrefix, "/"), + } + writer := pool.GetBuffer() + defer pool.PutBuffer(writer) + if err = temp.Execute(writer, data); err != nil { + return + } + return os.WriteFile(filename, writer.Bytes(), 0644) +} + // initREST 初始化REST模块 func initREST(ctx context.Context, o *options) (err error) { tx := o.db @@ -94,6 +180,9 @@ func initREST(ctx context.Context, o *options) (err error) { opts := make([]rest.Option, 0) opts = append(opts, o.restOpts...) opts = append(opts, rest.WithDB(tx)) + if o.apiPrefix != "" { + opts = append(opts, rest.WithUriPrefix(o.apiPrefix)) + } if err = rest.Init(opts...); err != nil { return } @@ -104,15 +193,24 @@ func initREST(ctx context.Context, o *options) (err error) { } // initRBAC 初始化权限控制, 用于生成角色权限相关的信息 -func initRBAC(ctx context.Context, o *options) (err error) { +func initModels(ctx context.Context, o *options) (err error) { var mv *rest.Model for _, v := range getModels() { - if mv, err = rest.AutoMigrate(ctx, v); err != nil { + moduleName := o.moduleName + if mm, ok := v.(adminTypes.ModuleModel); ok { + moduleName = mm.ModuleName() + } + if mv, err = rest.AutoMigrate(ctx, v, rest.WithModuleName(moduleName)); err != nil { return } else { if err = checkModel(o, mv); err != nil { return } + if o.vuePath != "" { + if err = generateVueFile(o.vuePath, o.apiPrefix, mv); err != nil { + return + } + } } } return @@ -124,22 +222,109 @@ func AutoMigrate(ctx context.Context, db *gorm.DB, model any, cbs ...Option) (er mv *rest.Model ) opts := newOptions(cbs...) - if mv, err = rest.AutoMigrate(ctx, model); err != nil { + if mm, ok := model.(adminTypes.ModuleModel); ok { + moduleName := mm.ModuleName() + opts.restOpts = append(opts.restOpts, rest.WithModuleName(moduleName)) + } + if mv, err = rest.AutoMigrate(ctx, model, opts.restOpts...); err != nil { return } err = checkModel(opts, mv) return } +func registerRESTRoute(domain string, db *gorm.DB, hs *http.Server) { + + handleListSchemas := func(ctx *http.Context) (err error) { + var ( + schemas []*restTypes.Schema + ) + scenario := ctx.Request().URL.Query().Get("scenario") + if scenario == "" { + schemas, err = rest.GetSchemas( + ctx.Request().Context(), + db.WithContext(ctx.Request().Context()), + "", + ctx.Param("module"), + ctx.Param("table"), + ) + } else { + schemas, err = rest.VisibleSchemas( + ctx.Request().Context(), + db.WithContext(ctx.Request().Context()), + "", + ctx.Param("module"), + ctx.Param("table"), + scenario, + ) + } + if err != nil { + return ctx.Error(errors.NotFound, err.Error()) + } else { + return ctx.Success(schemas) + } + } + + handleUpdateSchemas := func(ctx *http.Context) (err error) { + schemas := make([]*restTypes.Schema, 0) + if err = ctx.Bind(&schemas); err != nil { + return ctx.Error(errors.Invalid, err.Error()) + } + for i := range schemas { + schemas[i].Domain = domain + } + if err = db.WithContext(ctx.Request().Context()).Transaction(func(tx *gorm.DB) (errTx error) { + for _, row := range schemas { + if errTx = tx.Save(row).Error; errTx != nil { + return + } + } + return + }); err == nil { + return ctx.Success(map[string]interface{}{ + "count": len(schemas), + "state": "success", + }) + } else { + return ctx.Error(errors.Unavailable, err.Error()) + } + } + + handleDeleteSchema := func(ctx *http.Context) (err error) { + id, _ := strconv.Atoi(ctx.Param("id")) + model := &restTypes.Schema{Id: uint64(id)} + if err = db.WithContext(ctx.Request().Context()).Delete(model).Error; err == nil { + return ctx.Success(map[string]any{ + "id": id, + }) + } else { + return ctx.Error(errors.Unavailable, err.Error()) + } + } + + hs.GET("/rest/schema/:module/:table", handleListSchemas) + hs.PUT("/rest/schema/:module/:table", handleUpdateSchemas) + hs.DELETE("/rest/schema/:id", handleDeleteSchema) + +} + // Init 初始化模块 func Init(ctx context.Context, cbs ...Option) (err error) { opts := newOptions(cbs...) if err = initREST(ctx, opts); err != nil { return } - if err = initRBAC(ctx, opts); err != nil { + if err = defaults.Menu(opts.db); err != nil { + return + } + if err = initModels(ctx, opts); err != nil { + return + } + if opts.httpServer != nil { + registerRESTRoute(opts.domain, opts.db, opts.httpServer) + } + if err = defaults.Data(opts.db); err != nil { return } - err = defaults.Init(opts.db) return } diff --git a/service/department.go b/service/department.go new file mode 100644 index 0000000..f0d6906 --- /dev/null +++ b/service/department.go @@ -0,0 +1,53 @@ +package service + +import ( + "context" + "strconv" + + "git.nobla.cn/golang/aeus-admin/models" + "git.nobla.cn/golang/aeus-admin/pb" + "gorm.io/gorm" +) + +type ( + departmentOptions struct { + db *gorm.DB + } + DepartmentOption func(o *departmentOptions) + + DepartmentService struct { + opts *departmentOptions + } +) + +func WithDepartmentDB(db *gorm.DB) DepartmentOption { + return func(o *departmentOptions) { + o.db = db + } +} + +func (s *DepartmentService) GetDepartmentLabels(ctx context.Context, req *pb.GetDepartmentLabelRequest) (res *pb.GetDepartmentLabelResponse, err error) { + values := make([]*models.Department, 0) + if err = s.opts.db.WithContext(ctx).Find(&values).Error; err == nil { + res = &pb.GetDepartmentLabelResponse{ + Data: make([]*pb.LabelValue, 0, len(values)), + } + for _, v := range values { + res.Data = append(res.Data, &pb.LabelValue{ + Label: v.Name, + Value: strconv.FormatInt(v.Id, 10), + }) + } + } + return +} + +func NewDepartmentService(cbs ...DepartmentOption) *DepartmentService { + opts := &departmentOptions{} + for _, cb := range cbs { + cb(opts) + } + return &DepartmentService{ + opts: opts, + } +} diff --git a/service/menu.go b/service/menu.go deleted file mode 100644 index b8b3dbd..0000000 --- a/service/menu.go +++ /dev/null @@ -1,113 +0,0 @@ -package service - -import ( - "context" - - "git.nobla.cn/golang/aeus-admin/models" - "git.nobla.cn/golang/aeus-admin/pb" - "git.nobla.cn/golang/aeus-admin/types" - "git.nobla.cn/golang/aeus/middleware/auth" - "git.nobla.cn/golang/aeus/pkg/errors" - "gorm.io/gorm" -) - -type ( - menuOptions struct { - db *gorm.DB - } - MenuOption func(o *menuOptions) - - MenuService struct { - opts *menuOptions - } -) - -func WithMenuDB(db *gorm.DB) MenuOption { - return func(o *menuOptions) { - o.db = db - } -} - -func (s *MenuService) hasPermission(menuID int64, permissions []*models.Permission) bool { - for _, permission := range permissions { - if permission.MenuId == menuID { - return true - } - } - return false -} - -func (s *MenuService) getPermissions(menuID int64, permissions []*models.Permission) []*pb.PermissionItem { - ss := make([]*pb.PermissionItem, 0, 10) - for _, permission := range permissions { - if permission.MenuId == menuID { - ss = append(ss, &pb.PermissionItem{ - Value: permission.Permission, - Label: permission.Label, - }) - } - } - return ss -} - -func (s *MenuService) recursiveNestedMenu(ctx context.Context, parent int64, perm bool, menus []*models.Menu, permissions []*models.Permission) []*pb.MenuItem { - values := make([]*pb.MenuItem, 0) - for _, row := range menus { - if row.ParentId == parent { - if !row.Public && !s.hasPermission(row.Id, permissions) { - continue - } - v := &pb.MenuItem{ - Label: row.Label, - Name: row.Name, - Icon: row.Icon, - Hidden: row.Hidden, - Route: row.Uri, - Children: s.recursiveNestedMenu(ctx, row.Id, perm, menus, permissions), - } - if perm { - v.Permissions = s.getPermissions(row.Id, permissions) - } - values = append(values, v) - } - } - return values -} - -func (s *MenuService) GetRolePermissions(ctx context.Context, db *gorm.DB, role string) (permissions []*models.Permission, err error) { - permissions = make([]*models.Permission, 0) - err = db.Where("id IN (SELECT permission_id FROM role_permissions WHERE role = ?)", role).Find(&permissions).Error - return -} - -func (s *MenuService) GetMenus(ctx context.Context, req *pb.GetMenuRequest) (res *pb.GetMenuResponse, err error) { - claims, ok := auth.FromContext(ctx) - if !ok { - return nil, errors.ErrAccessDenied - } - var ( - permissions []*models.Permission - ) - tx := s.opts.db.WithContext(ctx) - if claims, ok := claims.(*types.Claims); ok { - permissions, err = s.GetRolePermissions(ctx, tx, claims.Role) - } - values := make([]*models.Menu, 0) - if err = tx.Find(&values).Error; err != nil { - return - } - res = &pb.GetMenuResponse{ - Data: s.recursiveNestedMenu(ctx, 0, req.Permission, values, permissions), - } - return -} - -func NewMenuService(cbs ...MenuOption) *MenuService { - opts := &menuOptions{} - for _, cb := range cbs { - cb(opts) - } - return &MenuService{ - opts: opts, - } -} diff --git a/service/profile.go b/service/profile.go deleted file mode 100644 index 406ee0f..0000000 --- a/service/profile.go +++ /dev/null @@ -1,113 +0,0 @@ -package service - -import ( - "context" - - "git.nobla.cn/golang/aeus-admin/models" - "git.nobla.cn/golang/aeus-admin/pb" - "git.nobla.cn/golang/aeus/middleware/auth" - "git.nobla.cn/golang/aeus/pkg/errors" - "gorm.io/gorm" -) - -type ( - profileOptions struct { - db *gorm.DB - } - - ProfileOption func(o *profileOptions) - - ProfileService struct { - opts *profileOptions - } -) - -func WithProfileDB(db *gorm.DB) ProfileOption { - return func(o *profileOptions) { - o.db = db - } -} - -func (s *ProfileService) getUidFromContext(ctx context.Context) (string, error) { - if claims, ok := auth.FromContext(ctx); !ok { - return "", errors.ErrAccessDenied - } else { - return claims.GetSubject() - } -} - -func (s *ProfileService) GetProfile(ctx context.Context, req *pb.GetProfileRequest) (res *pb.GetProfileResponse, err error) { - if req.Uid == "" { - if req.Uid, err = s.getUidFromContext(ctx); err != nil { - return - } - } - res = &pb.GetProfileResponse{} - tx := s.opts.db.WithContext(ctx) - err = tx.Table("users AS u").Select("u.uid as uid", "u.username", "u.avatar", "u.email", "u.description", "u.role_id as role").Where("u.uid=? ", req.Uid).First(res).Error - return -} - -func (s *ProfileService) UpdateProfile(ctx context.Context, req *pb.UpdateProfileRequest) (res *pb.UpdateProfileResponse, err error) { - if req.Uid == "" { - if req.Uid, err = s.getUidFromContext(ctx); err != nil { - return - } - } - userModel := &models.User{} - tx := s.opts.db.WithContext(ctx) - if err = tx.Where("uid=?", req.Uid).First(userModel).Error; err != nil { - return - } - if req.Avatar != "" { - userModel.Avatar = req.Avatar - } - if req.Email != "" { - userModel.Email = req.Email - } - if req.Username != "" { - userModel.Username = req.Username - } - if req.Description != "" { - userModel.Description = req.Description - } - if err = tx.Save(userModel).Error; err == nil { - res = &pb.UpdateProfileResponse{ - Uid: userModel.Uid, - } - } - return -} - -func (s *ProfileService) ResetPassword(ctx context.Context, req *pb.ResetPasswordRequest) (res *pb.ResetPasswordResponse, err error) { - if req.Uid == "" { - if req.Uid, err = s.getUidFromContext(ctx); err != nil { - return - } - } - userModel := &models.User{} - tx := s.opts.db.WithContext(ctx) - if err = tx.Where("uid=?", req.Uid).First(userModel).Error; err != nil { - return - } - if userModel.Password == req.OldPassword { - if err = tx.Where("uid=?", req.Uid).Model(&models.User{}).UpdateColumn("password", req.NewPassword).Error; err == nil { - res = &pb.ResetPasswordResponse{ - Uid: userModel.Uid, - } - } - } else { - err = errors.Format(errors.AccessDenied, "invalid old password") - } - return -} - -func NewProfileService(cbs ...ProfileOption) *ProfileService { - opts := &profileOptions{} - for _, cb := range cbs { - cb(opts) - } - return &ProfileService{ - opts: opts, - } -} diff --git a/service/role.go b/service/role.go new file mode 100644 index 0000000..7ca39bb --- /dev/null +++ b/service/role.go @@ -0,0 +1,67 @@ +package service + +import ( + "context" + + "git.nobla.cn/golang/aeus-admin/models" + "git.nobla.cn/golang/aeus-admin/pb" + "gorm.io/gorm" +) + +type ( + roleOptions struct { + db *gorm.DB + } + RoleOption func(o *roleOptions) + + RoleService struct { + opts *roleOptions + } +) + +func WithRoleDB(db *gorm.DB) RoleOption { + return func(o *roleOptions) { + o.db = db + } +} + +func (s *RoleService) GetRoleLabels(ctx context.Context, req *pb.GetRoleLabelRequest) (res *pb.GetRoleLabelResponse, err error) { + values := make([]*models.Role, 0) + if err = s.opts.db.WithContext(ctx).Find(&values).Error; err == nil { + res = &pb.GetRoleLabelResponse{ + Data: make([]*pb.LabelValue, 0, len(values)), + } + for _, v := range values { + res.Data = append(res.Data, &pb.LabelValue{ + Label: v.Label, + Value: v.Name, + }) + } + } + return +} + +func (s *RoleService) GetRolePermissions(ctx context.Context, req *pb.GetRolePermissionRequest) (res *pb.GetRolePermissionResponse, err error) { + permissions := make([]*models.Permission, 0) + if err = s.opts.db.WithContext(ctx).Where("id IN (SELECT permission_id FROM role_permissions WHERE role = ?)", req.Role).Find(&permissions).Error; err != nil { + return + } + res = &pb.GetRolePermissionResponse{ + Role: req.Role, + Permissions: make([]string, 0, len(permissions)), + } + for _, permission := range permissions { + res.Permissions = append(res.Permissions, permission.Permission) + } + return +} + +func NewRoleService(cbs ...RoleOption) *RoleService { + opts := &roleOptions{} + for _, cb := range cbs { + cb(opts) + } + return &RoleService{ + opts: opts, + } +} diff --git a/service/setting.go b/service/setting.go new file mode 100644 index 0000000..9a253de --- /dev/null +++ b/service/setting.go @@ -0,0 +1,45 @@ +package service + +import ( + "context" + + "git.nobla.cn/golang/aeus-admin/models" + "git.nobla.cn/golang/aeus-admin/pb" + "gorm.io/gorm" +) + +type ( + settingOptions struct { + db *gorm.DB + } + + SettingOption func(o *settingOptions) +) +type SettingService struct { + opts *settingOptions +} + +func (s *SettingService) GetSetting(ctx context.Context, req *pb.GetSettingRequest) (res *pb.GetSettingResponse, err error) { + tx := s.opts.db.WithContext(ctx) + values := make([]*models.Setting, 0) + if err = tx.Find(&values).Error; err != nil { + return + } + res = &pb.GetSettingResponse{ + Data: make([]*pb.SettingItem, 0, len(values)), + } + for _, v := range values { + res.Data = append(res.Data, &pb.SettingItem{ + Name: v.Name, + Value: v.Value, + }) + } + return +} +func NewSettingService(cbs ...SettingOption) *SettingService { + opts := &settingOptions{} + for _, cb := range cbs { + cb(opts) + } + return &SettingService{} +} diff --git a/service/user.go b/service/user.go new file mode 100644 index 0000000..49ad505 --- /dev/null +++ b/service/user.go @@ -0,0 +1,244 @@ +package service + +import ( + "context" + + "git.nobla.cn/golang/aeus-admin/models" + "git.nobla.cn/golang/aeus-admin/pb" + "git.nobla.cn/golang/aeus-admin/types" + "git.nobla.cn/golang/aeus/middleware/auth" + "git.nobla.cn/golang/aeus/pkg/errors" + "gorm.io/gorm" +) + +type ( + userOptions struct { + db *gorm.DB + } + UserOption func(o *userOptions) + + UserService struct { + opts *userOptions + } +) + +func WithUserDB(db *gorm.DB) UserOption { + return func(o *userOptions) { + o.db = db + } +} + +func (s *UserService) getUidFromContext(ctx context.Context) (string, error) { + if claims, ok := auth.FromContext(ctx); !ok { + return "", errors.ErrAccessDenied + } else { + return claims.GetSubject() + } +} + +func (s *UserService) hasPermission(menuID int64, permissions []*models.Permission) bool { + for _, permission := range permissions { + if permission.MenuId == menuID { + return true + } + } + return false +} + +func (s *UserService) getPermissions(menuID int64, permissions []*models.Permission) []*pb.PermissionItem { + ss := make([]*pb.PermissionItem, 0, 10) + for _, permission := range permissions { + if permission.MenuId == menuID { + ss = append(ss, &pb.PermissionItem{ + Value: permission.Permission, + Label: permission.Label, + }) + } + } + return ss +} + +func (s *UserService) recursiveNestedMenu(ctx context.Context, parent int64, perm bool, menus []*models.Menu, permissions []*models.Permission) []*pb.MenuItem { + values := make([]*pb.MenuItem, 0) + for _, row := range menus { + if row.ParentId == parent { + if !row.Public && !s.hasPermission(row.Id, permissions) { + continue + } + v := &pb.MenuItem{ + Label: row.Label, + Name: row.Name, + Icon: row.Icon, + Hidden: row.Hidden, + Route: row.Uri, + Public: row.Public, + View: row.ViewPath, + Children: s.recursiveNestedMenu(ctx, row.Id, perm, menus, permissions), + } + if perm { + v.Permissions = s.getPermissions(row.Id, permissions) + } + values = append(values, v) + } + } + return values +} + +func (s *UserService) getRolePermissions(ctx context.Context, db *gorm.DB, role string) (permissions []*models.Permission, err error) { + permissions = make([]*models.Permission, 0) + err = db.Where("id IN (SELECT permission_id 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) { + claims, ok := auth.FromContext(ctx) + if !ok { + return nil, errors.ErrAccessDenied + } + var ( + permissions []*models.Permission + ) + tx := s.opts.db.WithContext(ctx) + if claims, ok := claims.(*types.Claims); ok { + permissions, err = s.GetRolePermissions(ctx, tx, claims.Role) + } + values := make([]*models.Menu, 0) + if err = tx.Find(&values).Error; err != nil { + return + } + res = &pb.GetMenuResponse{ + Data: s.recursiveNestedMenu(ctx, 0, req.Permission, values, permissions), + } + return +} + +func (s *UserService) GetProfile(ctx context.Context, req *pb.GetProfileRequest) (res *pb.GetProfileResponse, err error) { + if req.Uid == "" { + if req.Uid, err = s.getUidFromContext(ctx); err != nil { + return + } + } + res = &pb.GetProfileResponse{} + tx := s.opts.db.WithContext(ctx) + err = tx.Table("users AS u"). + Select("u.uid as uid", "u.username", "u.avatar", "u.email", "u.description", "u.role", "u.admin"). + Where("u.uid=? ", req.Uid). + First(res).Error + return +} + +func (s *UserService) UpdateProfile(ctx context.Context, req *pb.UpdateProfileRequest) (res *pb.UpdateProfileResponse, err error) { + if req.Uid == "" { + if req.Uid, err = s.getUidFromContext(ctx); err != nil { + return + } + } + userModel := &models.User{} + tx := s.opts.db.WithContext(ctx) + if err = tx.Where("uid=?", req.Uid).First(userModel).Error; err != nil { + return + } + if req.Avatar != "" { + userModel.Avatar = req.Avatar + } + if req.Email != "" { + userModel.Email = req.Email + } + if req.Username != "" { + userModel.Username = req.Username + } + if req.Description != "" { + userModel.Description = req.Description + } + if err = tx.Save(userModel).Error; err == nil { + res = &pb.UpdateProfileResponse{ + Uid: userModel.Uid, + } + } + return +} + +func (s *UserService) ResetPassword(ctx context.Context, req *pb.ResetPasswordRequest) (res *pb.ResetPasswordResponse, err error) { + if req.Uid == "" { + if req.Uid, err = s.getUidFromContext(ctx); err != nil { + return + } + } + userModel := &models.User{} + tx := s.opts.db.WithContext(ctx) + if err = tx.Where("uid=?", req.Uid).First(userModel).Error; err != nil { + return + } + if userModel.Password == req.OldPassword { + if err = tx.Where("uid=?", req.Uid).Model(&models.User{}).UpdateColumn("password", req.NewPassword).Error; err == nil { + res = &pb.ResetPasswordResponse{ + Uid: userModel.Uid, + } + } + } else { + err = errors.Format(errors.AccessDenied, "invalid old password") + } + return +} + +func (s *UserService) GetPermissions(ctx context.Context, req *pb.GetPermissionRequest) (res *pb.GetPermissionResponse, err error) { + if req.Uid == "" { + if req.Uid, err = s.getUidFromContext(ctx); err != nil { + return + } + } + userModel := &models.User{} + tx := s.opts.db.WithContext(ctx) + if err = userModel.FindOne(tx, "uid=?", req.Uid); err != nil { + return + } + var permissions []string + tx.Select("permission").Where("id IN (SELECT permission_id FROM role_permissions WHERE role =?)", userModel.Role).Model(&models.Permission{}).Pluck("permission", &permissions) + res = &pb.GetPermissionResponse{ + Uid: userModel.Uid, + Permissions: permissions, + } + return +} + +func (s *UserService) GetUserLabels(ctx context.Context, req *pb.GetUserLabelRequest) (res *pb.GetUserLabelResponse, err error) { + values := make([]*models.User, 0) + if err = s.opts.db.WithContext(ctx).Find(&values).Error; err == nil { + res = &pb.GetUserLabelResponse{ + Data: make([]*pb.LabelValue, 0, len(values)), + } + for _, v := range values { + res.Data = append(res.Data, &pb.LabelValue{ + Label: v.Username, + Value: v.Uid, + }) + } + } + return +} + +func (s *UserService) GetUserTags(ctx context.Context, req *pb.GetUserTagRequest) (res *pb.GetUserTagResponse, err error) { + values := make([]*models.User, 0) + if err = s.opts.db.WithContext(ctx).Select("DISTINCT(`tag`) AS `tag`").Find(&values).Error; err == nil { + res = &pb.GetUserTagResponse{ + Data: make([]*pb.LabelValue, 0, len(values)), + } + for _, v := range values { + res.Data = append(res.Data, &pb.LabelValue{ + Label: v.Tag, + Value: v.Tag, + }) + } + } + return +} + +func NewUserService(cbs ...UserOption) *UserService { + opts := &userOptions{} + for _, cb := range cbs { + cb(opts) + } + return &UserService{ + opts: opts, + } +} diff --git a/template.go b/template.go new file mode 100644 index 0000000..ab629c5 --- /dev/null +++ b/template.go @@ -0,0 +1,49 @@ +package aeusadmin + +var ( + vueTemplate = ` + + + +` +) diff --git a/types.go b/types.go index 1905530..4a9de0e 100644 --- a/types.go +++ b/types.go @@ -1,6 +1,7 @@ package aeusadmin import ( + "git.nobla.cn/golang/aeus/transport/http" "git.nobla.cn/golang/rest" "git.nobla.cn/golang/rest/types" "gorm.io/gorm" @@ -21,9 +22,13 @@ var ( type ( options struct { db *gorm.DB + domain string moduleName string - viewPath string + apiPrefix string //接口前缀 + viewPrefix string //生成菜单View的前缀路径 + vuePath string //生成Vue文件的路径,如果指定了启动的时候会自动生成Vue的文件 translate Translate + httpServer *http.Server restOpts []rest.Option } @@ -33,6 +38,21 @@ type ( Menu(model *rest.Model, label string) string Permission(model *rest.Model, scene string, label string) string } + + MenuBuild interface { + Label(model *rest.Model) string + Title(model *rest.Model) string + Icon(model *rest.Model) string + Uri(model *rest.Model) string + ViewPath(model *rest.Model) string + } + + vueTemplateData struct { + ModuleName string + TableName string + ApiPrefix string + Permissions map[string]string + } ) func WithDB(db *gorm.DB) Option { @@ -41,15 +61,27 @@ func WithDB(db *gorm.DB) Option { } } +func WithHttpServer(server *http.Server) Option { + return func(o *options) { + o.httpServer = server + } +} + +func WithApiPrefix(apiPrefix string) Option { + return func(o *options) { + o.apiPrefix = apiPrefix + } +} + func WithModuleName(moduleName string) Option { return func(o *options) { o.moduleName = moduleName } } -func WithViewPath(viewPath string) Option { +func WithViewPrefix(viewPath string) Option { return func(o *options) { - o.viewPath = viewPath + o.viewPrefix = viewPath } } @@ -65,9 +97,17 @@ func WithRestOptions(opts ...rest.Option) Option { } } +func WithVuePath(path string) Option { + return func(o *options) { + o.vuePath = path + } +} + func newOptions(opts ...Option) *options { o := &options{ - viewPath: "views", + viewPrefix: "views", + moduleName: "organize", + domain: "localhost", } for _, opt := range opts { opt(o) diff --git a/types/model.go b/types/model.go new file mode 100644 index 0000000..b4e1341 --- /dev/null +++ b/types/model.go @@ -0,0 +1,19 @@ +package types + +type Menu struct { + Parent string `json:"parent"` + Name string `json:"name"` + Label string `json:"label"` + Uri string `json:"uri"` + ViewPath string `json:"view_path"` + Icon string `json:"icon"` + Hidden bool `json:"hidden"` +} + +type MenuModel interface { + GetMenu() *Menu +} + +type ModuleModel interface { + ModuleName() string +}