From 56d50536fcecaf0fde7cd0d3264e25f0a1cec790 Mon Sep 17 00:00:00 2001 From: Yavolte Date: Tue, 17 Jun 2025 17:13:53 +0800 Subject: [PATCH] add db cache and permission checker --- README.md | 3 +- cache.go | 93 ---- defaults/default.go | 40 +- go.mod | 6 +- go.sum | 4 +- i18n/zh.go | 5 +- models/model.go | 51 ++- models/model_test.go | 17 - pb/organize.pb.go | 850 ++++++++++++++++++++++++++----------- pb/organize.pb.validate.go | 455 +++++++++++++++++++- pb/organize.proto | 93 ++-- pb/organize_grpc.pb.go | 38 ++ pb/organize_http.pb.go | 27 +- pb/organize_model.pb.go | 139 ++++-- permission.go | 59 +++ pkg/dbcache/cache.go | 113 +++++ pkg/dbcache/depend.go | 29 ++ server.go | 103 +++-- service/auth.go | 24 +- service/department.go | 32 +- service/role.go | 59 ++- service/setting.go | 6 + service/user.go | 165 ++++--- template.go | 1 + types.go | 27 +- types/model.go | 4 + types/types.go | 5 + 27 files changed, 1882 insertions(+), 566 deletions(-) delete mode 100644 cache.go delete mode 100644 models/model_test.go create mode 100644 permission.go create mode 100644 pkg/dbcache/cache.go create mode 100644 pkg/dbcache/depend.go create mode 100644 types/types.go diff --git a/README.md b/README.md index 005faa2..8117c61 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# third_party +# 权限配置 + diff --git a/cache.go b/cache.go deleted file mode 100644 index 722c4e1..0000000 --- a/cache.go +++ /dev/null @@ -1,93 +0,0 @@ -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 c2cb03a..75b1bf4 100644 --- a/defaults/default.go +++ b/defaults/default.go @@ -38,11 +38,12 @@ func init() { defaultUsers = append(defaultUsers, adminUser, guestUser) dashboardMenu := &models.Menu{} - dashboardMenu.Icon = "org" - dashboardMenu.Label = "控制面板" + dashboardMenu.Icon = "dashboard" + dashboardMenu.Label = "系统首页" dashboardMenu.Name = "Dashboard" dashboardMenu.Public = true dashboardMenu.Uri = "/dashboard" + dashboardMenu.ViewPath = "../views/dashboard/Index.vue" orgMenu := &models.Menu{} orgMenu.Icon = "org" @@ -51,13 +52,32 @@ func init() { orgMenu.Public = true orgMenu.Uri = "/organize" + profileMenu := &models.Menu{} + profileMenu.Label = "个人信息" + profileMenu.Name = "OrganizeUserProfile" + profileMenu.Public = true + profileMenu.Hidden = true + profileMenu.Parent = "Organize" + profileMenu.Uri = "/organize/user/profile" + profileMenu.ViewPath = "../views/organize/user/Profile.vue" + settingMenu := &models.Menu{} settingMenu.Icon = "connect" settingMenu.Label = "系统设置" settingMenu.Name = "System" settingMenu.Public = true settingMenu.Uri = "/system" - defaultMenus = append(defaultMenus, dashboardMenu, orgMenu, settingMenu) + + schemaMenu := &models.Menu{} + schemaMenu.Label = "字段设置" + schemaMenu.Parent = "System" + schemaMenu.Name = "SystemSchema" + schemaMenu.Uri = "/system/schemas" + schemaMenu.Public = true + schemaMenu.Hidden = true + schemaMenu.ViewPath = "../views/system/schema/Index.vue" + + defaultMenus = append(defaultMenus, dashboardMenu, orgMenu, settingMenu, profileMenu, schemaMenu) systemDepartment := &models.Department{} systemDepartment.Name = "系统部门" @@ -74,19 +94,15 @@ func MergeMenu(db *gorm.DB, model *models.Menu) (err error) { return } -func Menu(db *gorm.DB) (err error) { +func Generate(db *gorm.DB) (err error) { + var ( + n int64 + ) for _, row := range defaultMenus { if err = MergeMenu(db, row); err != nil { return } } - return -} - -func Data(db *gorm.DB) (err error) { - var ( - n int64 - ) if db.Model(&models.Role{}).Count(&n); n == 0 { db.Create(defaultRoles) permissions := make([]*models.Permission, 0) @@ -96,7 +112,7 @@ func Data(db *gorm.DB) (err error) { for _, perm := range permissions { item := &models.RolePermission{} item.Role = row.Name - item.PermissionId = perm.Id + item.Permission = perm.Permission items = append(items, item) } db.Save(items) diff --git a/go.mod b/go.mod index fec0477..b920825 100644 --- a/go.mod +++ b/go.mod @@ -16,11 +16,15 @@ require ( require ( github.com/golang-jwt/jwt/v5 v5.2.2 + github.com/mssola/useragent v1.0.0 google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb google.golang.org/grpc v1.72.2 ) -replace git.nobla.cn/golang/aeus v0.0.7 => /Users/yavolte/Workspace/golang/aeus +replace ( + git.nobla.cn/golang/aeus v0.0.7 => /Users/yavolte/Workspace/golang/aeus + git.nobla.cn/golang/rest v0.1.1 => /Users/yavolte/Workspace/golang/rest +) require ( filippo.io/edwards25519 v1.1.0 // indirect diff --git a/go.sum b/go.sum index d26f2ca..dd71ca8 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= git.nobla.cn/golang/kos v0.1.32 h1:sFVCA7vKc8dPUd0cxzwExOSPX2mmMh2IuwL6cYS1pBc= git.nobla.cn/golang/kos v0.1.32/go.mod h1:35Z070+5oB39WcVrh5DDlnVeftL/Ccmscw2MZFe9fUg= -git.nobla.cn/golang/rest v0.1.1 h1:xsGO/1rDrjcmpeZWv7k1sjqACurBQy5l9wVZ430w0tQ= -git.nobla.cn/golang/rest v0.1.1/go.mod h1:4viDk7VujDokpUeHQGbnSp2bkkVZEoIkWQIs/l/TTPQ= github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= @@ -67,6 +65,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mssola/useragent v1.0.0 h1:WRlDpXyxHDNfvZaPEut5Biveq86Ze4o4EMffyMxmH5o= +github.com/mssola/useragent v1.0.0/go.mod h1:hz9Cqz4RXusgg1EdI4Al0INR62kP7aPSRNHnpU+b85Y= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/i18n/zh.go b/i18n/zh.go index 07cc610..8ec158c 100644 --- a/i18n/zh.go +++ b/i18n/zh.go @@ -19,6 +19,9 @@ func (t *ZH) Menu(model *rest.Model, label string) string { if _, ok := model.Value().Interface().(models.Role); ok { return "角色管理" } + if _, ok := model.Value().Interface().(models.Login); ok { + return "登录记录" + } if _, ok := model.Value().Interface().(models.Permission); ok { return "权限管理" } @@ -29,7 +32,7 @@ func (t *ZH) Menu(model *rest.Model, label string) string { return "角色权限" } if _, ok := model.Value().Interface().(models.Setting); ok { - return "系统设置" + return "参数设置" } return label } diff --git a/models/model.go b/models/model.go index cc8e258..8a9425f 100644 --- a/models/model.go +++ b/models/model.go @@ -3,6 +3,7 @@ package models import ( "git.nobla.cn/golang/aeus-admin/pb" "git.nobla.cn/golang/aeus-admin/types" + restTypes "git.nobla.cn/golang/rest/types" ) type ( @@ -12,6 +13,9 @@ type ( Menu struct { pb.MenuModel } + Login struct { + pb.LoginModel + } Department struct { pb.DepartmentModel } @@ -37,6 +41,17 @@ func (m *User) GetMenu() *types.Menu { } } +func (m *Login) GetMenu() *types.Menu { + return &types.Menu{ + Name: "OrganizeLogin", + Parent: "Organize", + } +} + +func (m *Login) Scenario() []string { + return []string{restTypes.ScenarioList} +} + func (m *Menu) GetMenu() *types.Menu { return &types.Menu{ Name: "OrganizeMenu", @@ -44,6 +59,12 @@ func (m *Menu) GetMenu() *types.Menu { } } +func (m *Menu) ModelPermissions() map[string]string { + return map[string]string{ + "organize:permission:list": "权限", + } +} + func (m *Department) GetMenu() *types.Menu { return &types.Menu{ Name: "OrganizeDepartment", @@ -58,22 +79,40 @@ func (m *Role) GetMenu() *types.Menu { } } +func (m *Role) ModelPermissions() map[string]string { + return map[string]string{ + "organize:role_permission:list": "权限", + } +} + func (m *Permission) GetMenu() *types.Menu { return &types.Menu{ - Name: "OrganizePermission", - Parent: "Organize", - Hidden: true, + Name: "OrganizePermission", + Parent: "Organize", + Hidden: true, + Uri: "/organize/menu/permission/:id", + ViewPath: "../views/organize/menu/Permission.vue", } } +func (m *Permission) GetPermission(s string) string { + return "organize:permission:list" +} + func (m *RolePermission) GetMenu() *types.Menu { return &types.Menu{ - Name: "OrganizeRolePermission", - Parent: "Organize", - Hidden: true, + Name: "OrganizeRolePermission", + Parent: "Organize", + Hidden: true, + Uri: "/organize/role/permission/:id", + ViewPath: "../views/organize/role/Permission.vue", } } +func (m *RolePermission) GetPermission(s string) string { + return "organize:role_permission:list" +} + func (m *Setting) GetMenu() *types.Menu { return &types.Menu{ Name: "SystemSetting", diff --git a/models/model_test.go b/models/model_test.go deleted file mode 100644 index 0a22101..0000000 --- a/models/model_test.go +++ /dev/null @@ -1,17 +0,0 @@ -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 252b06a..927ca41 100644 --- a/pb/organize.pb.go +++ b/pb/organize.pb.go @@ -29,15 +29,17 @@ const ( type Menu struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - ParentId int64 `protobuf:"varint,2,opt,name=parent_id,json=parentId,proto3" json:"parent_id,omitempty"` - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` - Label string `protobuf:"bytes,4,opt,name=label,proto3" json:"label,omitempty"` - Uri string `protobuf:"bytes,5,opt,name=uri,proto3" json:"uri,omitempty"` - ViewPath string `protobuf:"bytes,6,opt,name=view_path,json=viewPath,proto3" json:"view_path,omitempty"` - 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"` + 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"` + Parent string `protobuf:"bytes,4,opt,name=parent,proto3" json:"parent,omitempty"` + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + Label string `protobuf:"bytes,6,opt,name=label,proto3" json:"label,omitempty"` + Uri string `protobuf:"bytes,7,opt,name=uri,proto3" json:"uri,omitempty"` + ViewPath string `protobuf:"bytes,8,opt,name=view_path,json=viewPath,proto3" json:"view_path,omitempty"` + Icon string `protobuf:"bytes,9,opt,name=icon,proto3" json:"icon,omitempty"` + Hidden bool `protobuf:"varint,10,opt,name=hidden,proto3" json:"hidden,omitempty"` + Public bool `protobuf:"varint,11,opt,name=public,proto3" json:"public,omitempty"` + Description string `protobuf:"bytes,12,opt,name=description,proto3" json:"description,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -79,13 +81,27 @@ func (x *Menu) GetId() int64 { return 0 } -func (x *Menu) GetParentId() int64 { +func (x *Menu) GetCreatedAt() int64 { if x != nil { - return x.ParentId + return x.CreatedAt } return 0 } +func (x *Menu) GetUpdatedAt() int64 { + if x != nil { + return x.UpdatedAt + } + return 0 +} + +func (x *Menu) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + func (x *Menu) GetName() string { if x != nil { return x.Name @@ -146,9 +162,11 @@ func (x *Menu) GetDescription() string { type Role struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Label string `protobuf:"bytes,3,opt,name=label,proto3" json:"label,omitempty"` - Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,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"` + Label string `protobuf:"bytes,5,opt,name=label,proto3" json:"label,omitempty"` + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -190,6 +208,20 @@ func (x *Role) GetId() int64 { return 0 } +func (x *Role) GetCreatedAt() int64 { + if x != nil { + return x.CreatedAt + } + return 0 +} + +func (x *Role) GetUpdatedAt() int64 { + if x != nil { + return x.UpdatedAt + } + return 0 +} + func (x *Role) GetName() string { if x != nil { return x.Name @@ -215,7 +247,7 @@ func (x *Role) GetDescription() string { type Permission struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - MenuId int64 `protobuf:"varint,2,opt,name=menu_id,json=menuId,proto3" json:"menu_id,omitempty"` + Menu string `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` Permission string `protobuf:"bytes,3,opt,name=permission,proto3" json:"permission,omitempty"` Label string `protobuf:"bytes,4,opt,name=label,proto3" json:"label,omitempty"` unknownFields protoimpl.UnknownFields @@ -259,11 +291,11 @@ func (x *Permission) GetId() int64 { return 0 } -func (x *Permission) GetMenuId() int64 { +func (x *Permission) GetMenu() string { if x != nil { - return x.MenuId + return x.Menu } - return 0 + return "" } func (x *Permission) GetPermission() string { @@ -285,7 +317,7 @@ type RolePermission struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Role string `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` - PermissionId int64 `protobuf:"varint,3,opt,name=permission_id,json=permissionId,proto3" json:"permission_id,omitempty"` + Permission string `protobuf:"bytes,3,opt,name=permission,proto3" json:"permission,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -334,11 +366,11 @@ func (x *RolePermission) GetRole() string { return "" } -func (x *RolePermission) GetPermissionId() int64 { +func (x *RolePermission) GetPermission() string { if x != nil { - return x.PermissionId + return x.Permission } - return 0 + return "" } // User 用户模型定义 @@ -351,13 +383,14 @@ type User struct { Username string `protobuf:"bytes,5,opt,name=username,proto3" json:"username,omitempty"` Role string `protobuf:"bytes,6,opt,name=role,proto3" json:"role,omitempty"` Admin bool `protobuf:"varint,7,opt,name=admin,proto3" json:"admin,omitempty"` - DeptId int64 `protobuf:"varint,8,opt,name=dept_id,json=deptId,proto3" json:"dept_id,omitempty"` - Tag string `protobuf:"bytes,9,opt,name=tag,proto3" json:"tag,omitempty"` - Password string `protobuf:"bytes,10,opt,name=password,proto3" json:"password,omitempty"` - Email string `protobuf:"bytes,11,opt,name=email,proto3" json:"email,omitempty"` - Avatar string `protobuf:"bytes,12,opt,name=avatar,proto3" json:"avatar,omitempty"` - Gender string `protobuf:"bytes,13,opt,name=gender,proto3" json:"gender,omitempty"` - Description string `protobuf:"bytes,14,opt,name=description,proto3" json:"description,omitempty"` + Status string `protobuf:"bytes,8,opt,name=status,proto3" json:"status,omitempty"` + DeptId int64 `protobuf:"varint,9,opt,name=dept_id,json=deptId,proto3" json:"dept_id,omitempty"` + Tag string `protobuf:"bytes,10,opt,name=tag,proto3" json:"tag,omitempty"` + Password string `protobuf:"bytes,11,opt,name=password,proto3" json:"password,omitempty"` + Email string `protobuf:"bytes,12,opt,name=email,proto3" json:"email,omitempty"` + Avatar string `protobuf:"bytes,13,opt,name=avatar,proto3" json:"avatar,omitempty"` + Gender string `protobuf:"bytes,14,opt,name=gender,proto3" json:"gender,omitempty"` + Description string `protobuf:"bytes,15,opt,name=description,proto3" json:"description,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -441,6 +474,13 @@ func (x *User) GetAdmin() bool { return false } +func (x *User) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + func (x *User) GetDeptId() int64 { if x != nil { return x.DeptId @@ -575,6 +615,114 @@ func (x *Department) GetDescription() string { return "" } +type Login 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"` + Uid string `protobuf:"bytes,4,opt,name=uid,proto3" json:"uid,omitempty"` + Ip string `protobuf:"bytes,5,opt,name=ip,proto3" json:"ip,omitempty"` + Browser string `protobuf:"bytes,6,opt,name=browser,proto3" json:"browser,omitempty"` + Os string `protobuf:"bytes,7,opt,name=os,proto3" json:"os,omitempty"` + Platform string `protobuf:"bytes,8,opt,name=platform,proto3" json:"platform,omitempty"` + AccessToken string `protobuf:"bytes,9,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` + UserAgent string `protobuf:"bytes,10,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Login) Reset() { + *x = Login{} + mi := &file_organize_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Login) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Login) ProtoMessage() {} + +func (x *Login) 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 Login.ProtoReflect.Descriptor instead. +func (*Login) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{6} +} + +func (x *Login) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Login) GetCreatedAt() int64 { + if x != nil { + return x.CreatedAt + } + return 0 +} + +func (x *Login) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *Login) GetIp() string { + if x != nil { + return x.Ip + } + return "" +} + +func (x *Login) GetBrowser() string { + if x != nil { + return x.Browser + } + return "" +} + +func (x *Login) GetOs() string { + if x != nil { + return x.Os + } + return "" +} + +func (x *Login) GetPlatform() string { + if x != nil { + return x.Platform + } + return "" +} + +func (x *Login) GetAccessToken() string { + if x != nil { + return x.AccessToken + } + return "" +} + +func (x *Login) GetUserAgent() string { + if x != nil { + return x.UserAgent + } + return "" +} + // Setting 参数设置表 type Setting struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -590,7 +738,7 @@ type Setting struct { func (x *Setting) Reset() { *x = Setting{} - mi := &file_organize_proto_msgTypes[6] + mi := &file_organize_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -602,7 +750,7 @@ func (x *Setting) String() string { func (*Setting) ProtoMessage() {} func (x *Setting) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[6] + mi := &file_organize_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -615,7 +763,7 @@ func (x *Setting) ProtoReflect() protoreflect.Message { // Deprecated: Use Setting.ProtoReflect.Descriptor instead. func (*Setting) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{6} + return file_organize_proto_rawDescGZIP(), []int{7} } func (x *Setting) GetId() int64 { @@ -670,7 +818,7 @@ type LabelValue struct { func (x *LabelValue) Reset() { *x = LabelValue{} - mi := &file_organize_proto_msgTypes[7] + mi := &file_organize_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -682,7 +830,7 @@ func (x *LabelValue) String() string { func (*LabelValue) ProtoMessage() {} func (x *LabelValue) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[7] + mi := &file_organize_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -695,7 +843,7 @@ func (x *LabelValue) ProtoReflect() protoreflect.Message { // Deprecated: Use LabelValue.ProtoReflect.Descriptor instead. func (*LabelValue) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{7} + return file_organize_proto_rawDescGZIP(), []int{8} } func (x *LabelValue) GetLabel() string { @@ -722,7 +870,7 @@ type PermissionItem struct { func (x *PermissionItem) Reset() { *x = PermissionItem{} - mi := &file_organize_proto_msgTypes[8] + mi := &file_organize_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -734,7 +882,7 @@ func (x *PermissionItem) String() string { func (*PermissionItem) ProtoMessage() {} func (x *PermissionItem) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[8] + mi := &file_organize_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -747,7 +895,7 @@ func (x *PermissionItem) ProtoReflect() protoreflect.Message { // Deprecated: Use PermissionItem.ProtoReflect.Descriptor instead. func (*PermissionItem) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{8} + return file_organize_proto_rawDescGZIP(), []int{9} } func (x *PermissionItem) GetValue() string { @@ -782,7 +930,7 @@ type MenuItem struct { func (x *MenuItem) Reset() { *x = MenuItem{} - mi := &file_organize_proto_msgTypes[9] + mi := &file_organize_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -794,7 +942,7 @@ func (x *MenuItem) String() string { func (*MenuItem) ProtoMessage() {} func (x *MenuItem) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[9] + mi := &file_organize_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -807,7 +955,7 @@ func (x *MenuItem) ProtoReflect() protoreflect.Message { // Deprecated: Use MenuItem.ProtoReflect.Descriptor instead. func (*MenuItem) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{9} + return file_organize_proto_rawDescGZIP(), []int{10} } func (x *MenuItem) GetLabel() string { @@ -883,7 +1031,7 @@ type GetMenuRequest struct { func (x *GetMenuRequest) Reset() { *x = GetMenuRequest{} - mi := &file_organize_proto_msgTypes[10] + mi := &file_organize_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -895,7 +1043,7 @@ func (x *GetMenuRequest) String() string { func (*GetMenuRequest) ProtoMessage() {} func (x *GetMenuRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[10] + mi := &file_organize_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -908,7 +1056,7 @@ func (x *GetMenuRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetMenuRequest.ProtoReflect.Descriptor instead. func (*GetMenuRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{10} + return file_organize_proto_rawDescGZIP(), []int{11} } func (x *GetMenuRequest) GetPermission() bool { @@ -928,7 +1076,7 @@ type GetMenuResponse struct { func (x *GetMenuResponse) Reset() { *x = GetMenuResponse{} - mi := &file_organize_proto_msgTypes[11] + mi := &file_organize_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -940,7 +1088,7 @@ func (x *GetMenuResponse) String() string { func (*GetMenuResponse) ProtoMessage() {} func (x *GetMenuResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[11] + mi := &file_organize_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -953,7 +1101,7 @@ func (x *GetMenuResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetMenuResponse.ProtoReflect.Descriptor instead. func (*GetMenuResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{11} + return file_organize_proto_rawDescGZIP(), []int{12} } func (x *GetMenuResponse) GetData() []*MenuItem { @@ -973,7 +1121,7 @@ type GetProfileRequest struct { func (x *GetProfileRequest) Reset() { *x = GetProfileRequest{} - mi := &file_organize_proto_msgTypes[12] + mi := &file_organize_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -985,7 +1133,7 @@ func (x *GetProfileRequest) String() string { func (*GetProfileRequest) ProtoMessage() {} func (x *GetProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[12] + mi := &file_organize_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -998,7 +1146,7 @@ func (x *GetProfileRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetProfileRequest.ProtoReflect.Descriptor instead. func (*GetProfileRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{12} + return file_organize_proto_rawDescGZIP(), []int{13} } func (x *GetProfileRequest) GetUid() string { @@ -1024,7 +1172,7 @@ type GetProfileResponse struct { func (x *GetProfileResponse) Reset() { *x = GetProfileResponse{} - mi := &file_organize_proto_msgTypes[13] + mi := &file_organize_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1036,7 +1184,7 @@ func (x *GetProfileResponse) String() string { func (*GetProfileResponse) ProtoMessage() {} func (x *GetProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[13] + mi := &file_organize_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1049,7 +1197,7 @@ func (x *GetProfileResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetProfileResponse.ProtoReflect.Descriptor instead. func (*GetProfileResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{13} + return file_organize_proto_rawDescGZIP(), []int{14} } func (x *GetProfileResponse) GetUid() string { @@ -1112,7 +1260,7 @@ type ResetPasswordRequest struct { func (x *ResetPasswordRequest) Reset() { *x = ResetPasswordRequest{} - mi := &file_organize_proto_msgTypes[14] + mi := &file_organize_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1124,7 +1272,7 @@ func (x *ResetPasswordRequest) String() string { func (*ResetPasswordRequest) ProtoMessage() {} func (x *ResetPasswordRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[14] + mi := &file_organize_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1137,7 +1285,7 @@ func (x *ResetPasswordRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ResetPasswordRequest.ProtoReflect.Descriptor instead. func (*ResetPasswordRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{14} + return file_organize_proto_rawDescGZIP(), []int{15} } func (x *ResetPasswordRequest) GetUid() string { @@ -1170,7 +1318,7 @@ type ResetPasswordResponse struct { func (x *ResetPasswordResponse) Reset() { *x = ResetPasswordResponse{} - mi := &file_organize_proto_msgTypes[15] + mi := &file_organize_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1182,7 +1330,7 @@ func (x *ResetPasswordResponse) String() string { func (*ResetPasswordResponse) ProtoMessage() {} func (x *ResetPasswordResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[15] + mi := &file_organize_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1195,7 +1343,7 @@ func (x *ResetPasswordResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ResetPasswordResponse.ProtoReflect.Descriptor instead. func (*ResetPasswordResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{15} + return file_organize_proto_rawDescGZIP(), []int{16} } func (x *ResetPasswordResponse) GetUid() string { @@ -1218,7 +1366,7 @@ type UpdateProfileRequest struct { func (x *UpdateProfileRequest) Reset() { *x = UpdateProfileRequest{} - mi := &file_organize_proto_msgTypes[16] + mi := &file_organize_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1230,7 +1378,7 @@ func (x *UpdateProfileRequest) String() string { func (*UpdateProfileRequest) ProtoMessage() {} func (x *UpdateProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[16] + mi := &file_organize_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1243,7 +1391,7 @@ func (x *UpdateProfileRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateProfileRequest.ProtoReflect.Descriptor instead. func (*UpdateProfileRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{16} + return file_organize_proto_rawDescGZIP(), []int{17} } func (x *UpdateProfileRequest) GetUid() string { @@ -1290,7 +1438,7 @@ type UpdateProfileResponse struct { func (x *UpdateProfileResponse) Reset() { *x = UpdateProfileResponse{} - mi := &file_organize_proto_msgTypes[17] + mi := &file_organize_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1302,7 +1450,7 @@ func (x *UpdateProfileResponse) String() string { func (*UpdateProfileResponse) ProtoMessage() {} func (x *UpdateProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[17] + mi := &file_organize_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1315,7 +1463,7 @@ func (x *UpdateProfileResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateProfileResponse.ProtoReflect.Descriptor instead. func (*UpdateProfileResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{17} + return file_organize_proto_rawDescGZIP(), []int{18} } func (x *UpdateProfileResponse) GetUid() string { @@ -1334,7 +1482,7 @@ type GetPermissionRequest struct { func (x *GetPermissionRequest) Reset() { *x = GetPermissionRequest{} - mi := &file_organize_proto_msgTypes[18] + mi := &file_organize_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1346,7 +1494,7 @@ func (x *GetPermissionRequest) String() string { func (*GetPermissionRequest) ProtoMessage() {} func (x *GetPermissionRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[18] + mi := &file_organize_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1359,7 +1507,7 @@ func (x *GetPermissionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetPermissionRequest.ProtoReflect.Descriptor instead. func (*GetPermissionRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{18} + return file_organize_proto_rawDescGZIP(), []int{19} } func (x *GetPermissionRequest) GetUid() string { @@ -1379,7 +1527,7 @@ type GetPermissionResponse struct { func (x *GetPermissionResponse) Reset() { *x = GetPermissionResponse{} - mi := &file_organize_proto_msgTypes[19] + mi := &file_organize_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1391,7 +1539,7 @@ func (x *GetPermissionResponse) String() string { func (*GetPermissionResponse) ProtoMessage() {} func (x *GetPermissionResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[19] + mi := &file_organize_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1404,7 +1552,7 @@ func (x *GetPermissionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetPermissionResponse.ProtoReflect.Descriptor instead. func (*GetPermissionResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{19} + return file_organize_proto_rawDescGZIP(), []int{20} } func (x *GetPermissionResponse) GetUid() string { @@ -1429,7 +1577,7 @@ type GetUserLabelRequest struct { func (x *GetUserLabelRequest) Reset() { *x = GetUserLabelRequest{} - mi := &file_organize_proto_msgTypes[20] + mi := &file_organize_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1441,7 +1589,7 @@ func (x *GetUserLabelRequest) String() string { func (*GetUserLabelRequest) ProtoMessage() {} func (x *GetUserLabelRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[20] + mi := &file_organize_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1454,7 +1602,7 @@ func (x *GetUserLabelRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserLabelRequest.ProtoReflect.Descriptor instead. func (*GetUserLabelRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{20} + return file_organize_proto_rawDescGZIP(), []int{21} } type GetUserLabelResponse struct { @@ -1466,7 +1614,7 @@ type GetUserLabelResponse struct { func (x *GetUserLabelResponse) Reset() { *x = GetUserLabelResponse{} - mi := &file_organize_proto_msgTypes[21] + mi := &file_organize_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1478,7 +1626,7 @@ func (x *GetUserLabelResponse) String() string { func (*GetUserLabelResponse) ProtoMessage() {} func (x *GetUserLabelResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[21] + mi := &file_organize_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1491,7 +1639,7 @@ func (x *GetUserLabelResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserLabelResponse.ProtoReflect.Descriptor instead. func (*GetUserLabelResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{21} + return file_organize_proto_rawDescGZIP(), []int{22} } func (x *GetUserLabelResponse) GetData() []*LabelValue { @@ -1509,7 +1657,7 @@ type GetUserTagRequest struct { func (x *GetUserTagRequest) Reset() { *x = GetUserTagRequest{} - mi := &file_organize_proto_msgTypes[22] + mi := &file_organize_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1521,7 +1669,7 @@ func (x *GetUserTagRequest) String() string { func (*GetUserTagRequest) ProtoMessage() {} func (x *GetUserTagRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[22] + mi := &file_organize_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1534,7 +1682,7 @@ func (x *GetUserTagRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserTagRequest.ProtoReflect.Descriptor instead. func (*GetUserTagRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{22} + return file_organize_proto_rawDescGZIP(), []int{23} } type GetUserTagResponse struct { @@ -1546,7 +1694,7 @@ type GetUserTagResponse struct { func (x *GetUserTagResponse) Reset() { *x = GetUserTagResponse{} - mi := &file_organize_proto_msgTypes[23] + mi := &file_organize_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1558,7 +1706,7 @@ func (x *GetUserTagResponse) String() string { func (*GetUserTagResponse) ProtoMessage() {} func (x *GetUserTagResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[23] + mi := &file_organize_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1571,7 +1719,7 @@ func (x *GetUserTagResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserTagResponse.ProtoReflect.Descriptor instead. func (*GetUserTagResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{23} + return file_organize_proto_rawDescGZIP(), []int{24} } func (x *GetUserTagResponse) GetData() []*LabelValue { @@ -1581,6 +1729,58 @@ func (x *GetUserTagResponse) GetData() []*LabelValue { return nil } +type DepartmentLabelValue struct { + state protoimpl.MessageState `protogen:"open.v1"` + Label string `protobuf:"bytes,1,opt,name=label,proto3" json:"label,omitempty"` + Value int64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DepartmentLabelValue) Reset() { + *x = DepartmentLabelValue{} + mi := &file_organize_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DepartmentLabelValue) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DepartmentLabelValue) ProtoMessage() {} + +func (x *DepartmentLabelValue) 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 DepartmentLabelValue.ProtoReflect.Descriptor instead. +func (*DepartmentLabelValue) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{25} +} + +func (x *DepartmentLabelValue) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *DepartmentLabelValue) GetValue() int64 { + if x != nil { + return x.Value + } + return 0 +} + type GetDepartmentLabelRequest struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields @@ -1589,7 +1789,7 @@ type GetDepartmentLabelRequest struct { func (x *GetDepartmentLabelRequest) Reset() { *x = GetDepartmentLabelRequest{} - mi := &file_organize_proto_msgTypes[24] + mi := &file_organize_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1601,7 +1801,7 @@ func (x *GetDepartmentLabelRequest) String() string { func (*GetDepartmentLabelRequest) ProtoMessage() {} func (x *GetDepartmentLabelRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[24] + mi := &file_organize_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1614,19 +1814,19 @@ func (x *GetDepartmentLabelRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetDepartmentLabelRequest.ProtoReflect.Descriptor instead. func (*GetDepartmentLabelRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{24} + return file_organize_proto_rawDescGZIP(), []int{26} } type GetDepartmentLabelResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data []*LabelValue `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Data []*DepartmentLabelValue `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] + mi := &file_organize_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1638,7 +1838,7 @@ func (x *GetDepartmentLabelResponse) String() string { func (*GetDepartmentLabelResponse) ProtoMessage() {} func (x *GetDepartmentLabelResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[25] + mi := &file_organize_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1651,10 +1851,10 @@ func (x *GetDepartmentLabelResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetDepartmentLabelResponse.ProtoReflect.Descriptor instead. func (*GetDepartmentLabelResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{25} + return file_organize_proto_rawDescGZIP(), []int{27} } -func (x *GetDepartmentLabelResponse) GetData() []*LabelValue { +func (x *GetDepartmentLabelResponse) GetData() []*DepartmentLabelValue { if x != nil { return x.Data } @@ -1669,7 +1869,7 @@ type GetRoleLabelRequest struct { func (x *GetRoleLabelRequest) Reset() { *x = GetRoleLabelRequest{} - mi := &file_organize_proto_msgTypes[26] + mi := &file_organize_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1681,7 +1881,7 @@ func (x *GetRoleLabelRequest) String() string { func (*GetRoleLabelRequest) ProtoMessage() {} func (x *GetRoleLabelRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[26] + mi := &file_organize_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1694,7 +1894,7 @@ func (x *GetRoleLabelRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRoleLabelRequest.ProtoReflect.Descriptor instead. func (*GetRoleLabelRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{26} + return file_organize_proto_rawDescGZIP(), []int{28} } type GetRoleLabelResponse struct { @@ -1706,7 +1906,7 @@ type GetRoleLabelResponse struct { func (x *GetRoleLabelResponse) Reset() { *x = GetRoleLabelResponse{} - mi := &file_organize_proto_msgTypes[27] + mi := &file_organize_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1718,7 +1918,7 @@ func (x *GetRoleLabelResponse) String() string { func (*GetRoleLabelResponse) ProtoMessage() {} func (x *GetRoleLabelResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[27] + mi := &file_organize_proto_msgTypes[29] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1731,7 +1931,7 @@ func (x *GetRoleLabelResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRoleLabelResponse.ProtoReflect.Descriptor instead. func (*GetRoleLabelResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{27} + return file_organize_proto_rawDescGZIP(), []int{29} } func (x *GetRoleLabelResponse) GetData() []*LabelValue { @@ -1750,7 +1950,7 @@ type GetRolePermissionRequest struct { func (x *GetRolePermissionRequest) Reset() { *x = GetRolePermissionRequest{} - mi := &file_organize_proto_msgTypes[28] + mi := &file_organize_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1762,7 +1962,7 @@ func (x *GetRolePermissionRequest) String() string { func (*GetRolePermissionRequest) ProtoMessage() {} func (x *GetRolePermissionRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[28] + mi := &file_organize_proto_msgTypes[30] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1775,7 +1975,7 @@ func (x *GetRolePermissionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRolePermissionRequest.ProtoReflect.Descriptor instead. func (*GetRolePermissionRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{28} + return file_organize_proto_rawDescGZIP(), []int{30} } func (x *GetRolePermissionRequest) GetRole() string { @@ -1795,7 +1995,7 @@ type GetRolePermissionResponse struct { func (x *GetRolePermissionResponse) Reset() { *x = GetRolePermissionResponse{} - mi := &file_organize_proto_msgTypes[29] + mi := &file_organize_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1807,7 +2007,7 @@ func (x *GetRolePermissionResponse) String() string { func (*GetRolePermissionResponse) ProtoMessage() {} func (x *GetRolePermissionResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[29] + mi := &file_organize_proto_msgTypes[31] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1820,7 +2020,7 @@ func (x *GetRolePermissionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRolePermissionResponse.ProtoReflect.Descriptor instead. func (*GetRolePermissionResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{29} + return file_organize_proto_rawDescGZIP(), []int{31} } func (x *GetRolePermissionResponse) GetRole() string { @@ -1837,6 +2037,102 @@ func (x *GetRolePermissionResponse) GetPermissions() []string { return nil } +type SaveRolePermissionRequest 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 *SaveRolePermissionRequest) Reset() { + *x = SaveRolePermissionRequest{} + mi := &file_organize_proto_msgTypes[32] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SaveRolePermissionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SaveRolePermissionRequest) ProtoMessage() {} + +func (x *SaveRolePermissionRequest) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[32] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SaveRolePermissionRequest.ProtoReflect.Descriptor instead. +func (*SaveRolePermissionRequest) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{32} +} + +func (x *SaveRolePermissionRequest) GetRole() string { + if x != nil { + return x.Role + } + return "" +} + +func (x *SaveRolePermissionRequest) GetPermissions() []string { + if x != nil { + return x.Permissions + } + return nil +} + +type SaveRolePermissionResponse 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 *SaveRolePermissionResponse) Reset() { + *x = SaveRolePermissionResponse{} + mi := &file_organize_proto_msgTypes[33] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SaveRolePermissionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SaveRolePermissionResponse) ProtoMessage() {} + +func (x *SaveRolePermissionResponse) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[33] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SaveRolePermissionResponse.ProtoReflect.Descriptor instead. +func (*SaveRolePermissionResponse) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{33} +} + +func (x *SaveRolePermissionResponse) GetRole() string { + if x != nil { + return x.Role + } + return "" +} + type LoginRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` @@ -1848,7 +2144,7 @@ type LoginRequest struct { func (x *LoginRequest) Reset() { *x = LoginRequest{} - mi := &file_organize_proto_msgTypes[30] + mi := &file_organize_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1860,7 +2156,7 @@ func (x *LoginRequest) String() string { func (*LoginRequest) ProtoMessage() {} func (x *LoginRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[30] + mi := &file_organize_proto_msgTypes[34] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1873,7 +2169,7 @@ func (x *LoginRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. func (*LoginRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{30} + return file_organize_proto_rawDescGZIP(), []int{34} } func (x *LoginRequest) GetUsername() string { @@ -1909,7 +2205,7 @@ type LoginResponse struct { func (x *LoginResponse) Reset() { *x = LoginResponse{} - mi := &file_organize_proto_msgTypes[31] + mi := &file_organize_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1921,7 +2217,7 @@ func (x *LoginResponse) String() string { func (*LoginResponse) ProtoMessage() {} func (x *LoginResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[31] + mi := &file_organize_proto_msgTypes[35] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1934,7 +2230,7 @@ func (x *LoginResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. func (*LoginResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{31} + return file_organize_proto_rawDescGZIP(), []int{35} } func (x *LoginResponse) GetUid() string { @@ -1974,7 +2270,7 @@ type LogoutRequest struct { func (x *LogoutRequest) Reset() { *x = LogoutRequest{} - mi := &file_organize_proto_msgTypes[32] + mi := &file_organize_proto_msgTypes[36] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1986,7 +2282,7 @@ func (x *LogoutRequest) String() string { func (*LogoutRequest) ProtoMessage() {} func (x *LogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[32] + mi := &file_organize_proto_msgTypes[36] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1999,7 +2295,7 @@ func (x *LogoutRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead. func (*LogoutRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{32} + return file_organize_proto_rawDescGZIP(), []int{36} } func (x *LogoutRequest) GetToken() string { @@ -2018,7 +2314,7 @@ type LogoutResponse struct { func (x *LogoutResponse) Reset() { *x = LogoutResponse{} - mi := &file_organize_proto_msgTypes[33] + mi := &file_organize_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2030,7 +2326,7 @@ func (x *LogoutResponse) String() string { func (*LogoutResponse) ProtoMessage() {} func (x *LogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[33] + mi := &file_organize_proto_msgTypes[37] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2043,7 +2339,7 @@ func (x *LogoutResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LogoutResponse.ProtoReflect.Descriptor instead. func (*LogoutResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{33} + return file_organize_proto_rawDescGZIP(), []int{37} } func (x *LogoutResponse) GetUid() string { @@ -2063,7 +2359,7 @@ type SettingItem struct { func (x *SettingItem) Reset() { *x = SettingItem{} - mi := &file_organize_proto_msgTypes[34] + mi := &file_organize_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2075,7 +2371,7 @@ func (x *SettingItem) String() string { func (*SettingItem) ProtoMessage() {} func (x *SettingItem) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[34] + mi := &file_organize_proto_msgTypes[38] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2088,7 +2384,7 @@ func (x *SettingItem) ProtoReflect() protoreflect.Message { // Deprecated: Use SettingItem.ProtoReflect.Descriptor instead. func (*SettingItem) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{34} + return file_organize_proto_rawDescGZIP(), []int{38} } func (x *SettingItem) GetName() string { @@ -2113,7 +2409,7 @@ type GetSettingRequest struct { func (x *GetSettingRequest) Reset() { *x = GetSettingRequest{} - mi := &file_organize_proto_msgTypes[35] + mi := &file_organize_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2125,7 +2421,7 @@ func (x *GetSettingRequest) String() string { func (*GetSettingRequest) ProtoMessage() {} func (x *GetSettingRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[35] + mi := &file_organize_proto_msgTypes[39] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2138,7 +2434,7 @@ func (x *GetSettingRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetSettingRequest.ProtoReflect.Descriptor instead. func (*GetSettingRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{35} + return file_organize_proto_rawDescGZIP(), []int{39} } type GetSettingResponse struct { @@ -2150,7 +2446,7 @@ type GetSettingResponse struct { func (x *GetSettingResponse) Reset() { *x = GetSettingResponse{} - mi := &file_organize_proto_msgTypes[36] + mi := &file_organize_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2162,7 +2458,7 @@ func (x *GetSettingResponse) String() string { func (*GetSettingResponse) ProtoMessage() {} func (x *GetSettingResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[36] + mi := &file_organize_proto_msgTypes[40] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2175,7 +2471,7 @@ func (x *GetSettingResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetSettingResponse.ProtoReflect.Descriptor instead. func (*GetSettingResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{36} + return file_organize_proto_rawDescGZIP(), []int{40} } func (x *GetSettingResponse) GetData() []*SettingItem { @@ -2189,109 +2485,150 @@ 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\"\x9d\x06\n" + + "\x0eorganize.proto\x12\borganize\x1a\x0faeus/rest.proto\x1a\x17validate/validate.proto\x1a google/protobuf/descriptor.proto\x1a\x1cgoogle/api/annotations.proto\"\xc6\a\n" + "\x04Menu\x12*\n" + "\x02id\x18\x01 \x01(\x03B\x1a\xb2\xb9\x19\x16\n" + "\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" + + "primaryKey\x12\b菜单IDR\x02id\x12>\n" + + "\n" + + "created_at\x18\x02 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f创建时间\x1a\vview;exportR\tcreatedAt\x12E\n" + + "\n" + + "updated_at\x18\x03 \x01(\x03B&\xb2\xb9\x19\"\n" + + "\x05index\x12\f更新时间\x1a\vview;exportR\tupdatedAt\x12J\n" + + "\x06parent\x18\x04 \x01(\tB2\xb2\xb9\x19.\n" + + "\rindex;size:60\x12\f父级菜单2\x0freadonly:updateR\x06parent\x12^\n" + + "\x04name\x18\x05 \x01(\tBJ\xfaB\x04r\x02\x18<\xb2\xb9\x19?\n" + + "\rindex;size:60\x12\f组件名称2\x0freadonly:update:\x0funique;requiredR\x04name\x12C\n" + + "\x05label\x18\x06 \x01(\tB-\xfaB\x04r\x02\x18x\xb2\xb9\x19\"\n" + "\bsize:120\x12\f菜单标题:\brequiredR\x05label\x12[\n" + - "\x03uri\x18\x05 \x01(\tBI\xfaB\x05r\x03\x18\x80\x04\xb2\xb9\x19=\n" + + "\x03uri\x18\a \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" + + "\tview_path\x18\b \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" + + "\x04icon\x18\t \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" + + "\x06hidden\x18\n" + + " \x01(\bB-\xb2\xb9\x19)\x12\f是否隐藏\x1a\x19create;update;view;exportR\x06hidden\x12E\n" + + "\x06public\x18\v \x01(\bB-\xb2\xb9\x19)\x12\f是否公开\x1a\x19create;update;view;exportR\x06public\x12q\n" + + "\vdescription\x18\f \x01(\tBO\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19C\n" + "\tsize:1024\x12\f备注说明\x1a\x1ecreate;update;view;export;list*\btextareaR\vdescription:\v\xba\xb9\x19\a\n" + - "\x05menus\"\xb6\x02\n" + + "\x05menus\"\xbd\x03\n" + "\x04Role\x12*\n" + "\x02id\x18\x01 \x01(\x03B\x1a\xb2\xb9\x19\x16\n" + "\n" + - "primaryKey\x12\b角色IDR\x02id\x12M\n" + - "\x04name\x18\x02 \x01(\tB9\xfaB\x04r\x02\x18<\xb2\xb9\x19.\n" + + "primaryKey\x12\b角色IDR\x02id\x12>\n" + + "\n" + + "created_at\x18\x02 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f创建时间\x1a\vview;exportR\tcreatedAt\x12E\n" + + "\n" + + "updated_at\x18\x03 \x01(\x03B&\xb2\xb9\x19\"\n" + + "\x05index\x12\f更新时间\x1a\vview;exportR\tupdatedAt\x12M\n" + + "\x04name\x18\x04 \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" + + "\x05label\x18\x05 \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" + + "\vdescription\x18\x06 \x01(\tBJ\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19>\n" + "\tsize:1024\x12\f备注说明\x1a\x19list;create;update;export*\btextareaR\vdescription:\v\xba\xb9\x19\a\n" + - "\x05roles\"\xa1\x02\n" + + "\x05roles\"\xa4\x02\n" + "\n" + "Permission\x12*\n" + "\x02id\x18\x01 \x01(\x03B\x1a\xb2\xb9\x19\x16\n" + "\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" + + "primaryKey\x12\b权限IDR\x02id\x12?\n" + + "\x04menu\x18\x02 \x01(\tB+\xb2\xb9\x19'\n" + + "\rindex;size:60\x12\f所属菜单:\brequiredR\x04menu\x12R\n" + "\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" + + "\vpermissions\"\xd1\x01\n" + "\x0eRolePermission\x12$\n" + "\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" + "\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" + + "\rindex;size:60\x12\x06角色:\brequiredR\x04role\x12?\n" + + "\n" + + "permission\x18\x03 \x01(\tB\x1f\xb2\xb9\x19\x1b\n" + + "\asize:60\x12\x06权限:\brequiredR\n" + + "permission:\x16\xba\xb9\x19\x12\n" + + "\x10role_permissions\"\xa2\v\n" + "\x04User\x12$\n" + "\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" + "\n" + "primaryKey\x12\x02IDR\x02id\x12>\n" + "\n" + - "created_at\x18\x02 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f创建时间\x1a\vview;exportR\tcreatedAt\x12>\n" + + "created_at\x18\x02 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f创建时间\x1a\vview;exportR\tcreatedAt\x12E\n" + "\n" + - "updated_at\x18\x03 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f更新时间\x1a\vview;exportR\tupdatedAt\x12x\n" + + "updated_at\x18\x03 \x01(\x03B&\xb2\xb9\x19\"\n" + + "\x05index\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" + + "\asize:20\x12\f用户名称:\brequiredR\busername\x12z\n" + + "\x04role\x18\x06 \x01(\tBf\xfaB\x04r\x02\x18<\xb2\xb9\x19[\n" + + "\x1bsize:60;not null;default:''\x12\f所属角色*\x04role:\brequiredB\x1etype:dropdown;url:/role/labelsR\x04role\x12-\n" + + "\x05admin\x18\a \x01(\bB\x17\xb2\xb9\x19\x13\x12\t管理员\x1a\x06createR\x05admin\x12u\n" + + "\x06status\x18\b \x01(\tB]\xb2\xb9\x19Y\n" + + "\x16size:20;default:normal\x12\x06状态\x1a\x19create,update,list,searchR\x1cnormal:正常;disable:禁用R\x06status\x12{\n" + + "\adept_id\x18\t \x01(\x03Bb\xb2\xb9\x19^\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(\tB4\xfaB\x04r\x02\x18<\xb2\xb9\x19)\n" + + "department:\brequiredB$type:dropdown;url:/department/labelsR\x06deptId\x12\x88\x01\n" + + "\x03tag\x18\n" + + " \x01(\tBv\xfaB\x04r\x02\x18<\xb2\xb9\x19k\n" + + "\asize:60\x12\f用户标签\x1a\x12list;create;updateB\x1ctype:dropdown;url:/user/tagsJ created;filterable;default_firstR\x03tag\x12P\n" + + "\bpassword\x18\v \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" + + "\x05email\x18\f \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" + + "\x06avatar\x18\r \x01(\tB+\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19\x1f\n" + + "\tsize:1024\x12\f用户头像\x1a\x04viewR\x06avatar\x12\x90\x01\n" + + "\x06gender\x18\x0e \x01(\tBx\xfaB\x04r\x02\x18\x14\xb2\xb9\x19m\n" + + "\x13size:20;default:man\x12\f用户性别\x1a\x1elist;create;update;view;export:\brequiredR\x1eman:男;woman:女;other:其他R\x06gender\x12l\n" + + "\vdescription\x18\x0f \x01(\tBJ\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19>\n" + "\tsize:1024\x12\f备注说明\x1a\x19create;update;view;export*\btextareaR\vdescription:\v\xba\xb9\x19\a\n" + - "\x05users\"\xb7\x03\n" + + "\x05users\"\xbe\x03\n" + "\n" + "Department\x12$\n" + "\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" + "\n" + "primaryKey\x12\x02IDR\x02id\x12>\n" + "\n" + - "created_at\x18\x02 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f创建时间\x1a\vview;exportR\tcreatedAt\x12>\n" + + "created_at\x18\x02 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f创建时间\x1a\vview;exportR\tcreatedAt\x12E\n" + "\n" + - "updated_at\x18\x03 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f更新时间\x1a\vview;exportR\tupdatedAt\x12;\n" + + "updated_at\x18\x03 \x01(\x03B&\xb2\xb9\x19\"\n" + + "\x05index\x12\f更新时间\x1a\vview;exportR\tupdatedAt\x12;\n" + "\tparent_id\x18\x04 \x01(\x03B\x1e\xb2\xb9\x19\x1a\x12\f父级部门*\n" + "departmentR\bparentId\x12@\n" + "\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" + + "\vdepartments\"\xa4\x05\n" + + "\x05Login\x12$\n" + + "\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" + + "\n" + + "primaryKey\x12\x02IDR\x02id\x12J\n" + + "\n" + + "created_at\x18\x02 \x01(\x03B+\xb2\xb9\x19'\x12\f登录时间\x1a\x17list;search;view;exportR\tcreatedAt\x12]\n" + + "\x03uid\x18\x04 \x01(\tBK\xfaB\x06r\x04\x10\x05\x18\x14\xb2\xb9\x19>\n" + + "\rindex;size:20\x12\f用户工号*\x04user2\x0freadonly:update:\brequiredR\x03uid\x12E\n" + + "\x02ip\x18\x05 \x01(\tB5\xb2\xb9\x191\n" + + "\bsize:128\x12\f登录地址\x1a\x17list;search;view;exportR\x02ip\x12E\n" + + "\abrowser\x18\x06 \x01(\tB+\xb2\xb9\x19'\n" + + "\bsize:128\x12\t浏览器\x1a\x10list;view;exportR\abrowser\x12>\n" + + "\x02os\x18\a \x01(\tB.\xb2\xb9\x19*\n" + + "\bsize:128\x12\f操作系统\x1a\x10list;view;exportR\x02os\x12J\n" + + "\bplatform\x18\b \x01(\tB.\xb2\xb9\x19*\n" + + "\bsize:128\x12\f系统平台\x1a\x10list;view;exportR\bplatform\x12R\n" + + "\faccess_token\x18\t \x01(\tB/\xb2\xb9\x19+\n" + + "\tsize:1024\x12\f访问令牌\x1a\x10list;view;exportR\vaccessToken\x12N\n" + + "\n" + + "user_agent\x18\n" + + " \x01(\tB/\xb2\xb9\x19+\n" + + "\tsize:1024\x12\f用户代理\x1a\x10list;view;exportR\tuserAgent:\f\xba\xb9\x19\b\n" + + "\x06logins\"\xd8\x03\n" + "\aSetting\x12$\n" + "\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" + "\n" + @@ -2365,10 +2702,13 @@ const file_organize_proto_rawDesc = "" + "\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" + + "\x04data\x18\x01 \x03(\v2\x14.organize.LabelValueR\x04data\"B\n" + + "\x14DepartmentLabelValue\x12\x14\n" + + "\x05label\x18\x01 \x01(\tR\x05label\x12\x14\n" + + "\x05value\x18\x02 \x01(\x03R\x05value\"\x1b\n" + + "\x19GetDepartmentLabelRequest\"P\n" + + "\x1aGetDepartmentLabelResponse\x122\n" + + "\x04data\x18\x01 \x03(\v2\x1e.organize.DepartmentLabelValueR\x04data\"\x15\n" + "\x13GetRoleLabelRequest\"@\n" + "\x14GetRoleLabelResponse\x12(\n" + "\x04data\x18\x01 \x03(\v2\x14.organize.LabelValueR\x04data\".\n" + @@ -2376,7 +2716,12 @@ const file_organize_proto_rawDesc = "" + "\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" + + "\vpermissions\x18\x02 \x03(\tR\vpermissions\"Q\n" + + "\x19SaveRolePermissionRequest\x12\x12\n" + + "\x04role\x18\x01 \x01(\tR\x04role\x12 \n" + + "\vpermissions\x18\x02 \x03(\tR\vpermissions\"0\n" + + "\x1aSaveRolePermissionResponse\x12\x12\n" + + "\x04role\x18\x01 \x01(\tR\x04role\"\\\n" + "\fLoginRequest\x12\x1a\n" + "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + "\bpassword\x18\x02 \x01(\tR\bpassword\x12\x14\n" + @@ -2407,10 +2752,11 @@ const file_organize_proto_rawDesc = "" + "\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" + + "\x13GetDepartmentLabels\x12#.organize.GetDepartmentLabelRequest\x1a$.organize.GetDepartmentLabelResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/department/labels2\xec\x02\n" + "\vRoleService\x12d\n" + "\rGetRoleLabels\x12\x1d.organize.GetRoleLabelRequest\x1a\x1e.organize.GetRoleLabelResponse\"\x14\x82\xd3\xe4\x93\x02\x0e\x12\f/role/labels\x12x\n" + - "\x12GetRolePermissions\x12\".organize.GetRolePermissionRequest\x1a#.organize.GetRolePermissionResponse\"\x19\x82\xd3\xe4\x93\x02\x13\x12\x11/role/permissions2\xbd\x01\n" + + "\x12GetRolePermissions\x12\".organize.GetRolePermissionRequest\x1a#.organize.GetRolePermissionResponse\"\x19\x82\xd3\xe4\x93\x02\x13\x12\x11/role/permissions\x12}\n" + + "\x12SaveRolePermission\x12#.organize.SaveRolePermissionRequest\x1a$.organize.SaveRolePermissionResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\"\x11/role/permissions2\xbd\x01\n" + "\vAuthService\x12T\n" + "\x05Login\x12\x16.organize.LoginRequest\x1a\x17.organize.LoginResponse\"\x1a\x82\xd3\xe4\x93\x02\x14:\x01*\"\x0f/passport/login\x12X\n" + "\x06Logout\x12\x17.organize.LogoutRequest\x1a\x18.organize.LogoutResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/passport/logout2r\n" + @@ -2430,7 +2776,7 @@ func file_organize_proto_rawDescGZIP() []byte { return file_organize_proto_rawDescData } -var file_organize_proto_msgTypes = make([]protoimpl.MessageInfo, 37) +var file_organize_proto_msgTypes = make([]protoimpl.MessageInfo, 41) var file_organize_proto_goTypes = []any{ (*Menu)(nil), // 0: organize.Menu (*Role)(nil), // 1: organize.Role @@ -2438,75 +2784,81 @@ var file_organize_proto_goTypes = []any{ (*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 + (*Login)(nil), // 6: organize.Login + (*Setting)(nil), // 7: organize.Setting + (*LabelValue)(nil), // 8: organize.LabelValue + (*PermissionItem)(nil), // 9: organize.PermissionItem + (*MenuItem)(nil), // 10: organize.MenuItem + (*GetMenuRequest)(nil), // 11: organize.GetMenuRequest + (*GetMenuResponse)(nil), // 12: organize.GetMenuResponse + (*GetProfileRequest)(nil), // 13: organize.GetProfileRequest + (*GetProfileResponse)(nil), // 14: organize.GetProfileResponse + (*ResetPasswordRequest)(nil), // 15: organize.ResetPasswordRequest + (*ResetPasswordResponse)(nil), // 16: organize.ResetPasswordResponse + (*UpdateProfileRequest)(nil), // 17: organize.UpdateProfileRequest + (*UpdateProfileResponse)(nil), // 18: organize.UpdateProfileResponse + (*GetPermissionRequest)(nil), // 19: organize.GetPermissionRequest + (*GetPermissionResponse)(nil), // 20: organize.GetPermissionResponse + (*GetUserLabelRequest)(nil), // 21: organize.GetUserLabelRequest + (*GetUserLabelResponse)(nil), // 22: organize.GetUserLabelResponse + (*GetUserTagRequest)(nil), // 23: organize.GetUserTagRequest + (*GetUserTagResponse)(nil), // 24: organize.GetUserTagResponse + (*DepartmentLabelValue)(nil), // 25: organize.DepartmentLabelValue + (*GetDepartmentLabelRequest)(nil), // 26: organize.GetDepartmentLabelRequest + (*GetDepartmentLabelResponse)(nil), // 27: organize.GetDepartmentLabelResponse + (*GetRoleLabelRequest)(nil), // 28: organize.GetRoleLabelRequest + (*GetRoleLabelResponse)(nil), // 29: organize.GetRoleLabelResponse + (*GetRolePermissionRequest)(nil), // 30: organize.GetRolePermissionRequest + (*GetRolePermissionResponse)(nil), // 31: organize.GetRolePermissionResponse + (*SaveRolePermissionRequest)(nil), // 32: organize.SaveRolePermissionRequest + (*SaveRolePermissionResponse)(nil), // 33: organize.SaveRolePermissionResponse + (*LoginRequest)(nil), // 34: organize.LoginRequest + (*LoginResponse)(nil), // 35: organize.LoginResponse + (*LogoutRequest)(nil), // 36: organize.LogoutRequest + (*LogoutResponse)(nil), // 37: organize.LogoutResponse + (*SettingItem)(nil), // 38: organize.SettingItem + (*GetSettingRequest)(nil), // 39: organize.GetSettingRequest + (*GetSettingResponse)(nil), // 40: organize.GetSettingResponse } var file_organize_proto_depIdxs = []int32{ - 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 + 9, // 0: organize.MenuItem.permissions:type_name -> organize.PermissionItem + 10, // 1: organize.MenuItem.children:type_name -> organize.MenuItem + 10, // 2: organize.GetMenuResponse.data:type_name -> organize.MenuItem + 8, // 3: organize.GetUserLabelResponse.data:type_name -> organize.LabelValue + 8, // 4: organize.GetUserTagResponse.data:type_name -> organize.LabelValue + 25, // 5: organize.GetDepartmentLabelResponse.data:type_name -> organize.DepartmentLabelValue + 8, // 6: organize.GetRoleLabelResponse.data:type_name -> organize.LabelValue + 38, // 7: organize.GetSettingResponse.data:type_name -> organize.SettingItem + 11, // 8: organize.UserService.GetMenus:input_type -> organize.GetMenuRequest + 13, // 9: organize.UserService.GetProfile:input_type -> organize.GetProfileRequest + 17, // 10: organize.UserService.UpdateProfile:input_type -> organize.UpdateProfileRequest + 15, // 11: organize.UserService.ResetPassword:input_type -> organize.ResetPasswordRequest + 19, // 12: organize.UserService.GetPermissions:input_type -> organize.GetPermissionRequest + 21, // 13: organize.UserService.GetUserLabels:input_type -> organize.GetUserLabelRequest + 23, // 14: organize.UserService.GetUserTags:input_type -> organize.GetUserTagRequest + 26, // 15: organize.DepartmentService.GetDepartmentLabels:input_type -> organize.GetDepartmentLabelRequest + 28, // 16: organize.RoleService.GetRoleLabels:input_type -> organize.GetRoleLabelRequest + 30, // 17: organize.RoleService.GetRolePermissions:input_type -> organize.GetRolePermissionRequest + 32, // 18: organize.RoleService.SaveRolePermission:input_type -> organize.SaveRolePermissionRequest + 34, // 19: organize.AuthService.Login:input_type -> organize.LoginRequest + 36, // 20: organize.AuthService.Logout:input_type -> organize.LogoutRequest + 39, // 21: organize.SettingService.GetSetting:input_type -> organize.GetSettingRequest + 12, // 22: organize.UserService.GetMenus:output_type -> organize.GetMenuResponse + 14, // 23: organize.UserService.GetProfile:output_type -> organize.GetProfileResponse + 18, // 24: organize.UserService.UpdateProfile:output_type -> organize.UpdateProfileResponse + 16, // 25: organize.UserService.ResetPassword:output_type -> organize.ResetPasswordResponse + 20, // 26: organize.UserService.GetPermissions:output_type -> organize.GetPermissionResponse + 22, // 27: organize.UserService.GetUserLabels:output_type -> organize.GetUserLabelResponse + 24, // 28: organize.UserService.GetUserTags:output_type -> organize.GetUserTagResponse + 27, // 29: organize.DepartmentService.GetDepartmentLabels:output_type -> organize.GetDepartmentLabelResponse + 29, // 30: organize.RoleService.GetRoleLabels:output_type -> organize.GetRoleLabelResponse + 31, // 31: organize.RoleService.GetRolePermissions:output_type -> organize.GetRolePermissionResponse + 33, // 32: organize.RoleService.SaveRolePermission:output_type -> organize.SaveRolePermissionResponse + 35, // 33: organize.AuthService.Login:output_type -> organize.LoginResponse + 37, // 34: organize.AuthService.Logout:output_type -> organize.LogoutResponse + 40, // 35: organize.SettingService.GetSetting:output_type -> organize.GetSettingResponse + 22, // [22:36] is the sub-list for method output_type + 8, // [8:22] is the sub-list for method input_type 8, // [8:8] is the sub-list for extension type_name 8, // [8:8] is the sub-list for extension extendee 0, // [0:8] is the sub-list for field type_name @@ -2523,7 +2875,7 @@ 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: 37, + NumMessages: 41, NumExtensions: 0, NumServices: 5, }, diff --git a/pb/organize.pb.validate.go b/pb/organize.pb.validate.go index 92112d1..9c79d72 100644 --- a/pb/organize.pb.validate.go +++ b/pb/organize.pb.validate.go @@ -58,7 +58,11 @@ func (m *Menu) validate(all bool) error { // no validation rules for Id - // no validation rules for ParentId + // no validation rules for CreatedAt + + // no validation rules for UpdatedAt + + // no validation rules for Parent if utf8.RuneCountInString(m.GetName()) > 60 { err := MenuValidationError{ @@ -230,6 +234,10 @@ func (m *Role) validate(all bool) error { // no validation rules for Id + // no validation rules for CreatedAt + + // no validation rules for UpdatedAt + if utf8.RuneCountInString(m.GetName()) > 60 { err := RoleValidationError{ field: "Name", @@ -364,7 +372,7 @@ func (m *Permission) validate(all bool) error { // no validation rules for Id - // no validation rules for MenuId + // no validation rules for Menu if utf8.RuneCountInString(m.GetPermission()) > 60 { err := PermissionValidationError{ @@ -500,7 +508,7 @@ func (m *RolePermission) validate(all bool) error { errors = append(errors, err) } - // no validation rules for PermissionId + // no validation rules for Permission if len(errors) > 0 { return RolePermissionMultiError(errors) @@ -642,6 +650,8 @@ func (m *User) validate(all bool) error { // no validation rules for Admin + // no validation rules for Status + // no validation rules for DeptId if utf8.RuneCountInString(m.GetTag()) > 60 { @@ -916,6 +926,131 @@ var _ interface { ErrorName() string } = DepartmentValidationError{} +// Validate checks the field values on Login 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 *Login) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Login 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 LoginMultiError, or nil if none found. +func (m *Login) ValidateAll() error { + return m.validate(true) +} + +func (m *Login) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for CreatedAt + + if l := utf8.RuneCountInString(m.GetUid()); l < 5 || l > 20 { + err := LoginValidationError{ + field: "Uid", + reason: "value length must be between 5 and 20 runes, inclusive", + } + if !all { + return err + } + errors = append(errors, err) + } + + // no validation rules for Ip + + // no validation rules for Browser + + // no validation rules for Os + + // no validation rules for Platform + + // no validation rules for AccessToken + + // no validation rules for UserAgent + + if len(errors) > 0 { + return LoginMultiError(errors) + } + + return nil +} + +// LoginMultiError is an error wrapping multiple validation errors returned by +// Login.ValidateAll() if the designated constraints aren't met. +type LoginMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m LoginMultiError) 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 LoginMultiError) AllErrors() []error { return m } + +// LoginValidationError is the validation error returned by Login.Validate if +// the designated constraints aren't met. +type LoginValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e LoginValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e LoginValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e LoginValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e LoginValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e LoginValidationError) ErrorName() string { return "LoginValidationError" } + +// Error satisfies the builtin error interface +func (e LoginValidationError) 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 %sLogin.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = LoginValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = LoginValidationError{} + // 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. @@ -3009,6 +3144,112 @@ var _ interface { ErrorName() string } = GetUserTagResponseValidationError{} +// Validate checks the field values on DepartmentLabelValue 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 *DepartmentLabelValue) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DepartmentLabelValue 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 +// DepartmentLabelValueMultiError, or nil if none found. +func (m *DepartmentLabelValue) ValidateAll() error { + return m.validate(true) +} + +func (m *DepartmentLabelValue) 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 DepartmentLabelValueMultiError(errors) + } + + return nil +} + +// DepartmentLabelValueMultiError is an error wrapping multiple validation +// errors returned by DepartmentLabelValue.ValidateAll() if the designated +// constraints aren't met. +type DepartmentLabelValueMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DepartmentLabelValueMultiError) 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 DepartmentLabelValueMultiError) AllErrors() []error { return m } + +// DepartmentLabelValueValidationError is the validation error returned by +// DepartmentLabelValue.Validate if the designated constraints aren't met. +type DepartmentLabelValueValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DepartmentLabelValueValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DepartmentLabelValueValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DepartmentLabelValueValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DepartmentLabelValueValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DepartmentLabelValueValidationError) ErrorName() string { + return "DepartmentLabelValueValidationError" +} + +// Error satisfies the builtin error interface +func (e DepartmentLabelValueValidationError) 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 %sDepartmentLabelValue.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DepartmentLabelValueValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DepartmentLabelValueValidationError{} + // 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. @@ -3693,6 +3934,214 @@ var _ interface { ErrorName() string } = GetRolePermissionResponseValidationError{} +// Validate checks the field values on SaveRolePermissionRequest 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 *SaveRolePermissionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SaveRolePermissionRequest 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 +// SaveRolePermissionRequestMultiError, or nil if none found. +func (m *SaveRolePermissionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *SaveRolePermissionRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Role + + if len(errors) > 0 { + return SaveRolePermissionRequestMultiError(errors) + } + + return nil +} + +// SaveRolePermissionRequestMultiError is an error wrapping multiple validation +// errors returned by SaveRolePermissionRequest.ValidateAll() if the +// designated constraints aren't met. +type SaveRolePermissionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SaveRolePermissionRequestMultiError) 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 SaveRolePermissionRequestMultiError) AllErrors() []error { return m } + +// SaveRolePermissionRequestValidationError is the validation error returned by +// SaveRolePermissionRequest.Validate if the designated constraints aren't met. +type SaveRolePermissionRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SaveRolePermissionRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SaveRolePermissionRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SaveRolePermissionRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SaveRolePermissionRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SaveRolePermissionRequestValidationError) ErrorName() string { + return "SaveRolePermissionRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e SaveRolePermissionRequestValidationError) 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 %sSaveRolePermissionRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SaveRolePermissionRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SaveRolePermissionRequestValidationError{} + +// Validate checks the field values on SaveRolePermissionResponse 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 *SaveRolePermissionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SaveRolePermissionResponse 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 +// SaveRolePermissionResponseMultiError, or nil if none found. +func (m *SaveRolePermissionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *SaveRolePermissionResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Role + + if len(errors) > 0 { + return SaveRolePermissionResponseMultiError(errors) + } + + return nil +} + +// SaveRolePermissionResponseMultiError is an error wrapping multiple +// validation errors returned by SaveRolePermissionResponse.ValidateAll() if +// the designated constraints aren't met. +type SaveRolePermissionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SaveRolePermissionResponseMultiError) 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 SaveRolePermissionResponseMultiError) AllErrors() []error { return m } + +// SaveRolePermissionResponseValidationError is the validation error returned +// by SaveRolePermissionResponse.Validate if the designated constraints aren't met. +type SaveRolePermissionResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SaveRolePermissionResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SaveRolePermissionResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SaveRolePermissionResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SaveRolePermissionResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SaveRolePermissionResponseValidationError) ErrorName() string { + return "SaveRolePermissionResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e SaveRolePermissionResponseValidationError) 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 %sSaveRolePermissionResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SaveRolePermissionResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SaveRolePermissionResponseValidationError{} + // Validate checks the field values on LoginRequest with the rules defined in // the proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. diff --git a/pb/organize.proto b/pb/organize.proto index 7b58e23..36efe94 100644 --- a/pb/organize.proto +++ b/pb/organize.proto @@ -15,15 +15,17 @@ message Menu { table: "menus" }; 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}]; + int64 created_at = 2 [(aeus.field)={scenarios:"view;export",comment:"创建时间"}]; + int64 updated_at = 3 [(aeus.field)={gorm:"index",scenarios:"view;export",comment:"更新时间"}]; + string parent = 4 [(aeus.field)={gorm:"index;size:60",props:"readonly:update",comment:"父级菜单"}]; + string name = 5 [(aeus.field)={gorm:"index;size:60",props:"readonly:update",rule:"unique;required",comment: "组件名称"},(validate.rules).string = {max_len: 60}]; + string label = 6 [(aeus.field)={gorm:"size:120",rule:"required",comment: "菜单标题"},(validate.rules).string = {max_len: 120}]; + string uri = 7 [(aeus.field)={gorm:"size:512",rule:"required",scenarios:"create;update;view;export",comment: "菜单链接"},(validate.rules).string = {max_len: 512}]; + string view_path = 8 [(aeus.field)={gorm:"size:512",scenarios:"create;update;view;export",comment: "视图路径"},(validate.rules).string = {max_len: 512}]; + string icon = 9 [(aeus.field)={gorm:"size:60",scenarios:"create;update;view;export",comment: "菜单图标"},(validate.rules).string = {max_len: 60}]; + bool hidden = 10 [(aeus.field)={scenarios:"create;update;view;export",comment:"是否隐藏"}]; + bool public = 11 [(aeus.field)={scenarios:"create;update;view;export",comment:"是否公开"}]; + string description = 12 [(aeus.field)={gorm:"size:1024",scenarios:"create;update;view;export;list",format:"textarea",comment: "备注说明"},(validate.rules).string = {max_len: 1024}]; } // Role 角色模型定义 @@ -32,9 +34,11 @@ message Role { table: "roles" }; 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}]; + int64 created_at = 2 [(aeus.field)={scenarios:"view;export",comment:"创建时间"}]; + int64 updated_at = 3 [(aeus.field)={gorm:"index",scenarios:"view;export",comment:"更新时间"}]; + string name = 4 [(aeus.field)={gorm:"index;size:60",props:"readonly:update",comment: "角色名称"},(validate.rules).string = {max_len: 60}]; + string label = 5 [(aeus.field)={gorm:"size:60",comment: "角色标题"},(validate.rules).string = {max_len: 60}]; + string description = 6 [(aeus.field)={gorm:"size:1024",scenarios:"list;create;update;export",format:"textarea",comment: "备注说明"},(validate.rules).string = {max_len: 1024}]; } // Permission 权限模型定义 @@ -43,7 +47,7 @@ message Permission { table: "permissions" }; int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment: "权限ID"}]; - int64 menu_id = 2 [(aeus.field)={gorm:"index",rule:"required",comment: "所属菜单"}]; + string menu = 2 [(aeus.field)={gorm:"index;size:60",rule:"required",comment: "所属菜单"}]; string permission = 3 [(aeus.field)={gorm:"index;size:60",rule:"required",comment: "权限名称"},(validate.rules).string = {max_len: 60}]; string label = 4 [(aeus.field)={gorm:"size:60",rule:"required",comment: "权限标题"},(validate.rules).string = {max_len: 60}]; } @@ -54,8 +58,8 @@ message RolePermission { table: "role_permissions" }; 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"}]; + string role = 2 [(aeus.field)={gorm:"index;size:60",rule:"required",comment: "角色"},(validate.rules).string = {max_len: 60}]; + string permission = 3 [(aeus.field)={gorm:"size:60",rule:"required",comment: "权限"}]; } // User 用户模型定义 @@ -65,18 +69,19 @@ message User { }; 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 updated_at = 3 [(aeus.field)={gorm:"index",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}]; + string role = 6 [(aeus.field)={gorm:"size:60;not null;default:''",rule:"required",format:"role",live:"type:dropdown;url:/role/labels",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}]; + string status = 8 [(aeus.field)={scenarios:"create,update,list,search",gorm:"size:20;default:normal",enum:"normal:正常;disable:禁用",comment:"状态"}]; + int64 dept_id = 9 [(aeus.field) = {gorm:"not null;default:0",rule:"required",live:"type:dropdown;url:/department/labels",format:"department",comment: "所属部门"}]; + string tag = 10 [ (aeus.field)={gorm:"size:60",scenarios:"list;create;update",dropdown:"created;filterable;default_first",live:"type:dropdown;url:/user/tags",comment: "用户标签"},(validate.rules).string = {max_len: 60}]; + string password = 11 [(aeus.field)={gorm:"size:60",rule:"required",scenarios:"create",comment: "用户密码"},(validate.rules).string = {max_len: 60}]; + string email = 12 [(aeus.field)={gorm:"size:60",scenarios:"create;update;view;list;export",comment: "用户邮箱"},(validate.rules).string = {max_len: 60}]; + string avatar = 13 [(aeus.field)={gorm:"size:1024",scenarios:"view",comment: "用户头像"},(validate.rules).string = {max_len: 1024}]; + string gender = 14 [(aeus.field)={gorm:"size:20;default:man",rule:"required",scenarios:"list;create;update;view;export",enum:"man:男;woman:女;other:其他",comment: "用户性别"},(validate.rules).string = {max_len: 20}]; + string description = 15 [(aeus.field)={gorm:"size:1024",format:"textarea",scenarios:"create;update;view;export",comment: "备注说明"},(validate.rules).string = {max_len: 1024}]; } // Department 部门模型定义 @@ -86,12 +91,27 @@ message Department { }; int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment:"ID"}]; int64 created_at = 2 [(aeus.field)={scenarios:"view;export",comment:"创建时间"}]; - int64 updated_at = 3 [(aeus.field)={scenarios:"view;export",comment:"更新时间"}]; + int64 updated_at = 3 [(aeus.field)={gorm:"index",scenarios:"view;export",comment:"更新时间"}]; int64 parent_id = 4 [(aeus.field)={format:"department",comment:"父级部门"}]; 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}]; } +message Login { + option (aeus.rest) = { + table: "logins" + }; + int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment:"ID"}]; + int64 created_at = 2 [(aeus.field)={scenarios:"list;search;view;export",comment:"登录时间"}]; + string uid = 4 [(aeus.field)={gorm:"index;size:20",rule:"required",props:"readonly:update",format:"user",comment: "用户工号"},(validate.rules).string = {min_len: 5, max_len: 20}]; + string ip = 5 [(aeus.field)={gorm:"size:128",scenarios:"list;search;view;export",comment: "登录地址"}]; + string browser = 6 [(aeus.field)={gorm:"size:128",scenarios:"list;view;export",comment: "浏览器"}]; + string os = 7 [(aeus.field)={gorm:"size:128",scenarios:"list;view;export",comment: "操作系统"}]; + string platform = 8 [(aeus.field)={gorm:"size:128",scenarios:"list;view;export",comment: "系统平台"}]; + string access_token = 9 [(aeus.field)={gorm:"size:1024",scenarios:"list;view;export",comment: "访问令牌"}]; + string user_agent = 10 [(aeus.field)={gorm:"size:1024",scenarios:"list;view;export",comment: "用户代理"}]; +} + // Setting 参数设置表 message Setting { option (aeus.rest) = { @@ -250,11 +270,16 @@ service UserService { } +message DepartmentLabelValue { + string label = 1; + int64 value = 2; +} + message GetDepartmentLabelRequest { } message GetDepartmentLabelResponse { - repeated LabelValue data = 1; + repeated DepartmentLabelValue data = 1; } service DepartmentService { @@ -282,6 +307,15 @@ message GetRolePermissionResponse { repeated string permissions = 2; } +message SaveRolePermissionRequest { + string role = 1; + repeated string permissions = 2; +} + +message SaveRolePermissionResponse { + string role = 1; +} + service RoleService { // 获取角色标签 rpc GetRoleLabels(GetRoleLabelRequest) returns (GetRoleLabelResponse) { @@ -295,6 +329,13 @@ service RoleService { get: "/role/permissions" }; } + + rpc SaveRolePermission(SaveRolePermissionRequest) returns (SaveRolePermissionResponse) { + option (google.api.http) = { + post: "/role/permissions" + body: "*" + }; + } } diff --git a/pb/organize_grpc.pb.go b/pb/organize_grpc.pb.go index 743f7eb..7a55e19 100644 --- a/pb/organize_grpc.pb.go +++ b/pb/organize_grpc.pb.go @@ -473,6 +473,7 @@ var DepartmentService_ServiceDesc = grpc.ServiceDesc{ const ( RoleService_GetRoleLabels_FullMethodName = "/organize.RoleService/GetRoleLabels" RoleService_GetRolePermissions_FullMethodName = "/organize.RoleService/GetRolePermissions" + RoleService_SaveRolePermission_FullMethodName = "/organize.RoleService/SaveRolePermission" ) // RoleServiceClient is the client API for RoleService service. @@ -483,6 +484,7 @@ 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) + SaveRolePermission(ctx context.Context, in *SaveRolePermissionRequest, opts ...grpc.CallOption) (*SaveRolePermissionResponse, error) } type roleServiceClient struct { @@ -513,6 +515,16 @@ func (c *roleServiceClient) GetRolePermissions(ctx context.Context, in *GetRoleP return out, nil } +func (c *roleServiceClient) SaveRolePermission(ctx context.Context, in *SaveRolePermissionRequest, opts ...grpc.CallOption) (*SaveRolePermissionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(SaveRolePermissionResponse) + err := c.cc.Invoke(ctx, RoleService_SaveRolePermission_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. @@ -521,6 +533,7 @@ type RoleServiceServer interface { GetRoleLabels(context.Context, *GetRoleLabelRequest) (*GetRoleLabelResponse, error) // 获取角色权限 GetRolePermissions(context.Context, *GetRolePermissionRequest) (*GetRolePermissionResponse, error) + SaveRolePermission(context.Context, *SaveRolePermissionRequest) (*SaveRolePermissionResponse, error) mustEmbedUnimplementedRoleServiceServer() } @@ -537,6 +550,9 @@ func (UnimplementedRoleServiceServer) GetRoleLabels(context.Context, *GetRoleLab func (UnimplementedRoleServiceServer) GetRolePermissions(context.Context, *GetRolePermissionRequest) (*GetRolePermissionResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetRolePermissions not implemented") } +func (UnimplementedRoleServiceServer) SaveRolePermission(context.Context, *SaveRolePermissionRequest) (*SaveRolePermissionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SaveRolePermission not implemented") +} func (UnimplementedRoleServiceServer) mustEmbedUnimplementedRoleServiceServer() {} func (UnimplementedRoleServiceServer) testEmbeddedByValue() {} @@ -594,6 +610,24 @@ func _RoleService_GetRolePermissions_Handler(srv interface{}, ctx context.Contex return interceptor(ctx, in, info, handler) } +func _RoleService_SaveRolePermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SaveRolePermissionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RoleServiceServer).SaveRolePermission(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RoleService_SaveRolePermission_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RoleServiceServer).SaveRolePermission(ctx, req.(*SaveRolePermissionRequest)) + } + 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) @@ -609,6 +643,10 @@ var RoleService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetRolePermissions", Handler: _RoleService_GetRolePermissions_Handler, }, + { + MethodName: "SaveRolePermission", + Handler: _RoleService_SaveRolePermission_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "organize.proto", diff --git a/pb/organize_http.pb.go b/pb/organize_http.pb.go index 4312532..bfd025c 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-16 11:37:44 +// date: 2025-06-17 15:01:15 package pb @@ -34,6 +34,8 @@ type RoleServiceHttpServer interface { GetRoleLabels(context.Context, *GetRoleLabelRequest) (*GetRoleLabelResponse, error) GetRolePermissions(context.Context, *GetRolePermissionRequest) (*GetRolePermissionResponse, error) + + SaveRolePermission(context.Context, *SaveRolePermissionRequest) (*SaveRolePermissionResponse, error) } type AuthServiceHttpServer interface { @@ -250,6 +252,26 @@ func handleRoleServiceGetRolePermissions(s RoleServiceHttpServer) http.HandleFun } } +func handleRoleServiceSaveRolePermission(s RoleServiceHttpServer) http.HandleFunc { + return func(ctx *http.Context) (err error) { + req := &SaveRolePermissionRequest{} + + if err := ctx.Bind(req); err != nil { + return ctx.Error(errors.Invalid, err.Error()) + } + + if res, err := s.SaveRolePermission(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{} @@ -346,6 +368,9 @@ func RegisterRoleServiceRouter(hs *http.Server, s RoleServiceHttpServer) { // Register handle GetRolePermissions route hs.GET("/role/permissions", handleRoleServiceGetRolePermissions(s)) + // Register handle SaveRolePermission route + hs.POST("/role/permissions", handleRoleServiceSaveRolePermission(s)) + } func RegisterAuthServiceRouter(hs *http.Server, s AuthServiceHttpServer) { diff --git a/pb/organize_model.pb.go b/pb/organize_model.pb.go index cc47ad4..40df4a1 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-16 11:37:44 +// date: 2025-06-17 15:01:15 package pb @@ -10,15 +10,17 @@ import ( type MenuModel struct { 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"` + CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"view;export"` + UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index" comment:"更新时间" scenarios:"view;export"` + Parent string `json:"parent" yaml:"parent" xml:"parent" gorm:"index;size:60" comment:"父级菜单" props:"readonly:update"` + Name string `json:"name" yaml:"name" xml:"name" gorm:"index;size:60" comment:"组件名称" props:"readonly:update" rule:"unique;required"` Label string `json:"label" yaml:"label" xml:"label" gorm:"size:120" comment:"菜单标题" rule:"required"` Uri string `json:"uri" yaml:"uri" xml:"uri" gorm:"size:512" comment:"菜单链接" scenarios:"create;update;view;export" rule:"required"` 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"` + Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" scenarios:"create;update;view;export;list" format:"textarea"` } func (m *MenuModel) TableName() string { @@ -27,7 +29,9 @@ func (m *MenuModel) TableName() string { func (m *MenuModel) FromValue(x *Menu) { m.Id = x.Id - m.ParentId = x.ParentId + m.CreatedAt = x.CreatedAt + m.UpdatedAt = x.UpdatedAt + m.Parent = x.Parent m.Name = x.Name m.Label = x.Label m.Uri = x.Uri @@ -41,7 +45,9 @@ func (m *MenuModel) FromValue(x *Menu) { func (m *MenuModel) ToValue() (x *Menu) { x = &Menu{} x.Id = m.Id - x.ParentId = m.ParentId + x.CreatedAt = m.CreatedAt + x.UpdatedAt = m.UpdatedAt + x.Parent = m.Parent x.Name = m.Name x.Label = m.Label x.Uri = m.Uri @@ -87,9 +93,11 @@ func NewMenuModel() *MenuModel { type RoleModel struct { Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"角色ID"` + CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"view;export"` + UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index" comment:"更新时间" scenarios:"view;export"` 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"` + Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" scenarios:"list;create;update;export" format:"textarea"` } func (m *RoleModel) TableName() string { @@ -98,6 +106,8 @@ func (m *RoleModel) TableName() string { func (m *RoleModel) FromValue(x *Role) { m.Id = x.Id + m.CreatedAt = x.CreatedAt + m.UpdatedAt = x.UpdatedAt m.Name = x.Name m.Label = x.Label m.Description = x.Description @@ -106,6 +116,8 @@ func (m *RoleModel) FromValue(x *Role) { func (m *RoleModel) ToValue() (x *Role) { x = &Role{} x.Id = m.Id + x.CreatedAt = m.CreatedAt + x.UpdatedAt = m.UpdatedAt x.Name = m.Name x.Label = m.Label x.Description = m.Description @@ -146,7 +158,7 @@ func NewRoleModel() *RoleModel { type PermissionModel struct { 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"` + Menu string `json:"menu" yaml:"menu" xml:"menu" gorm:"index;size:60" 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"` } @@ -157,7 +169,7 @@ func (m *PermissionModel) TableName() string { func (m *PermissionModel) FromValue(x *Permission) { m.Id = x.Id - m.MenuId = x.MenuId + m.Menu = x.Menu m.Permission = x.Permission m.Label = x.Label } @@ -165,7 +177,7 @@ func (m *PermissionModel) FromValue(x *Permission) { func (m *PermissionModel) ToValue() (x *Permission) { x = &Permission{} x.Id = m.Id - x.MenuId = m.MenuId + x.Menu = m.Menu x.Permission = m.Permission x.Label = m.Label return x @@ -204,9 +216,9 @@ func NewPermissionModel() *PermissionModel { } type RolePermissionModel struct { - 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"` + Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"ID"` + Role string `json:"role" yaml:"role" xml:"role" gorm:"index;size:60" comment:"角色" rule:"required"` + Permission string `json:"permission" yaml:"permission" xml:"permission" gorm:"size:60" comment:"权限" rule:"required"` } func (m *RolePermissionModel) TableName() string { @@ -216,14 +228,14 @@ func (m *RolePermissionModel) TableName() string { func (m *RolePermissionModel) FromValue(x *RolePermission) { m.Id = x.Id m.Role = x.Role - m.PermissionId = x.PermissionId + m.Permission = x.Permission } func (m *RolePermissionModel) ToValue() (x *RolePermission) { x = &RolePermission{} x.Id = m.Id x.Role = m.Role - x.PermissionId = m.PermissionId + x.Permission = m.Permission return x } @@ -244,7 +256,7 @@ func (m *RolePermissionModel) Delete(db *gorm.DB) (err error) { } func (m *RolePermissionModel) Find(db *gorm.DB, pk any) (err error) { - return db.Where("permission_id=?", pk).First(m).Error + return db.Where("permission=?", pk).First(m).Error } func (m *RolePermissionModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { @@ -262,18 +274,19 @@ func NewRolePermissionModel() *RolePermissionModel { type UserModel struct { Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"ID"` CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"view;export"` - UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" comment:"更新时间" scenarios:"view;export"` + UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index" 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"` + Role string `json:"role" yaml:"role" xml:"role" gorm:"size:60;not null;default:''" comment:"所属角色" format:"role" rule:"required" live:"type:dropdown;url:/role/labels"` 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"` + Status string `json:"status" yaml:"status" xml:"status" gorm:"size:20;default:normal" comment:"状态" scenarios:"create,update,list,search" enum:"normal:正常;disable:禁用"` + DeptId int64 `json:"dept_id" yaml:"deptId" xml:"deptId" gorm:"not null;default:0" comment:"所属部门" format:"department" rule:"required" live:"type:dropdown;url:/department/labels"` + Tag string `json:"tag" yaml:"tag" xml:"tag" gorm:"size:60" comment:"用户标签" scenarios:"list;create;update" live:"type:dropdown;url:/user/tags" dropdown:"created;filterable;default_first"` 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"` + Gender string `json:"gender" yaml:"gender" xml:"gender" gorm:"size:20;default:man" comment:"用户性别" scenarios:"list;create;update;view;export" rule:"required" enum:"man:男;woman:女;other:其他"` + Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" scenarios:"create;update;view;export" format:"textarea"` } func (m *UserModel) TableName() string { @@ -288,6 +301,7 @@ func (m *UserModel) FromValue(x *User) { m.Username = x.Username m.Role = x.Role m.Admin = x.Admin + m.Status = x.Status m.DeptId = x.DeptId m.Tag = x.Tag m.Password = x.Password @@ -306,6 +320,7 @@ func (m *UserModel) ToValue() (x *User) { x.Username = m.Username x.Role = m.Role x.Admin = m.Admin + x.Status = m.Status x.DeptId = m.DeptId x.Tag = m.Tag x.Password = m.Password @@ -351,10 +366,10 @@ func NewUserModel() *UserModel { type DepartmentModel struct { Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"ID"` CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"view;export"` - UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" comment:"更新时间" scenarios:"view;export"` + UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index" comment:"更新时间" scenarios:"view;export"` ParentId int64 `json:"parent_id" yaml:"parentId" xml:"parentId" comment:"父级部门" format:"department"` 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"` + Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" scenarios:"create;update;view;export;list" format:"textarea"` } func (m *DepartmentModel) TableName() string { @@ -413,13 +428,87 @@ func NewDepartmentModel() *DepartmentModel { return &DepartmentModel{} } +type LoginModel struct { + Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"ID"` + CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"登录时间" scenarios:"list;search;view;export"` + Uid string `json:"uid" yaml:"uid" xml:"uid" gorm:"index;size:20" comment:"用户工号" format:"user" props:"readonly:update" rule:"required"` + Ip string `json:"ip" yaml:"ip" xml:"ip" gorm:"size:128" comment:"登录地址" scenarios:"list;search;view;export"` + Browser string `json:"browser" yaml:"browser" xml:"browser" gorm:"size:128" comment:"浏览器" scenarios:"list;view;export"` + Os string `json:"os" yaml:"os" xml:"os" gorm:"size:128" comment:"操作系统" scenarios:"list;view;export"` + Platform string `json:"platform" yaml:"platform" xml:"platform" gorm:"size:128" comment:"系统平台" scenarios:"list;view;export"` + AccessToken string `json:"access_token" yaml:"accessToken" xml:"accessToken" gorm:"size:1024" comment:"访问令牌" scenarios:"list;view;export"` + UserAgent string `json:"user_agent" yaml:"userAgent" xml:"userAgent" gorm:"size:1024" comment:"用户代理" scenarios:"list;view;export"` +} + +func (m *LoginModel) TableName() string { + return "logins" +} + +func (m *LoginModel) FromValue(x *Login) { + m.Id = x.Id + m.CreatedAt = x.CreatedAt + m.Uid = x.Uid + m.Ip = x.Ip + m.Browser = x.Browser + m.Os = x.Os + m.Platform = x.Platform + m.AccessToken = x.AccessToken + m.UserAgent = x.UserAgent +} + +func (m *LoginModel) ToValue() (x *Login) { + x = &Login{} + x.Id = m.Id + x.CreatedAt = m.CreatedAt + x.Uid = m.Uid + x.Ip = m.Ip + x.Browser = m.Browser + x.Os = m.Os + x.Platform = m.Platform + x.AccessToken = m.AccessToken + x.UserAgent = m.UserAgent + return x +} + +func (m *LoginModel) Create(db *gorm.DB) (err error) { + return db.Create(m).Error +} + +func (m *LoginModel) UpdateColumn(db *gorm.DB, column string, value any) (err error) { + return db.Model(m).UpdateColumn(column, value).Error +} + +func (m *LoginModel) Save(db *gorm.DB) (err error) { + return db.Save(m).Error +} + +func (m *LoginModel) Delete(db *gorm.DB) (err error) { + return db.Delete(m).Error +} + +func (m *LoginModel) Find(db *gorm.DB, pk any) (err error) { + return db.Where("user_agent=?", pk).First(m).Error +} + +func (m *LoginModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { + return db.Where(query, args...).First(m).Error +} + +func (m *LoginModel) FindAll(db *gorm.DB, query any, args ...any) (err error) { + return db.Where(query, args...).Find(m).Error +} + +func NewLoginModel() *LoginModel { + return &LoginModel{} +} + 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"` + Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" scenarios:"create;update;view;export" format:"textarea"` } func (m *SettingModel) TableName() string { diff --git a/permission.go b/permission.go new file mode 100644 index 0000000..dba60a2 --- /dev/null +++ b/permission.go @@ -0,0 +1,59 @@ +package aeusadmin + +import ( + "context" + "fmt" + "slices" + "time" + + "git.nobla.cn/golang/aeus-admin/models" + "git.nobla.cn/golang/aeus-admin/pkg/dbcache" + "git.nobla.cn/golang/aeus/middleware/auth" + "git.nobla.cn/golang/aeus/pkg/errors" + "gorm.io/gorm" +) + +type PermissionChecker struct { + db *gorm.DB +} + +func (p *PermissionChecker) getUserPermissions(ctx context.Context, uid string) (permissions []string, err error) { + permissions, err = dbcache.TryCache(ctx, fmt.Sprintf("user:permissions:%s", uid), func(tx *gorm.DB) ([]string, error) { + var ss []string + err = tx.Select("permission").Model(&models.RolePermission{}). + Joins("LEFT JOIN users on users.role = role_permissions.role"). + Where("users.uid = ?", uid). + Pluck("permission", &ss). + Error + return ss, err + }, dbcache.WithCacheDuration(time.Minute), dbcache.WithDB(p.db)) + return +} + + +func (p *PermissionChecker) CheckPermission(ctx context.Context, permission string) (err error) { + var ( + uid string + ps []string + ) + if claims, ok := auth.FromContext(ctx); !ok { + return errors.ErrAccessDenied + } else { + if uid, err = claims.GetSubject(); err != nil { + return + } + } + if ps, err = p.getUserPermissions(ctx, uid); err != nil { + return + } + if !slices.Contains(ps, permission) { + err = errors.ErrPermissionDenied + } + return +} + +func NewPermissionChecker(db *gorm.DB) *PermissionChecker { + return &PermissionChecker{ + db: db, + } +} diff --git a/pkg/dbcache/cache.go b/pkg/dbcache/cache.go new file mode 100644 index 0000000..52f7392 --- /dev/null +++ b/pkg/dbcache/cache.go @@ -0,0 +1,113 @@ +package dbcache + +import ( + "context" + "time" + + "git.nobla.cn/golang/aeus/pkg/cache" + "git.nobla.cn/golang/aeus/pkg/errors" + "golang.org/x/sync/singleflight" + "gorm.io/gorm" +) + +var singleInstance singleflight.Group + +type ( + CacheOptions struct { + db *gorm.DB + cache cache.Cache + dependency CacheDependency + cacheDuration time.Duration + } + + CacheOption func(o *CacheOptions) + + cacheEntry[T any] struct { + Value T + CompareValue string + CreatedAt int64 + } +) + +func WithDB(db *gorm.DB) CacheOption { + return func(o *CacheOptions) { + o.db = db + } +} + +func WithCache(c cache.Cache) CacheOption { + return func(o *CacheOptions) { + o.cache = c + } +} + +func WithCacheDuration(d time.Duration) CacheOption { + return func(o *CacheOptions) { + o.cacheDuration = d + } +} + +func WithDependency(d CacheDependency) CacheOption { + return func(o *CacheOptions) { + o.dependency = d + } +} + +// TryCache 尝试从缓存中获取数据 +func TryCache[T any](ctx context.Context, key string, f func(tx *gorm.DB) (T, error), cbs ...CacheOption) (result T, err error) { + var ( + none T + value any + val any + hasDependValue bool + dependValue string + ) + opts := &CacheOptions{ + cache: cache.Default(), + cacheDuration: time.Minute * 10, + } + for _, cb := range cbs { + cb(opts) + } + if opts.db == nil { + return none, errors.Format(errors.Unavailable, "db instance unavailable") + } + //从缓存加载数据 + if value, err = opts.cache.Get(ctx, key); err == nil { + if entry, ok := value.(*cacheEntry[T]); ok { + if time.Now().Unix()-entry.CreatedAt <= 1 { + return entry.Value, nil + } + if opts.dependency == nil { + return entry.Value, nil + } + if dependValue, err = opts.dependency.GetValue(ctx, opts.db); err == nil { + hasDependValue = true + if entry.CompareValue == dependValue { + return entry.Value, nil + } else { + opts.cache.Delete(ctx, key) + } + } + } + } + //从数据库加载数据 + tx := opts.db.WithContext(ctx) + if val, err, _ = singleInstance.Do(key, func() (any, error) { + if result, err = f(tx); err == nil { + if !hasDependValue && opts.dependency != nil { + dependValue, err = opts.dependency.GetValue(ctx, tx) + } + opts.cache.Put(ctx, key, &cacheEntry[T]{ + CompareValue: dependValue, + Value: result, + CreatedAt: time.Now().Unix(), + }, opts.cacheDuration) + } + return result, err + }); err != nil { + return none, err + } else { + return val.(T), err + } +} diff --git a/pkg/dbcache/depend.go b/pkg/dbcache/depend.go new file mode 100644 index 0000000..6cd2040 --- /dev/null +++ b/pkg/dbcache/depend.go @@ -0,0 +1,29 @@ +package dbcache + +import ( + "context" + + "gorm.io/gorm" +) + +type CacheDependency interface { + GetValue(ctx context.Context, tx *gorm.DB) (value string, err error) +} + +type SqlDependency struct { + dependSQL string + dependArgs []any +} + +func (d *SqlDependency) GetValue(ctx context.Context, tx *gorm.DB) (value string, err error) { + var dependValue string + err = tx.Raw(d.dependSQL, d.dependArgs...).Scan(&dependValue).Error + return dependValue, err +} + +func NewSqlDependency(dependSQL string, dependArgs ...any) *SqlDependency { + return &SqlDependency{ + dependSQL: dependSQL, + dependArgs: dependArgs, + } +} diff --git a/server.go b/server.go index b981d31..0365188 100644 --- a/server.go +++ b/server.go @@ -2,6 +2,7 @@ package aeusadmin import ( "context" + "fmt" "html/template" "os" "path" @@ -11,6 +12,7 @@ import ( "git.nobla.cn/golang/aeus-admin/defaults" "git.nobla.cn/golang/aeus-admin/models" + "git.nobla.cn/golang/aeus-admin/pkg/dbcache" adminTypes "git.nobla.cn/golang/aeus-admin/types" "git.nobla.cn/golang/aeus/pkg/errors" "git.nobla.cn/golang/aeus/pkg/pool" @@ -29,6 +31,7 @@ func getModels() []any { &models.Role{}, &models.User{}, &models.Menu{}, + &models.Login{}, &models.Permission{}, &models.RolePermission{}, &models.Setting{}, @@ -47,10 +50,7 @@ func checkModelMenu(db *gorm.DB, viewPath string, apiPrefix string, model *rest. 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.Parent = row.Parent } value.Name = row.Name value.Hidden = row.Hidden @@ -79,7 +79,7 @@ func checkModelMenu(db *gorm.DB, viewPath string, apiPrefix string, model *rest. if err = db.Where("name = ?", menuName).First(value).Error; err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { value.Name = menuName - value.ParentId = 0 + value.Parent = "" value.Label = inflector.Camel2words(model.Naming().Pluralize) if translate != nil { value.Label = translate.Menu(model, value.Label) @@ -94,12 +94,12 @@ func checkModelMenu(db *gorm.DB, viewPath string, apiPrefix string, model *rest. } // checkModelPermission 检查模型权限是否写入到数据库 -func checkModelPermission(db *gorm.DB, menuId int64, scene string, model *rest.Model, translate Translate) (permissionModel *models.Permission, err error) { +func checkModelPermission(db *gorm.DB, menuName string, scene string, model *rest.Model, translate Translate) (permissionModel *models.Permission, err error) { permissionModel = &models.Permission{} permission := model.Permission(scene) - if err = db.Where("permission = ?", permission).First(permissionModel).Error; err != nil { + if err = db.Where("permission = ? AND menu = ?", permission, menuName).First(permissionModel).Error; err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { - permissionModel.MenuId = menuId + permissionModel.Menu = menuName permissionModel.Label = scene if translate != nil { permissionModel.Label = translate.Permission(model, scene, permissionModel.Label) @@ -111,6 +111,19 @@ func checkModelPermission(db *gorm.DB, menuId int64, scene string, model *rest.M return } +func replaceModelPermission(db *gorm.DB, menuName string, permission string, label string) (permissionModel *models.Permission, err error) { + permissionModel = &models.Permission{} + if err = db.Where("permission = ? AND menu = ?", permission, menuName).First(permissionModel).Error; err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + permissionModel.Menu = menuName + permissionModel.Label = label + permissionModel.Permission = permission + err = db.Create(permissionModel).Error + } + } + return +} + // checkModel 检查模型 func checkModel(opts *options, model *rest.Model) (err error) { var ( @@ -123,7 +136,16 @@ func checkModel(opts *options, model *rest.Model) (err error) { } for _, s := range defaultScenarios { if model.HasScenario(s) { - if _, err = checkModelPermission(tx, menuModel.Id, s, model, opts.translate); err != nil { + if _, err = checkModelPermission(tx, menuModel.Name, s, model, opts.translate); err != nil { + tx.Rollback() + return + } + } + } + modelValue := reflect.New(model.Value().Type()).Interface() + if v, ok := modelValue.(adminTypes.PerrmissionModule); ok { + for k, v := range v.ModelPermissions() { + if _, err = replaceModelPermission(tx, menuModel.Name, k, v); err != nil { tx.Rollback() return } @@ -135,6 +157,15 @@ func checkModel(opts *options, model *rest.Model) (err error) { // generateVueFile 生成Vue文件 func generateVueFile(prefix string, apiPrefix string, mv *rest.Model) (err error) { + refVal := reflect.New(mv.Value().Type()).Interface() + if v, ok := refVal.(adminTypes.MenuModel); ok { + instance := v.GetMenu() + if instance != nil { + if instance.Hidden { + return + } + } + } filename := path.Join(prefix, mv.Naming().ModuleName, mv.Naming().Singular, "Index.vue") if _, err = os.Stat(filename); err == nil { return @@ -146,7 +177,8 @@ func generateVueFile(prefix string, apiPrefix string, mv *rest.Model) (err error } } var ( - temp *template.Template + editable bool + temp *template.Template ) if temp, err = template.New("vue").Parse(vueTemplate); err != nil { return @@ -154,6 +186,9 @@ func generateVueFile(prefix string, apiPrefix string, mv *rest.Model) (err error permissions := make(map[string]string) for _, s := range defaultScenarios { if mv.HasScenario(s) { + if s == types.ScenarioCreate || s == types.ScenarioUpdate { + editable = true + } permissions[s] = mv.Permission(s) } } @@ -161,6 +196,7 @@ func generateVueFile(prefix string, apiPrefix string, mv *rest.Model) (err error ModuleName: mv.ModuleName(), TableName: mv.TableName(), Permissions: permissions, + Readonly: !editable, ApiPrefix: strings.TrimPrefix(apiPrefix, "/"), } writer := pool.GetBuffer() @@ -241,21 +277,37 @@ func registerRESTRoute(domain string, db *gorm.DB, hs *http.Server) { ) scenario := ctx.Request().URL.Query().Get("scenario") if scenario == "" { - schemas, err = rest.GetSchemas( + schemas, err = dbcache.TryCache( ctx.Request().Context(), - db.WithContext(ctx.Request().Context()), - "", - ctx.Param("module"), - ctx.Param("table"), + fmt.Sprintf("rest:schems:%s:%s", ctx.Param("module"), ctx.Param("table")), + func(tx *gorm.DB) ([]*restTypes.Schema, error) { + return rest.GetSchemas( + ctx.Request().Context(), + tx, + "", + ctx.Param("module"), + ctx.Param("table"), + ) + }, + dbcache.WithDB(db), + dbcache.WithDependency(dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM `schemas`")), ) } else { - schemas, err = rest.VisibleSchemas( + schemas, err = dbcache.TryCache( ctx.Request().Context(), - db.WithContext(ctx.Request().Context()), - "", - ctx.Param("module"), - ctx.Param("table"), - scenario, + fmt.Sprintf("rest:schems:%s:%s", ctx.Param("module"), ctx.Param("table")), + func(tx *gorm.DB) ([]*restTypes.Schema, error) { + return rest.VisibleSchemas( + ctx.Request().Context(), + db.WithContext(ctx.Request().Context()), + "", + ctx.Param("module"), + ctx.Param("table"), + scenario, + ) + }, + dbcache.WithDB(db), + dbcache.WithDependency(dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM `schemas`")), ) } if err != nil { @@ -314,17 +366,16 @@ func Init(ctx context.Context, cbs ...Option) (err error) { if err = initREST(ctx, opts); err != nil { return } - 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 + if !opts.disableDefault { + if err = defaults.Generate(opts.db); err != nil { + return + } } return } diff --git a/service/auth.go b/service/auth.go index 0f437e4..05ee2a3 100644 --- a/service/auth.go +++ b/service/auth.go @@ -7,8 +7,10 @@ import ( "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/metadata" "git.nobla.cn/golang/aeus/pkg/errors" jwt "github.com/golang-jwt/jwt/v5" + "github.com/mssola/useragent" "gorm.io/gorm" ) @@ -58,11 +60,13 @@ func (s *AuthService) Login(ctx context.Context, req *pb.LoginRequest) (res *pb. return nil, errors.Format(errors.Invalid, err.Error()) } if err = model.FindOne(tx, "uid=?", req.Username); err != nil { - return + return nil, errors.ErrAccessDenied + } + if model.Status != types.UserStatusNormal { + return nil, errors.ErrAccessDenied } if model.Password != req.Password { - err = errors.ErrAccessDenied - return + return nil, errors.ErrAccessDenied } claims := types.Claims{ Uid: model.Uid, @@ -71,12 +75,26 @@ func (s *AuthService) Login(ctx context.Context, req *pb.LoginRequest) (res *pb. ExpirationAt: time.Now().Add(time.Second * time.Duration(s.opts.ttl)).Unix(), } token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) + res = &pb.LoginResponse{} if res.Token, err = token.SignedString(s.opts.secret); err == nil { res.Uid = model.Uid res.Username = model.Username res.Expires = s.opts.ttl } + loginModel := &models.Login{} + loginModel.Uid = model.Uid + loginModel.AccessToken = res.Token + md := metadata.FromContext(ctx) + if userAgent, ok := md.Get("User-Agent"); ok { + ua := useragent.New(userAgent) + loginModel.Os = ua.OS() + loginModel.Platform = ua.Platform() + loginModel.UserAgent = userAgent + browser, browserVersion := ua.Browser() + loginModel.Browser = browser + "/" + browserVersion + tx.Save(loginModel) + } return } diff --git a/service/department.go b/service/department.go index f0d6906..dc52f2b 100644 --- a/service/department.go +++ b/service/department.go @@ -2,10 +2,11 @@ package service import ( "context" - "strconv" + "fmt" "git.nobla.cn/golang/aeus-admin/models" "git.nobla.cn/golang/aeus-admin/pb" + "git.nobla.cn/golang/aeus-admin/pkg/dbcache" "gorm.io/gorm" ) @@ -27,18 +28,25 @@ func WithDepartmentDB(db *gorm.DB) DepartmentOption { } 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)), + res = &pb.GetDepartmentLabelResponse{} + res.Data, err = dbcache.TryCache(ctx, fmt.Sprintf("department:labels"), func(tx *gorm.DB) ([]*pb.DepartmentLabelValue, error) { + values := make([]*models.Department, 0) + if err = tx.Find(&values).Error; err == nil { + items := make([]*pb.DepartmentLabelValue, 0, len(values)) + for _, v := range values { + items = append(items, &pb.DepartmentLabelValue{ + Label: v.Name, + Value: v.Id, + }) + } + return items, nil + } else { + return nil, err } - for _, v := range values { - res.Data = append(res.Data, &pb.LabelValue{ - Label: v.Name, - Value: strconv.FormatInt(v.Id, 10), - }) - } - } + }, + dbcache.WithDB(s.opts.db), + dbcache.WithDependency(dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM departments")), + ) return } diff --git a/service/role.go b/service/role.go index 7ca39bb..6319cc6 100644 --- a/service/role.go +++ b/service/role.go @@ -2,9 +2,11 @@ package service import ( "context" + "fmt" "git.nobla.cn/golang/aeus-admin/models" "git.nobla.cn/golang/aeus-admin/pb" + "git.nobla.cn/golang/aeus-admin/pkg/dbcache" "gorm.io/gorm" ) @@ -26,32 +28,57 @@ func WithRoleDB(db *gorm.DB) RoleOption { } 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)), + res = &pb.GetRoleLabelResponse{} + res.Data, err = dbcache.TryCache(ctx, fmt.Sprintf("role:labels"), func(tx *gorm.DB) ([]*pb.LabelValue, error) { + values := make([]*models.Role, 0) + if err = tx.Find(&values).Error; err == nil { + items := make([]*pb.LabelValue, 0, len(values)) + for _, v := range values { + items = append(items, &pb.LabelValue{ + Label: v.Label, + Value: v.Name, + }) + } + return items, nil + } else { + return nil, err } - for _, v := range values { - res.Data = append(res.Data, &pb.LabelValue{ - Label: v.Label, - Value: v.Name, - }) - } - } + }, + dbcache.WithDB(s.opts.db), + dbcache.WithDependency(dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM roles")), + ) 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 { + var permissions []string + if err = s.opts.db.WithContext(ctx).Model(&models.RolePermission{}).Where("role=?", req.Role).Pluck("permission", &permissions).Error; err != nil { return } res = &pb.GetRolePermissionResponse{ Role: req.Role, - Permissions: make([]string, 0, len(permissions)), + Permissions: permissions, } - for _, permission := range permissions { - res.Permissions = append(res.Permissions, permission.Permission) + return +} + +func (s *RoleService) SaveRolePermission(ctx context.Context, req *pb.SaveRolePermissionRequest) (res *pb.SaveRolePermissionResponse, err error) { + tx := s.opts.db.WithContext(ctx).Begin() + tx.Where("role = ?", req.Role).Delete(&models.RolePermission{}) + values := make([]*models.RolePermission, 0) + for _, permission := range req.Permissions { + item := &models.RolePermission{} + item.Role = req.Role + item.Permission = permission + values = append(values, item) + } + if err = tx.Save(values).Error; err == nil { + tx.Commit() + } else { + tx.Rollback() + } + res = &pb.SaveRolePermissionResponse{ + Role: req.Role, } return } diff --git a/service/setting.go b/service/setting.go index 9a253de..2031119 100644 --- a/service/setting.go +++ b/service/setting.go @@ -19,6 +19,12 @@ type SettingService struct { opts *settingOptions } +func WithSettingDB(db *gorm.DB) SettingOption { + return func(o *settingOptions) { + o.db = db + } +} + 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) diff --git a/service/user.go b/service/user.go index 49ad505..0e2e3f9 100644 --- a/service/user.go +++ b/service/user.go @@ -2,10 +2,12 @@ package service import ( "context" + "fmt" + "time" "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-admin/pkg/dbcache" "git.nobla.cn/golang/aeus/middleware/auth" "git.nobla.cn/golang/aeus/pkg/errors" "gorm.io/gorm" @@ -15,6 +17,7 @@ type ( userOptions struct { db *gorm.DB } + UserOption func(o *userOptions) UserService struct { @@ -36,19 +39,19 @@ func (s *UserService) getUidFromContext(ctx context.Context) (string, error) { } } -func (s *UserService) hasPermission(menuID int64, permissions []*models.Permission) bool { +func (s *UserService) hasPermission(menuName string, permissions []*models.Permission) bool { for _, permission := range permissions { - if permission.MenuId == menuID { + if permission.Menu == menuName { return true } } return false } -func (s *UserService) getPermissions(menuID int64, permissions []*models.Permission) []*pb.PermissionItem { +func (s *UserService) getPermissions(menuName string, permissions []*models.Permission) []*pb.PermissionItem { ss := make([]*pb.PermissionItem, 0, 10) for _, permission := range permissions { - if permission.MenuId == menuID { + if permission.Menu == menuName { ss = append(ss, &pb.PermissionItem{ Value: permission.Permission, Label: permission.Label, @@ -58,11 +61,11 @@ func (s *UserService) getPermissions(menuID int64, permissions []*models.Permiss return ss } -func (s *UserService) recursiveNestedMenu(ctx context.Context, parent int64, perm bool, menus []*models.Menu, permissions []*models.Permission) []*pb.MenuItem { +func (s *UserService) recursiveNestedMenu(ctx context.Context, parent string, 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) { + if row.Parent == parent { + if !row.Public && !s.hasPermission(row.Name, permissions) { continue } v := &pb.MenuItem{ @@ -73,10 +76,10 @@ func (s *UserService) recursiveNestedMenu(ctx context.Context, parent int64, per Route: row.Uri, Public: row.Public, View: row.ViewPath, - Children: s.recursiveNestedMenu(ctx, row.Id, perm, menus, permissions), + Children: s.recursiveNestedMenu(ctx, row.Name, perm, menus, permissions), } if perm { - v.Permissions = s.getPermissions(row.Id, permissions) + v.Permissions = s.getPermissions(row.Name, permissions) } values = append(values, v) } @@ -84,31 +87,45 @@ func (s *UserService) recursiveNestedMenu(ctx context.Context, parent int64, per return values } -func (s *UserService) getRolePermissions(ctx context.Context, db *gorm.DB, role string) (permissions []*models.Permission, err error) { +func (s *UserService) getRolePermissions(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 + err = db.Where("permission IN (SELECT permission FROM role_permissions WHERE role = ?)", role).Find(&permissions).Error return } func (s *UserService) GetMenus(ctx context.Context, req *pb.GetMenuRequest) (res *pb.GetMenuResponse, err error) { - claims, ok := auth.FromContext(ctx) - if !ok { - return nil, errors.ErrAccessDenied - } var ( + uid string 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 { + if uid, err = s.getUidFromContext(ctx); err != nil { return } - res = &pb.GetMenuResponse{ - Data: s.recursiveNestedMenu(ctx, 0, req.Permission, values, permissions), - } + res = &pb.GetMenuResponse{} + res.Data, err = dbcache.TryCache(ctx, fmt.Sprintf("user:menu:%s:%v", uid, req.Permission), func(tx *gorm.DB) ([]*pb.MenuItem, error) { + userModel := &models.User{} + if err = tx.Where("uid=?", uid).First(userModel).Error; err != nil { + return nil, err + } + items := make([]*models.Menu, 0) + if err = tx.Find(&items).Error; err != nil { + return nil, err + } + if userModel.Admin { + permissions = make([]*models.Permission, 0) + if err = tx.Find(&permissions).Error; err != nil { + return nil, err + } + } else { + if permissions, err = s.getRolePermissions(tx, userModel.Role); err != nil { + return nil, err + } + } + return s.recursiveNestedMenu(ctx, "", req.Permission, items, permissions), nil + }, + dbcache.WithDB(s.opts.db), + dbcache.WithDependency(dbcache.NewSqlDependency("SELECT `updated_at` FROM users WHERE `uid`=?", uid)), + ) return } @@ -118,12 +135,18 @@ func (s *UserService) GetProfile(ctx context.Context, req *pb.GetProfileRequest) 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 + res, err = dbcache.TryCache(ctx, fmt.Sprintf("user:profile:%s", req.Uid), func(tx *gorm.DB) (*pb.GetProfileResponse, error) { + profile := &pb.GetProfileResponse{} + 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(profile).Error + return profile, err + }, + dbcache.WithDB(s.opts.db), + dbcache.WithDependency(dbcache.NewSqlDependency("SELECT `updated_at` FROM users WHERE `uid`=?", req.Uid)), + // dbcache.WithDepend("SELECT `updated_at` FROM users WHERE `uid`=?", req.Uid), + ) return } @@ -187,49 +210,67 @@ func (s *UserService) GetPermissions(ctx context.Context, req *pb.GetPermissionR 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, + Uid: req.Uid, } + res.Permissions, err = dbcache.TryCache(ctx, fmt.Sprintf("user:permissions:%s", req.Uid), func(tx *gorm.DB) ([]string, error) { + var ss []string + err = tx.Select("permission").Model(&models.RolePermission{}). + Joins("LEFT JOIN users on users.role = role_permissions.role"). + Where("users.uid = ?", req.Uid). + Pluck("permission", &ss). + Error + return ss, err + }, dbcache.WithCacheDuration(time.Minute), dbcache.WithDB(s.opts.db)) 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)), + res = &pb.GetUserLabelResponse{} + res.Data, err = dbcache.TryCache(ctx, fmt.Sprintf("user:labels"), func(tx *gorm.DB) ([]*pb.LabelValue, error) { + values := make([]*models.User, 0) + if err = tx.Find(&values).Error; err == nil { + items := make([]*pb.LabelValue, 0, len(values)) + for _, v := range values { + items = append(items, &pb.LabelValue{ + Label: v.Username, + Value: v.Uid, + }) + } + return items, nil + } else { + return nil, err } - for _, v := range values { - res.Data = append(res.Data, &pb.LabelValue{ - Label: v.Username, - Value: v.Uid, - }) - } - } + }, + dbcache.WithDB(s.opts.db), + dbcache.WithDependency(dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM users")), + ) 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)), + res = &pb.GetUserTagResponse{} + res.Data, err = dbcache.TryCache(ctx, fmt.Sprintf("user:tags"), func(tx *gorm.DB) ([]*pb.LabelValue, error) { + values := make([]*models.User, 0) + if err = tx.Select("DISTINCT(`tag`) AS `tag`").Find(&values).Error; err == nil { + items := make([]*pb.LabelValue, 0, len(values)) + for _, v := range values { + if v.Tag == "" { + continue + } + items = append(items, &pb.LabelValue{ + Label: v.Tag, + Value: v.Tag, + }) + } + return items, nil + } else { + return nil, err } - for _, v := range values { - res.Data = append(res.Data, &pb.LabelValue{ - Label: v.Tag, - Value: v.Tag, - }) - } - } + }, + dbcache.WithDB(s.opts.db), + dbcache.WithDependency(dbcache.NewSqlDependency("SELECT MAX(`updated_at`) FROM users")), + ) return } diff --git a/template.go b/template.go index ab629c5..55d614d 100644 --- a/template.go +++ b/template.go @@ -11,6 +11,7 @@ var ( :permissions="permissions" :disable-toolbar="false" default-sortable="id" + {{if .Readonly}}:readonly="true"{{end}} > diff --git a/types.go b/types.go index 4a9de0e..afc9c14 100644 --- a/types.go +++ b/types.go @@ -14,22 +14,22 @@ var ( types.ScenarioUpdate, types.ScenarioDelete, types.ScenarioView, - types.ScenarioImport, types.ScenarioExport, } ) type ( options struct { - db *gorm.DB - domain string - moduleName string - apiPrefix string //接口前缀 - viewPrefix string //生成菜单View的前缀路径 - vuePath string //生成Vue文件的路径,如果指定了启动的时候会自动生成Vue的文件 - translate Translate - httpServer *http.Server - restOpts []rest.Option + db *gorm.DB + domain string + moduleName string + apiPrefix string //接口前缀 + viewPrefix string //生成菜单View的前缀路径 + vuePath string //生成Vue文件的路径,如果指定了启动的时候会自动生成Vue的文件 + translate Translate + disableDefault bool + httpServer *http.Server + restOpts []rest.Option } Option func(*options) @@ -51,6 +51,7 @@ type ( ModuleName string TableName string ApiPrefix string + Readonly bool Permissions map[string]string } ) @@ -61,6 +62,12 @@ func WithDB(db *gorm.DB) Option { } } +func WithoutDefault() Option { + return func(o *options) { + o.disableDefault = true + } +} + func WithHttpServer(server *http.Server) Option { return func(o *options) { o.httpServer = server diff --git a/types/model.go b/types/model.go index b4e1341..369baff 100644 --- a/types/model.go +++ b/types/model.go @@ -17,3 +17,7 @@ type MenuModel interface { type ModuleModel interface { ModuleName() string } + +type PerrmissionModule interface { + ModelPermissions() map[string]string +} diff --git a/types/types.go b/types/types.go new file mode 100644 index 0000000..8a4e7e5 --- /dev/null +++ b/types/types.go @@ -0,0 +1,5 @@ +package types + +const ( + UserStatusNormal = "normal" +)